Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PyQt processEvents not processing

Reply
Thread Tools

PyQt processEvents not processing

 
 
DarkBlue
Guest
Posts: n/a
 
      11-07-2009
qt 4.5.3
pyqt 4.6.1
python 2.6

I have this QtTable widget which I want to refresh once about every 2
seconds with new data.

so I do :

def updateSchedule(self):
for j in range(0,10):
doUpdate()
QtCore.processEvents()
sleep(2)

unfortunately QT appears to wait until the for loop finishes
and only then paints the QtTable widget on the screen showing
only the latest updated result.

if I connect the doUpdate() to a Qtpushbutton widget and physically
click the pushbutton , everything is fine and the updates get shown on
every click.

What is the right way to simulate this pushbutton click so that
the table widget gets 'visibly' refreshed for every iteration of the
loop ?


Thanks
Db

 
Reply With Quote
 
 
 
 
David Boddie
Guest
Posts: n/a
 
      11-07-2009
On Saturday 07 November 2009 05:12, DarkBlue wrote:

> qt 4.5.3
> pyqt 4.6.1
> python 2.6
>
> I have this QtTable widget which I want to refresh once about every 2
> seconds with new data.
>
> so I do :
>
> def updateSchedule(self):
> for j in range(0,10):
> doUpdate()
> QtCore.processEvents()
> sleep(2)
>
> unfortunately QT appears to wait until the for loop finishes
> and only then paints the QtTable widget on the screen showing
> only the latest updated result.


It's difficult to know exactly why this is without more context. Calling
the application's processEvents() method should give the user interface the
chance to update itself, but perhaps you need to explicitly call update()
on the QTableView or QTableWidget instance to ensure that it is refreshed.

An alternative way to do this is to use a timer to update the table every
two seconds.

David
 
Reply With Quote
 
 
 
 
DarkBlue
Guest
Posts: n/a
 
      11-08-2009
On Nov 8, 12:04*am, David Boddie <(E-Mail Removed)> wrote:
> On Saturday 07 November 2009 05:12, DarkBlue wrote:
>
>
>
> > qt 4.5.3
> > pyqt 4.6.1
> > python 2.6

>
> > I have this QtTable widget which I want to refresh once about every 2
> > seconds with new data.

>
> > so I do :

>
> > *def updateSchedule(self):
> > * * * * *for j in range(0,10):
> > * * * * * * * * * * * doUpdate()
> > * * * * * * * * * * * QtCore.processEvents()
> > * * * * * * * * * * * sleep(2)

>
> > *unfortunately QT appears to wait until the for loop finishes
> > *and only then paints the QtTable widget on the screen showing
> > *only the latest updated result.

>
> It's difficult to know exactly why this is without more context. Calling
> the application's processEvents() method should give the user interface the
> chance to update itself, but perhaps you need to explicitly call update()
> on the QTableView or QTableWidget instance to ensure that it is refreshed..
>
> An alternative way to do this is to use a timer to update the table every
> two seconds.
>
> David



As per your suggestion I added a timer to the init part and now the
update works as expected , even without calls to processEvents.

self.myTimer = QtCore.QTimer(self)
QtCore.QObject.connect(self.myTimer,QtCore.SIGNAL( "timeout()"),
self.doUpdate)
self.timerTime = 0
self.myTimer.start(2000)

Thanks
Db
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PyQt not working well on Mac OS X Michael McGarry Python 2 12-14-2005 11:10 AM
Post-Processing RAW vs Post-Processing TIFF Mike Henley Digital Photography 42 01-30-2005 08:26 AM
Question: processing HTML, re-write default processing action of many tags Hubert Hung-Hsien Chang Python 2 09-17-2004 03:10 PM
[PY GUI] interest function in python GUI(wxpython,pyqt) program.wxpython,pyqt ulysses Python 4 10-22-2003 03:28 PM
PyQt: Can't show QFileDialog.getExistingDirectory in Python Thread, bug or not? ulysses Python 0 09-16-2003 04:09 AM



Advertisments