Hi,
(wxPython 2.8.6.0/python 2.5.1 on Ubuntu)
It seems that wx.Menu.FindItem is broken for menu items with
accelerators ('&'). See attached sample. Hopefully I'm missing
something?
Cheers, Frank
menu_finditem.py (682 Bytes)
Hi,
(wxPython 2.8.6.0/python 2.5.1 on Ubuntu)
It seems that wx.Menu.FindItem is broken for menu items with
accelerators ('&'). See attached sample. Hopefully I'm missing
something?
Cheers, Frank
menu_finditem.py (682 Bytes)
Weird! Check this out, Frank -- it turns the '&' into a '_'! Here's
the output of the attached program:
Menu item Without accelerator found
Menu item &With accelerator not found
wxMenuItemList: [<wx._core.MenuItem; proxy of <Swig Object of type
'wxMenuItem *' at 0xb13da0> >, <wx._core.MenuItem; proxy of <Swig
Object of type 'wxMenuItem *' at 0xb213b0> >]
Without accelerator
Without accelerator
_With accelerator
_With accelerator
Menu item Without accelerator found
Menu item &With accelerator not found
Menu item _With accelerator found
Maybe I missed it in the documentation somewhere, but I would have
thought you could have found a menu item using the same label that you
passed to the menu creation function...
On windows, your original attached example works fine and my
modification doesn't work. So, I wonder if this is a result of
intended platform differences, or just a bug?
Rob
menu_finditem2.py (1.23 KB)
On 10/7/07, Frank Niessink <frank@niessink.com> wrote:
It seems that wx.Menu.FindItem is broken for menu items with
accelerators ('&'). See attached sample. Hopefully I'm missing
something?
Hi Frank,
On 10/7/07, Frank Niessink wrote:
(wxPython 2.8.6.0/python 2.5.1 on Ubuntu)
It seems that wx.Menu.FindItem is broken for menu items with
accelerators ('&'). See attached sample. Hopefully I'm missing
something?
It works ok on my Windows box, so it might be a wxGTK issue... I have
no idea
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
It's a platform difference (GTK uses the underscore to indicate
accelerators in format strings the same way that Windows uses &, wx
standardizes on &), but it should do the opposite conversion also.
Please file a bug report on SF.
On 10/7/07, Rob McMullen <rob.mcmullen@gmail.com> wrote:
On 10/7/07, Frank Niessink <frank@niessink.com> wrote:
> It seems that wx.Menu.FindItem is broken for menu items with
> accelerators ('&'). See attached sample. Hopefully I'm missing
> something?Weird! Check this out, Frank -- it turns the '&' into a '_'! Here's
the output of the attached program:Menu item Without accelerator found
Menu item &With accelerator not found
wxMenuItemList: [<wx._core.MenuItem; proxy of <Swig Object of type
'wxMenuItem *' at 0xb13da0> >, <wx._core.MenuItem; proxy of <Swig
Object of type 'wxMenuItem *' at 0xb213b0> >]
Without accelerator
Without accelerator
_With accelerator
_With accelerator
Menu item Without accelerator found
Menu item &With accelerator not found
Menu item _With accelerator foundMaybe I missed it in the documentation somewhere, but I would have
thought you could have found a menu item using the same label that you
passed to the menu creation function...On windows, your original attached example works fine and my
modification doesn't work. So, I wonder if this is a result of
intended platform differences, or just a bug?
Rob McMullen wrote:
It seems that wx.Menu.FindItem is broken for menu items with
accelerators ('&'). See attached sample. Hopefully I'm missing
something?
There were some changes made to some of the methods dealing with menu, menubar, and menuitem labels, trying to get them to all use the same terminology in the method names, etc. The main changes were done in the SVN trunk for 2.9 but there were also some changes made in the 2.8 branch to help facilitate forward compatibility, but it was supposed to not affect any existing functionality. Did this work for you prior to 2.8.6.0 or did it also have the & --> _ 'feature'? (see below)
Weird! Check this out, Frank -- it turns the '&' into a '_'! Here's
the output of the attached program:Menu item Without accelerator found
Menu item &With accelerator not found
wxMenuItemList: [<wx._core.MenuItem; proxy of <Swig Object of type
'wxMenuItem *' at 0xb13da0> >, <wx._core.MenuItem; proxy of <Swig
Object of type 'wxMenuItem *' at 0xb213b0> >]
Without accelerator
_With accelerator
Menu item Without accelerator found
Menu item &With accelerator not found
Menu item _With accelerator foundMaybe I missed it in the documentation somewhere, but I would have
thought you could have found a menu item using the same label that you
passed to the menu creation function...On windows, your original attached example works fine and my
modification doesn't work. So, I wonder if this is a result of
intended platform differences, or just a bug?
GTK uses the _ the same way that Windows uses the &, so the labels get translated for wxGTK changing the &'s into _'s. I had thought that searching would also do the translation, but maybe that broke as an unintended side-effect of the recent changes I mentioned.
On 10/7/07, Frank Niessink <frank@niessink.com> wrote:
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
I'm pretty sure FindItems worked before (2.8.4.2 was the last but one
version I had installed on Ubuntu I think). I am also pretty sure that
FindItemByPosition did *not* work before. This is code from Task
Coach's unit tests that tests the "recent files" menu. It was checked
in December last year:
for index, expectedFilename in enumerate(expectedFilenames):
menuItem = self.menu.FindItemByPosition(self.initialFileMenuLength-1+index)
# Apparently the '&' can also be a '_' (seen on Ubuntu)
expectedLabel = u'&%d %s'%(index+1, expectedFilename)
self.assertEqual(expectedLabel[1:], menuItem.GetText()[1:])
Cheers, Frank
2007/10/8, Robin Dunn <robin@alldunn.com>:
Rob McMullen wrote:
> On 10/7/07, Frank Niessink <frank@niessink.com> wrote:
>> It seems that wx.Menu.FindItem is broken for menu items with
>> accelerators ('&'). See attached sample. Hopefully I'm missing
>> something?There were some changes made to some of the methods dealing with menu,
menubar, and menuitem labels, trying to get them to all use the same
terminology in the method names, etc. The main changes were done in the
SVN trunk for 2.9 but there were also some changes made in the 2.8
branch to help facilitate forward compatibility, but it was supposed to
not affect any existing functionality. Did this work for you prior to
2.8.6.0 or did it also have the & --> _ 'feature'? (see below)
Frank Niessink wrote:
2007/10/8, Robin Dunn <robin@alldunn.com>:
Rob McMullen wrote:
On 10/7/07, Frank Niessink <frank@niessink.com> wrote:
It seems that wx.Menu.FindItem is broken for menu items with
accelerators ('&'). See attached sample. Hopefully I'm missing
something?There were some changes made to some of the methods dealing with menu,
menubar, and menuitem labels, trying to get them to all use the same
terminology in the method names, etc. The main changes were done in the
SVN trunk for 2.9 but there were also some changes made in the 2.8
branch to help facilitate forward compatibility, but it was supposed to
not affect any existing functionality. Did this work for you prior to
2.8.6.0 or did it also have the & --> _ 'feature'? (see below)I'm pretty sure FindItems worked before (2.8.4.2 was the last but one
version I had installed on Ubuntu I think). I am also pretty sure that
FindItemByPosition did *not* work before. This is code from Task
Coach's unit tests that tests the "recent files" menu. It was checked
in December last year:for index, expectedFilename in enumerate(expectedFilenames):
menuItem = self.menu.FindItemByPosition(self.initialFileMenuLength-1+index)
# Apparently the '&' can also be a '_' (seen on Ubuntu)
expectedLabel = u'&%d %s'%(index+1, expectedFilename)
self.assertEqual(expectedLabel[1:], menuItem.GetText()[1:])
I think it's probably a bug that item.GetText doesn't behave the same as before, but I don't remember the conversations about this change to be sure. Entering a bug report about it might turn up an answer from the person who made the changes. In the meantime I think that GetItemLabel should give you exactly what was set in the item, including the &.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Hi Robin,
2007/10/9, Robin Dunn <robin@alldunn.com>:
I think it's probably a bug that item.GetText doesn't behave the same as
before, but I don't remember the conversations about this change to be
sure. Entering a bug report about it might turn up an answer from the
person who made the changes.
I entered a bug report:
http://sourceforge.net/tracker/index.php?func=detail&aid=1810349&group_id=9863&atid=109863
Cheers, Frank