[Tutor] Help with a simple problem

Kent Johnson kent37 at tds.net
Sat Jan 3 18:33:25 CET 2009


On Sat, Jan 3, 2009 at 11:39 AM, Saad Javed <sbjaved at gmail.com> wrote:
> The bold was intentional. I was trying to get a shell command (wvdial) to
> run when a button is pressed. The error I get is:
>
> Traceback (most recent call last):
>   File "testgui.py", line 26, in <module>
>     testgui = TestGui()
>   File "testgui.py", line 19, in __init__
>     self.connect(dial, QtCore.SIGNAL('clicked()'), QtGui.qApp,
> QtCore.SLOT(os.system('wvdial')))
> TypeError: argument 1 of SLOT() has an invalid type
>
> Was that helpful?

Maybe :-)

>From a quick look at the docs, it seems that QtCore.SLOT() is used to
get a reference to a Qt function. When you want to use your own
function as the target of an action, you just pass the function
directly. Try this:
        self.connect(dial, QtCore.SIGNAL('clicked()'),
            QtGui.qApp, lambda: os.system('wvdial'))

or define a named function that calls os.system() and pass the
function to connect().

Kent


More information about the Tutor mailing list