[PyQt] Discard events

Albert Cervera i Areny albert at nan-tic.com
Mon Feb 9 15:01:14 GMT 2009


A Dilluns 09 Febrer 2009, Frédéric va escriure:
> 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(

Usage of processEvents() usually means you're doing something wrong. If you 
don't want any widget to obey user input you should possibly disable all of 
them (by putting them in a list of widgets to be enabled/disabled, for 
example).

>
>
> --
>    Frédéric
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt



-- 
Albert Cervera i Areny
http://www.NaN-tic.com


More information about the PyQt mailing list