[Tutor] Help with a simple problem

Saad Javed sbjaved at gmail.com
Sat Jan 3 18:45:56 CET 2009


I implemented a dial function and passed it to the QtCore.SLOT(), which
worked fine. Thanks everyone!

On Sat, Jan 3, 2009 at 10:33 PM, Kent Johnson <kent37 at tds.net> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090103/33b2c446/attachment-0001.htm>


More information about the Tutor mailing list