Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Jakimow
EO Time Series Viewer
Commits
fbbe4ef9
Commit
fbbe4ef9
authored
Mar 17, 2012
by
Luke Campagnola
Browse files
SignalProxy now uses thread-safe timer.
parent
fcf2c53c
Changes
2
Hide whitespace changes
Inline
Side-by-side
SignalProxy.py
View file @
fbbe4ef9
# -*- coding: utf-8 -*-
from
Qt
import
QtCore
from
ptime
import
time
import
ThreadsafeTimer
__all__
=
[
'SignalProxy'
]
...
...
@@ -27,7 +28,7 @@ class SignalProxy(QtCore.QObject):
self
.
signal
=
signal
self
.
delay
=
delay
self
.
args
=
None
self
.
timer
=
QtCore
.
Q
Timer
()
self
.
timer
=
ThreadsafeTimer
.
Threadsafe
Timer
()
self
.
timer
.
timeout
.
connect
(
self
.
flush
)
self
.
block
=
False
self
.
slot
=
slot
...
...
ThreadsafeTimer.py
0 → 100644
View file @
fbbe4ef9
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment