Share

wxGlade

Tracker: Feature Requests

5 Event binding (with notebooks) - ID: 1699997
Last Update: Comment added ( agriggio )

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()


the-moog ( the-moog ) - 2007-04-13 13:18

5

Open

None

Alberto Griggio

None

None

Public


Comment ( 1 )




Date: 2007-08-06 11:53
Sender: agriggioProject Admin


First of all, sorry for the very long delay of my reply.
Anyway, I see the problem and I'll put it on my TODO list. I will do it
for python output, and it's likely to be done for perl as well, but not for
C++ (as the event-binding code for C++ is based on event tables, so it
would be much a bigger change...)


Log in to comment.

Attached File

No Files Currently Attached

Change ( 1 )

Field Old Value Date By
assigned_to nobody 2007-08-06 11:53 agriggio