namespace problems in pyqt

Phil Thompson phil at
Sun Mar 30 03:06:35 CEST 2003

On Sunday 30 March 2003 12:29 am, Tom Chance wrote:
> Hullo,
> I've got a problem that's come about by not wanting to create a new
> class for a dialogue box in PyQt. Previously, I had a class for the
> dialogue which included a function connected to a button in the dialogue. I
> made the class for the dialogue box in Qt Designer, imported that class,
> inherited it in a new class, into which I put the function (so it overrode
> the empty function declaration in the original class), like so:
> class Inherited(QDialog):
>         /all the pyqt stuff/
>         connect signal to function2
> class Inheritor(Inherited):
>         def function2:
>                 /so some stuff/

This isn't valid Python.

> 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 = Inherited()
> def function2(self):
>         /do some stuff.../

Are these class methods or functions? Functions don't (to be more accurate, 
shouldn't) have self arguments.

> How can I connect the button in Inherited to function2()? I've been told
> you can connect a Qt signal to a global function, but I can't work out how;
> I've tried declaring "global function2", and I've read through the Qt docs,
> but I cant' figure it out, so I'm obviously just being dumb and missing
> something here. Can someone give me a hand?

It isn't clear which function2() you want to connect to. Either way, simply 
use the name in the call to connect(), ie.






More information about the Python-list mailing list