Question regarding event binding and propagation:
Is it possible to bind an event to a frame (the parent widget) even
though there are other widgets like panels on top of it? What I am
saying is, I have a frame that contains numerous panels and the frame
has a mouse motion event bound to itself (see code below). Now is it
possible that the mouse events are caught even though there are other
panels on top of the frame. Kind of like reversed propagation?
class MainFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
self.parent = parent
self.initialize()
def initialize(self):
hbox = wx.BoxSizer(wx.HORIZONTAL)
panel1 = wx.Panel(self, wx.ID_ANY)
panel2 = wx.Panel(self, wx.ID_ANY)
panel3 = wx.Panel(self, wx.ID_ANY)
panel4 = wx.Panel(self, wx.ID_ANY)
hbox.Add(panel1, 1, wx.EXPAND)
hbox.Add(panel2, 1, wx.EXPAND)
hbox.Add(panel3, 1, wx.EXPAND)
hbox.Add(panel4, 1, wx.EXPAND)
self.SetSizer(hbox)
self.Centre()
self.Bind(wx.EVT_MOTION, self.OnMotion)
def OnMotion(self, event):
xpt = wx.GetMousePosition()
print "i am moving "+str(xpt)
class MyApp(wx.App):
def OnInit(self):
frame = MainFrame(None, -1, 'EXperiment')
frame.Show(True)
frame.SetPosition(wx.Point(0,0))
frame.SetSize(wx.Size(1600,800))
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
Not sure if this is the right place for my question... Sorry. Dom