Hello list,
I'm pretty new to wxPython. I now have a Problem with EVT_CHAR events:
On reading the event system dokumentation, I expected, that calling
event.Skip() within an event handler would chain to the next relevant
handler up the containment hirarchy.
In my test application, I have a wxPanel placed inside a wxFrame. The
wxPanel catches some keys, but most keys are unhandled and I call
event.Skip() on them. I have registered an event Handler vor EVT_CHAR
events in the wxFrame and would expect to receive all unhandled
EVT_CHAR events there, but this handler is never called. Is this the
expected behaviour and did I understand the dokumentation wrong or
should my Konzept work (and I made some stupid mistake on registering
the handlers ...)?
In code form:
from wxPython.wx import *
import sys
class MyPanel(wxPanel):
def __init__(self,parent,id):
wxPanel.__init__(self,parent,id)
EVT_CHAR(self,self.OnChar)
def OnChar(self,event):
sys.stderr.write("MyPanel.OnChar\n")
event.Skip()
class MyFrame(wxFrame):
def __init__(self,title):
wxFrame.__init__(self,None,-1,title,(-1,-1),(-1,-1))
MyPanel(self,-1)
EVT_CHAR(self,self.OnChar)
def OnChar(self,event):
sys.stderr.write("MyFrame.OnChar\n")
event.Skip()
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame("EVT_CHAR test")
frame.Show(true)
self.SetTopWindow(frame)
EVT_CLOSE(self,self.OnClose)
return true
def OnClose(self,event):
self.Destroy()
app = MyApp(0)
app.MainLoop()
I would like this to call *both* MyPanel.OnChar and MyFrame.OnChar,
but only MyPanel.OnChar is called. What would be the correct way to
solve this Problem?
Stefan.