[wxpython-users] wx.NewId() interfering with manually set ids?
AK
andrei.avk at gmail.com
Mon Apr 14 04:45:28 PDT 2008
Hi.. in some examples I saw ids of menu items being set at the top of
program like this:
ID_NEW = 101
ID_EXIT = 102
...
Later on in the program, for some items that are not part of menus, the
id would be
assigned automatically, with wx.NewId(). I ran into some problem with
this. I had
a toolbar with a bunch of buttons. All of them worked fine except for
one that was
supposed to create a new copy of an item. That button used an id
assigned auto-
matically, and it was the last of them to do that (i.e. the buttons
after it assigned
ids manually, which is something I overlooked when I was debugging this
problem).
Also note that the first manual id was, at the top of the program, the
ID_EXIT:
ID_EXIT = 103
What would happen is that pushing that 'new copy' button would run the
action
bound to ID_EXIT. So, wx.NewId() would assign id = 103 even though it
was already bound to a menu item above it.
What's the best way to avoid this? Currently, in the app I distributed I
have
manually assigned ids after that button. Is it possible that on some systems
this behaviour would work differently and NewId() would assign a different
id that'd interfere with manual ids? I currently tested all other icons
and menu
items and they work properly.
In the development version I assigned all menu item ids on top to start at
1100 instead of 100, but that doesn't seem like a generally nice solution.
More information about the wxpython-users
mailing list