I've been using wxPython for probably 5 years now, and I'm
afraid I still don't "get" event IDs.
For example, I don't understand how one knows what event IDs to
use when doing things like binding handlers to menu items.
Here's the example from the tutorial:
from wxPython.wx import *
ID_ABOUT = 101
ID_EXIT = 102
class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(200, 150))
self.CreateStatusBar()
self.SetStatusText("This is the statusbar")
menu = wxMenu()
menu.Append(ID_ABOUT, "&About",
"More information about this program")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar = wxMenuBar()
menuBar.Append(menu, "&File");
self.SetMenuBar(menuBar)
EVT_MENU(self, ID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_EXIT, self.TimeToQuit)
Where do the values 101 and 102 come from? How are they
different from wx.ID_ABOUT and wx.ID_EXIT. When would you use
wx.ID_ABOUT or wx.ID_EXIT?
When pulling numbers like 101 and 102 out of the air, how do
you know they don't conflict with event IDs wx is using for
something else? Is the event "number space" considered to be
global?
Why should one even have to pull a bunch of arbitrary numbers
out of the air in order to connect a handler to a menu? Why
not just tell the menu what hanlder to call?
menu.Append("&About","More information about this program",handler=self.OnAbout)
If oen were to subclass wx.Menu to do that, what are the rules
for generating event IDs?
···
--
Grant Edwards grante Yow! Can I have an IMPULSE
at ITEM instead?
visi.com