[Tutor] Help with a simple problem
bob gailer
bgailer at gmail.com
Sat Jan 3 22:15:09 CET 2009
Saad Javed 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?
Yes.
When calling self.connect all of its arguments are evaluated. This means
that QtCore.SLOT is called with an argument of os.system('wvdial') which
in turn means that os.system is called with an argument of 'wvdial'.
Thus wvdial is run as part of creating an instance of the class;
os.system then returns an integer (see docs for explanation).
self.connect is expecting "os.system('wvdial')" (character string).
So try self.connect(dial, QtCore.SIGNAL('clicked()'), QtGui.qApp,
QtCore.SLOT("os.system('wvdial')")).
--
Bob Gailer
Chapel Hill NC
919-636-4239
More information about the Tutor
mailing list