2013-12-22 07:18:37 +00:00
|
|
|
from ..Qt import QtGui, QtCore
|
2012-06-18 19:17:46 +00:00
|
|
|
|
|
|
|
__all__ = ['BusyCursor']
|
|
|
|
|
2012-11-29 03:47:52 +00:00
|
|
|
class BusyCursor(object):
|
2012-06-18 19:17:46 +00:00
|
|
|
"""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()
|
|
|
|
|