Can't get menu title for popup menus in Windows

Isaac Wagner geekyisaac at gmail.com
Fri Feb 2 07:42:22 PST 2007


I've got a program that I created for both Windows and Linux.  It
works great under Linux, but I'm having trouble in Windows that I
can't seem to figure out.  In one window I have a context menu (right
click menu) with a couple submenu's.  When creating the menu I use the
call SetTitle on the submenu's.  Here's what I have for my menu event:

    def OnPopupMenu(self, evt):
        menu = evt.GetEventObject()
        title = menu.GetTitle()
        print "Title = " + title
        item = evt.GetId()
        text = menu.GetLabel(item)
        print "Menu item selected: " + text
        if title == 'Menu1':
            self.DoSomething1(text)
        if title == 'Menu2':
            self.DoSomething2(text)
        evt.Skip()

On Linux things work as expected.  For title I get either "Menu1" or
"Menu2" depending on which submenu the item was selected from.
However, on Windows the title is always an empty string.  Is this a wx
issue or is it a Windows issue?  Does anyone know any workarounds?

Thanks,

Isaac




More information about the wxpython-users mailing list