From: Phil E. <ph...@li...> - 2004-08-26 13:27:48
|
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... :-) -- Regards Phil Edwards Brighton, UK |
From: Alex T. <al...@tw...> - 2004-08-26 14:59:46
|
At 14:26 26/08/2004 +0100, 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: This may be a really dumb question, but ... why ? As far as I can tell, there shouldn't be any need to change this; at least, the resourceEditor in 0.8 still uses wx.EVT_LEFT_UP(self.panel, self.on_mouseUp) >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... :-) Try changing it back ? What error do you get then ? If this doesn't help, I'm afraid it'll need to wait for Kevin or someone else ... -- Alex. |
From: Phil E. <ph...@li...> - 2004-08-26 16:08:42
|
On Thursday 26 Aug 2004 16:09, Alex Tweedly wrote: > > This may be a really dumb question, but ... why ? > The GUI for the app has a bunch of imageButton components and I need to allow multiple selections by left-clicking whilst holding down the control key. Take a look at the first entry on: http://pythoncard.sourceforge.net/moreapplications.html > As far as I can tell, there shouldn't be any need to change this; at least, > the resourceEditor in 0.8 still uses > wx.EVT_LEFT_UP(self.panel, self.on_mouseUp) > > >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 > > Several words spring to mind, all of them Anglo-Saxon/Germanic in origin and none of them very polite...I should have engaged brain before posting. You are, of course, completely correct - no change is required to the event binding line. The real issue is that my event handling code isn't getting fired. I'd expect to see a message printed when I run the app from the command line with the following code: def on_multiSelect(self, event): print 'here we are!' if event.controlDown: self.need2Add = 1 -- Regards Phil Edwards Brighton, UK |
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 |
From: Phil E. <ph...@li...> - 2004-08-26 16:28:20
|
On Thursday 26 Aug 2004 16:21, Kevin Altis wrote: > > 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 I just trawled through the mailing list archives, because I was convinced that there'd been a posting somewhere describing the method of adding events that I've been using in my app, but I can't find it. > 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. > I'll go and re-code that part of the app. -- Regards Phil Edwards Brighton, UK |
From: Phil E. <ph...@li...> - 2004-08-26 16:53:31
|
> > > 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. > > I'll go and re-code that part of the app. That seems to work perfectly, thanks! -- Regards Phil Edwards Brighton, UK |