[PyKDE] Connecting slots to functions in a different namespace

Phil Thompson phil at river-bank.demon.co.uk
Sun Mar 30 02:00:01 BST 2003


On Saturday 29 March 2003 8:23 pm, Tom Chance wrote:
> I've got another problem that's come about by not wanting to create a new
> class for a dialogue box. Previously, I had a class for the dialogue which
> included a function connected to a button in the dialogue. Now that
> function isn't in that dialogue's class... it's in the namespace that is
> calling the class instance, e.g.:
>
> def function1(self):
> 	do some stuff...
> 	instance = ClassName()
>
> def function2(self):
> 	do some stuff...
>
> How can I connect the button in ClassName() to function2()? Or am I forced
> to put the function in ClassName()?

You can connect a Qt signal to any Python callable (ie. class method, global 
function etc.) See the documention.

Phil




More information about the PyQt mailing list