Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - PyQt processEvents not processing

 
Thread Tools Search this Thread
Old 11-07-2009, 04:12 AM   #1
Default PyQt processEvents not processing


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



DarkBlue
  Reply With Quote
Old 11-07-2009, 04:04 PM   #2
David Boddie
 
Posts: n/a
Default Re: PyQt processEvents not processing
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


David Boddie
  Reply With Quote
Old 11-08-2009, 02:16 AM   #3
DarkBlue
 
Posts: n/a
Default Re: PyQt processEvents not processing
On Nov 8, 12:04*am, David Boddie <da...@boddie.org.uk> 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


DarkBlue
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Risk FREE Electronic Check Processing rebateprocessing Computer Information 0 06-19-2009 07:41 AM
Check Processing Services with 99% Accuracy rebateprocessing Computer Information 0 06-19-2009 07:39 AM
File processing error,possibly disk is full. native error devaraja007 Software 0 03-30-2009 01:23 PM
How to automatize video files processing? Wormund Computer Support 0 09-03-2008 05:16 PM
Valve talks about Multi-Core CPU Processing in Source Silverstrand Front Page News 0 11-07-2006 12:47 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46