diff --git a/ThreadsafeTimer.py b/ThreadsafeTimer.py index d8c4bcee..f2de9791 100644 --- a/ThreadsafeTimer.py +++ b/ThreadsafeTimer.py @@ -1,41 +1,41 @@ -from pyqtgraph.Qt import QtCore, QtGui - -class ThreadsafeTimer(QtCore.QObject): - """ - Thread-safe replacement for QTimer. - """ - - timeout = QtCore.Signal() - sigTimerStopRequested = QtCore.Signal() - sigTimerStartRequested = QtCore.Signal(object) - - def __init__(self): - QtCore.QObject.__init__(self) - self.timer = QtCore.QTimer() - self.timer.timeout.connect(self.timerFinished) - self.timer.moveToThread(QtCore.QCoreApplication.instance().thread()) - self.moveToThread(QtCore.QCoreApplication.instance().thread()) - self.sigTimerStopRequested.connect(self.stop, QtCore.Qt.QueuedConnection) - self.sigTimerStartRequested.connect(self.start, QtCore.Qt.QueuedConnection) - - - def start(self, timeout): - isGuiThread = QtCore.QThread.currentThread() == QtCore.QCoreApplication.instance().thread() - if isGuiThread: - #print "start timer", self, "from gui thread" - self.timer.start(timeout) - else: - #print "start timer", self, "from remote thread" - self.sigTimerStartRequested.emit(timeout) - - def stop(self): - isGuiThread = QtCore.QThread.currentThread() == QtCore.QCoreApplication.instance().thread() - if isGuiThread: - #print "stop timer", self, "from gui thread" - self.timer.stop() - else: - #print "stop timer", self, "from remote thread" - self.sigTimerStopRequested.emit() - - def timerFinished(self): +from pyqtgraph.Qt import QtCore, QtGui + +class ThreadsafeTimer(QtCore.QObject): + """ + Thread-safe replacement for QTimer. + """ + + timeout = QtCore.Signal() + sigTimerStopRequested = QtCore.Signal() + sigTimerStartRequested = QtCore.Signal(object) + + def __init__(self): + QtCore.QObject.__init__(self) + self.timer = QtCore.QTimer() + self.timer.timeout.connect(self.timerFinished) + self.timer.moveToThread(QtCore.QCoreApplication.instance().thread()) + self.moveToThread(QtCore.QCoreApplication.instance().thread()) + self.sigTimerStopRequested.connect(self.stop, QtCore.Qt.QueuedConnection) + self.sigTimerStartRequested.connect(self.start, QtCore.Qt.QueuedConnection) + + + def start(self, timeout): + isGuiThread = QtCore.QThread.currentThread() == QtCore.QCoreApplication.instance().thread() + if isGuiThread: + #print "start timer", self, "from gui thread" + self.timer.start(timeout) + else: + #print "start timer", self, "from remote thread" + self.sigTimerStartRequested.emit(timeout) + + def stop(self): + isGuiThread = QtCore.QThread.currentThread() == QtCore.QCoreApplication.instance().thread() + if isGuiThread: + #print "stop timer", self, "from gui thread" + self.timer.stop() + else: + #print "stop timer", self, "from remote thread" + self.sigTimerStopRequested.emit() + + def timerFinished(self): self.timeout.emit() \ No newline at end of file diff --git a/examples/Arrow.py b/examples/Arrow.py old mode 100755 new mode 100644 diff --git a/examples/GraphicsLayout.py b/examples/GraphicsLayout.py old mode 100755 new mode 100644 diff --git a/examples/ScatterPlot.py b/examples/ScatterPlot.py old mode 100755 new mode 100644 diff --git a/examples/ViewBox.py b/examples/ViewBox.py old mode 100755 new mode 100644 diff --git a/graphicsItems/PlotDataItem.py b/graphicsItems/PlotDataItem.py index 44869f17..572c2c65 100644 --- a/graphicsItems/PlotDataItem.py +++ b/graphicsItems/PlotDataItem.py @@ -247,7 +247,6 @@ class PlotDataItem(GraphicsObject): if len(args) == 1: data = args[0] dt = dataType(data) - print "plot:", dt, type(data) if dt == 'empty': pass elif dt == 'listOfValues': diff --git a/graphicsItems/ROI.py b/graphicsItems/ROI.py old mode 100755 new mode 100644