Ignore BusyCursor when called from thread
This commit is contained in:
parent
d4a4fd7fd5
commit
7daa5bdff1
@ -9,13 +9,19 @@ class BusyCursor(object):
|
||||
with pyqtgraph.BusyCursor():
|
||||
doLongOperation()
|
||||
|
||||
May be nested.
|
||||
May be nested. If called from a non-gui thread, then the cursor will not be affected.
|
||||
"""
|
||||
active = []
|
||||
|
||||
def __enter__(self):
|
||||
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
|
||||
BusyCursor.active.append(self)
|
||||
app = QtCore.QCoreApplication.instance()
|
||||
isGuiThread = (app is not None) and (QtCore.QThread.currentThread() == app.thread())
|
||||
if isGuiThread and QtGui.QApplication.instance() is not None:
|
||||
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
|
||||
BusyCursor.active.append(self)
|
||||
self._active = True
|
||||
else:
|
||||
self._active = False
|
||||
|
||||
def __exit__(self, *args):
|
||||
if self._active:
|
||||
|
Loading…
Reference in New Issue
Block a user