[PyQt] Another connect problem

Hans-Peter Jansen hpj at urpla.net
Fri Oct 2 13:43:57 BST 2009


Am Freitag 02 Oktober 2009 schrieb Thomas Olsen:
> 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:
>
>   QObject.connect(self.currency_from,
>       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.currency_from.connect(self.do_convert_from)

Try:
self.currency_from.textChanged.connect(self.do_convert_from)

The pattern is:

sender.signal.connect(handler)

Hth,
Pete


More information about the PyQt mailing list