[PyQt] Another connect problem

Thomas Olsen tanghus at gmail.com
Fri Oct 2 13:01:04 BST 2009

On 2/10-2009 01:09 Thomas Olsen <tanghus at gmail.com> wrote:
> On 1/10-2009 23:51 David Boddie <david at boddie.org.uk> wrote:
> > job.data.connect(self.job_received)
> Thanks! It works. It really is true that the new syntax is more python
>  like. The documentation was so explicit that I didn't understand it :-)
>  The only problem now is that the method doesn't actually get any data.
>     def job_received(self, job, data):
>         print "Data received: " + data
> I run "urllib2.urlopen(url).read().strip()" at the same time to check that
>  the url contains some data, but when job_received is called it only prints
>  out "Data received: " and a newline.
> Well it's late now and I've had some red wine so I'll wait until tomorrow
>  to debug anymore.
> Thanks for the help.

I made it work despite the red wine - but now I don't remember what I changed 
to make it work :-D (kidding)

Today I wanted to change my other connections to the new-style syntax. I have 
a Plasma.Label[1] connected to a method in my class in "old-style" that works:

      SIGNAL("textChanged(const QString &)"),self.do_convert_from)

I tried to change it the way you showed but apparently it wasn't as simple as 
I was hoping:


"self" is a subclass of plasmascript.Applet [2].

This resulted in the following exception:

Original exception was:
Traceback (most recent call last):
  File "/usr/share/kde4/apps/plasma_scriptengine_python/pyappletscript.py", 
line 55, in init
  File "/home/tol/snippets/currency-converter-plasma/contents/code/main.py", 
line 453, in init
TypeError: argument 1 of QObject.connect() has an invalid type

[1] http://api.kde.org/pykde-4.3-api/plasma/Plasma.Label.html
[2] http://api.kde.org/pykde-4.3-api/plasma/Plasma.Applet.html

Best Regards / Med venlig hilsen

  Thomas Olsen

More information about the PyQt mailing list