Help on PyQt4 QProcess

Edgar Fuentes fuentesej at gmail.com
Fri Aug 19 15:55:40 EDT 2011


On Aug 19, 1:56 pm, Phil Thompson <p... at riverbankcomputing.com> wrote:
> On Fri, 19 Aug 2011 10:15:20 -0700 (PDT), Edgar Fuentes
>
>
>
>
>
>
>
>
>
> <fuente... at gmail.com> wrote:
> > Dear friends,
>
> > I need execute an external program from a gui using PyQt4, to avoid
> > that hang the main thread, i must connect the signal "finished(int)"
> > of a QProcess to work properly.
>
> > for example, why this program don't work?
>
> >    from PyQt4.QtCore import QProcess
> >    pro = QProcess() # create QProcess object
> >    pro.connect(pro, SIGNAL('started()'), lambda
> > x="started":print(x))        # connect
> >    pro.connect(pro, SIGNAL("finished(int)"), lambda
> > x="finished":print(x))
> >    pro.start('python',['hello.py'])        # star hello.py program
> > (contain print("hello world!"))
> >    timeout = -1
> >    pro.waitForFinished(timeout)
> >    print(pro.readAllStandardOutput().data())
>
> > output:
>
> >    started
> >    0
> >    b'hello world!\n'
>
> > see that not emit the signal finished(int)
>
> Yes it is, and your lambda slot is printing "0" which is the return code
> of the process.
>
> Phil

Ok, but the output should be:

    started
    b'hello world!\n'
    finished

no?.

thanks Phil



More information about the Python-list mailing list