[wxPython-users] Can't get menu title for popup menus in Windows
Chris Mellon
arkanes at gmail.com
Fri Feb 2 07:51:37 PST 2007
On 2/2/07, Isaac Wagner <geekyisaac at gmail.com> wrote:
> 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?
>
I've never tried this, although I suspect it's a Windows artifact that
wx should probably try to work around. The reason why I've never tried
it, though, is that I bind the submenus to different event handlers by
using different IDs instead of doing secondary dispatch. You might try
taking that approach.
More information about the wxpython-users
mailing list