Is it possible to have the Python code generation bind the event to the
control, rather than the form?
When I have a notebook with several pages, all the buttons become bound to
the same event handler, even though more than one event handler is
specified
for the buttons.
I have to use objectIDs as I have a large number of buttons calling each
handler. The current arrangement makes it tricky to maintain.
e.g.
The following code is generated.
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnPulEnableToggle, id=1)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnPulEnableToggle, id=2)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnPulEnableToggle, id=3)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnRecEnableToggle, id=1)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnRecEnableToggle, id=2)
self.Bind(wx.EVT_TOGGLEBUTTON, self.OnRecEnableToggle, id=3)
meaning only OnRecEnableToggle() is called.
Now, of course I can specify different IDs for each page, but that seems
silly when it could just bind the event to the button, thus:
self.pul_enable_1 = wx.ToggleButton(self.PulserPane, 1,
"Disabled")
self.pul_enable_2 = wx.ToggleButton(self.PulserPane, 2,
"Disabled")
self.pul_enable_3 = wx.ToggleButton(self.PulserPane, 3,
"Disabled")
self.rec_enable_1 = wx.ToggleButton(self.ReceiverPane, 1,
"ENABLED")
self.rec_enable_2 = wx.ToggleButton(self.ReceiverPane, 2,
"ENABLED")
self.rec_enable_3 = wx.ToggleButton(self.ReceiverPane, 3,
"ENABLED")
self.pul_enable_1.Bind(wx.EVT_TOGGLEBUTTON,
self.OnPulEnableToggle)
self.pul_enable_2.Bind(wx.EVT_TOGGLEBUTTON,
self.OnPulEnableToggle)
self.pul_enable_3.Bind(wx.EVT_TOGGLEBUTTON,
self.OnPulEnableToggle)
self.rec_enable_1.Bind(wx.EVT_TOGGLEBUTTON,
self.OnRecEnableToggle)
self.rec_enable_2.Bind(wx.EVT_TOGGLEBUTTON,
self.OnRecEnableToggle)
self.rec_enable_3.Bind(wx.EVT_TOGGLEBUTTON,
self.OnRecEnableToggle)
After all, it is still possible to pass the event on downto the form if
requred using Skip()
Alberto Griggio
None
None
Public
|
Date: 2007-08-06 11:53
|
| Field | Old Value | Date | By |
|---|---|---|---|
| assigned_to | nobody | 2007-08-06 11:53 | agriggio |