From a7d2118a99a424f4cfdd5a0f15cc78b8e44209d7 Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Mon, 18 Jun 2012 15:17:46 -0400 Subject: [PATCH] Added very simple, enterable object for setting busy cursor during long operations --- widgets/BusyCursor.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 widgets/BusyCursor.py diff --git a/widgets/BusyCursor.py b/widgets/BusyCursor.py new file mode 100644 index 00000000..4212d6a6 --- /dev/null +++ b/widgets/BusyCursor.py @@ -0,0 +1,24 @@ +from pyqtgraph.Qt import QtGui, QtCore + +__all__ = ['BusyCursor'] + +class BusyCursor: + """Class for displaying a busy mouse cursor during long operations. + Usage:: + + with pyqtgraph.BusyCursor(): + doLongOperation() + + May be nested. + """ + active = [] + + def __enter__(self): + QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) + BusyCursor.active.append(self) + + def __exit__(self, *args): + BusyCursor.active.pop(-1) + if len(BusyCursor.active) == 0: + QtGui.QApplication.restoreOverrideCursor() + \ No newline at end of file