I created a menubar, but the callback does not seem to be called. What is wrong with the following test code. (I am using Python 2.2, WxPython 2.4-2.2, on a Mandrake 9.0).
Thanks a lot for any hint !
#!/usr/bin/env python
from wxPython.wx import *
class CMenuBar(wxMenuBar):
def __init__ (self,parent):
wxMenuBar.__init__(self)
menu = wxMenu()
ID = wxNewId()
menu.Append(ID,"Exit","Exit Application")
self.Append(menu, "File")
EVT_MENU(self,ID, self.OnExit)
Change EVT_MENU(.... to this
EVT_MENU(parent,ID, self.OnExit)
···
Op do 24-07-2003, om 14:48 schreef Peter Wurmsdobler:
Hello again,
I created a menubar, but the callback does not seem to be called. What
is wrong with the following test code. (I am using Python 2.2, WxPython
2.4-2.2, on a Mandrake 9.0).
Thanks a lot for any hint !
#!/usr/bin/env python
from wxPython.wx import *
class CMenuBar(wxMenuBar):
def __init__ (self,parent):
wxMenuBar.__init__(self)
menu = wxMenu()
ID = wxNewId()
menu.Append(ID,"Exit","Exit Application")
self.Append(menu, "File")
EVT_MENU(self,ID, self.OnExit)
class Cdm(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
self.Appl = CAppl (None, -1, "Application")
self.SetTopWindow (self.Appl)
self.Appl.Show (1)
return True
if __name__ == "__main__":
dm = Cdm()
dm.MainLoop()
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
Change EVT_MENU(.... to this
EVT_MENU(parent,ID, self.OnExit)
Thanks a lot, now it works !
Just to give some more info about this, the events from menubars are delivered to the frame they are attached to. There has been talk about posisbly changing this so they go to the menubar first, but if that happens it will only be in 2.5 and beyond.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!