[PyQt] Discard events

Frédéric frederic.mantegazza at gbiloba.org
Mon Feb 9 11:26:54 GMT 2009


Is there a way to discard all pending events? In a menu callback, I run
the following code:

        self.setStatusbarMessage("Goto home position...")
        self._model.hardware.gotoPosition(0., 0., wait=False)
        while self._model.hardware.isAxisMoving():
           
QtGui.QApplication.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents)
        self.setStatusbarMessage("Home position reached", 10)

I periodically call the processEvents, because I want the current
position to be refreshed (from a thread). During the move, I don't want
any widgets to be active. This work fine, but all input events are
queued, and executed as soon as we leave the callback. If the user
clicks on different widgets, all actions will be executed :o(


--
   Frédéric



More information about the PyQt mailing list