PyQt processEvents not processing

Discussion in 'Python' started by DarkBlue, Nov 7, 2009.

  1. DarkBlue

    DarkBlue Guest

    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, Nov 7, 2009
    #1
    1. Advertising

  2. DarkBlue

    David Boddie Guest

    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, Nov 7, 2009
    #2
    1. Advertising

  3. DarkBlue

    DarkBlue Guest

    Re: PyQt processEvents not processing

    On Nov 8, 12:04 am, David Boddie <> 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, Nov 8, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ulysses
    Replies:
    0
    Views:
    865
    ulysses
    Sep 16, 2003
  2. ulysses
    Replies:
    4
    Views:
    820
    Werner Schiendl
    Oct 22, 2003
  3. Hubert Hung-Hsien Chang
    Replies:
    2
    Views:
    540
    Michael Foord
    Sep 17, 2004
  4. Michael McGarry

    PyQt not working well on Mac OS X

    Michael McGarry, Dec 14, 2005, in forum: Python
    Replies:
    2
    Views:
    352
    Dan Sommers
    Dec 14, 2005
  5. sgperone
    Replies:
    1
    Views:
    1,167
    sgperone
    Jun 28, 2009
Loading...

Share This Page