Added very simple, enterable object for setting busy cursor during long operations
This commit is contained in:
parent
f9310d64c7
commit
a7d2118a99
24
widgets/BusyCursor.py
Normal file
24
widgets/BusyCursor.py
Normal file
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user