Timothy Smith wrote:
John Fouhy wrote:
Does that apply for menus too? All the documentation I've seen talking
about creating menus uses wx.EVT_MENU.
menus are not real wx.windows, so they are different, and don't have a bind() method.
eg, this is from the wxPython demo:
b = MyButton(self, -1, " Click me ", (30,30))
self.Bind(wx.EVT_BUTTON, self.OnClick, id=b.GetId())
Why would you not just write b.Bind(wx.EVT_BUTTON, self.OnClick) ?
No reason, b.Bind(wx.EVT_BUTTON, self.OnClick) is the best way to do it. Unfortunately, the demo and all the docs, Wiki, etc, are evolving documents, and no one has the time to go through and make sure everything gets updated to the latest and greatest syntax when changes are made.
I am intrested in how you can create a menu when using the event manager. the wx.menu objects don't seem to allow the us of anything BUT ID's
I don't know about the Event Manager, but it does make sense that menus wouldn't work with them, as they are not real windows. However, at least you can do:
item = wx.MenuItem(FileMenu, wx.ID_ANY, "&Quit")
FileMenu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnQuit, item)
So you don't need explicit IDs. I NEVER use explicit IDs. In this case self is a wx.Frame.
For that matter that above button example can also be done as:
self.Bind(wx.EVT_BUTTON, self.OnClick, b)
You can pass in either the Window itself ,or the ID of the Window that is creating the event.
-CHB
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov