[wxPython-users] Can't get menu title for popup menus in Windows
Isaac Wagner
geekyisaac at gmail.com
Fri Feb 2 08:34:35 PST 2007
Unfortunately, my menus are generated from info collected at runtime,
so I am never sure what the menu title will end up being. That makes
it hard to create different handlers for the different menus.
On 2/2/07, Chris Mellon <arkanes at gmail.com> wrote:
> 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.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
More information about the wxpython-users
mailing list