From: Kevin A. <al...@se...> - 2004-08-26 15:21:18
|
On Aug 26, 2004, at 6:26 AM, Phil Edwards wrote: > I've been using a custom event handler in one of my PythonCard apps, as > follows: > > wx.EVT_LEFT_UP(self.components.versionString, self.on_multiSelect) > > I've changed this to: > > wxEVT_LEFT_UP(self.components.versionString, self.on_multiSelect) > > the on_multiSelect() function doesn't do anything earth shattering: > > def on_multiSelect(self, event): > if event.controlDown: self.need2Add = 1 > > The flag that's being set is dealt with elsewhere in the code. > > I get an exception thrown when starting the program: > > Traceback (most recent call last): > File "./pimp.py", line 59, in on_initialize > wxEVT_LEFT_UP(self.components.versionString, self.on_multiSelect) > TypeError: 'int' object is not callable > > The migration guide tells me I should post event binding issues to the > mailing > list, so here I am... :-) > Assuming you are doing an import wx, to use the wx package instead of wxPython.wx then the function is wx.EVT_LEFT_UP and the event id constant is wx.wxEVT_LEFT_UP. You can see these defined for the 'mouseUp' event in PythonCard/event.py class MouseUpEvent(MouseEvent): name = 'mouseUp' binding = wx.EVT_LEFT_UP id = wx.wxEVT_LEFT_UP Now the question I have to ask you is why are you binding your own event instead of just using on_versionString_mouseUp? If you want to have a single mouseUp handler for multiple controls then just make it on_mouseUp and do a check of the target to make sure you are processing for the components you are interested in, otherwise call event.skip() so the event is passed on. Also, since PythonCard doesn't bind events that it can't find event handlers for the additional attributes such as controlDown won't be available if you do your own binding, so you'll have to use the wxPython method event.ControlDown() ka |