8000 Qt embedding example: processEvents, to make sure GUI is smooth · matplotlib/matplotlib@e632e9e · GitHub
[go: up one dir, main page]

Skip to content

Commit e632e9e

Browse files
committed
Qt embedding example: processEvents, to make sure GUI is smooth
See also pyqtgraph/pyqtgraph#3092
1 parent 0da7d89 commit e632e9e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

galleries/examples/user_interfaces/embedding_in_qt_sgskip.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def _update_canvas(self):
5656
# Shift the sinusoid as a function of time.
5757
self._line.set_data(t, np.sin(t + time.time()))
5858
self._line.figure.canvas.draw()
59+
# If the timer frequency is fast enough for the Qt platform (in case
60+
# the frequency is increased or if the desktop is overloaded), the GUI
61+
# might get stuck because the event loop won't manage to respond to
62+
# events such as window resize etc while the timer is running. This
63+
# forces the timer to process the GUI events and to provide a smooth
64+
# experience.
65+
qapp.processEvents()
5966

6067

6168
if __name__ == "__main__":

0 commit comments

Comments
 (0)
0