[PyKDE] So how do I pass an argument to a function tied to a callback?

Aaron J. Ginn aaron.ginn at motorola.com
Fri Mar 2 20:46:11 GMT 2001


Ken Kozman wrote:
>     What I came up with was the following:
> 
>     # This is a silly little class to wrap function calling.
>     class CCommandDispatcher:
>         def __init__( self, function, functionId ):
>             self.caller = function
>             self.callerId = functionId
>         def invoke( self ):
>             self.caller( self.callerId )
> 
>     # Then later on...
>     self.dispatcher = CCommandDispatcher( self.buttonPressed, num )
>     self.connect( widget, SIGNAL( "clicked()" ), self.dispatcher.invoke )


This looks fairly clever.  I'll give it a shot if it's the only way to
get this working.  Thanks for the tip, Ken.

Aaron

-- 
Aaron J. Ginn                    Phone: 480-814-4463
Motorola SemiCustom Solutions    Pager: 877-586-2318
1300 N. Alma School Rd.          Fax  : 480-814-4463
Chandler, AZ 85226 M/D CH260     mailto:aaron.ginn at motorola.com




More information about the PyQt mailing list