dodle
April 19th, 2009, 06:14 AM
Is there a way to set up events/event handlers using a single line for multiple buttons/objects? I already tried adding the buttons to a list, then binding the list.... that doesn't work.
For example if I bind three buttons, I use three lines of code:
button1.Bind(wx.EVT_BUTTON, self.EventHandler)
button2.Bind(wx.EVT_BUTTON, self.EventHandler)
button3.Bind(wx.EVT_BUTTON, self.EventHandler)
or just connecting:
wx.EVT_BUTTON(button1, -1, self.EventHandler)
wx.EVT_BUTTON(button2, -1, self.EventHandler)
wx.EVT_BUTTON(button3, -1, self.EventHandler)
For example if I bind three buttons, I use three lines of code:
button1.Bind(wx.EVT_BUTTON, self.EventHandler)
button2.Bind(wx.EVT_BUTTON, self.EventHandler)
button3.Bind(wx.EVT_BUTTON, self.EventHandler)
or just connecting:
wx.EVT_BUTTON(button1, -1, self.EventHandler)
wx.EVT_BUTTON(button2, -1, self.EventHandler)
wx.EVT_BUTTON(button3, -1, self.EventHandler)