Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EO Time Series Viewer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Jakimow
EO Time Series Viewer
Commits
ef8c47e8
Commit
ef8c47e8
authored
11 years ago
by
Luke Campagnola
Browse files
Options
Downloads
Patches
Plain Diff
Allow QtProcess without local QApplication
parent
3eeffd3b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyqtgraph/multiprocess/processes.py
+17
-5
17 additions, 5 deletions
pyqtgraph/multiprocess/processes.py
with
17 additions
and
5 deletions
pyqtgraph/multiprocess/processes.py
+
17
−
5
View file @
ef8c47e8
...
@@ -325,7 +325,8 @@ class QtProcess(Process):
...
@@ -325,7 +325,8 @@ class QtProcess(Process):
GUI.
GUI.
- A QTimer is also started on the parent process which polls for requests
- A QTimer is also started on the parent process which polls for requests
from the child process. This allows Qt signals emitted within the child
from the child process. This allows Qt signals emitted within the child
process to invoke slots on the parent process and vice-versa.
process to invoke slots on the parent process and vice-versa. This can
be disabled using processRequests=False in the constructor.
Example::
Example::
...
@@ -342,18 +343,29 @@ class QtProcess(Process):
...
@@ -342,18 +343,29 @@ class QtProcess(Process):
def
__init__
(
self
,
**
kwds
):
def
__init__
(
self
,
**
kwds
):
if
'
target
'
not
in
kwds
:
if
'
target
'
not
in
kwds
:
kwds
[
'
target
'
]
=
startQtEventLoop
kwds
[
'
target
'
]
=
startQtEventLoop
self
.
_processRequests
=
kwds
.
pop
(
'
processRequests
'
,
True
)
Process
.
__init__
(
self
,
**
kwds
)
Process
.
__init__
(
self
,
**
kwds
)
self
.
startEventTimer
()
self
.
startEventTimer
()
def
startEventTimer
(
self
):
def
startEventTimer
(
self
):
from
pyqtgraph.Qt
import
QtGui
,
QtCore
## avoid module-level import to keep bootstrap snappy.
from
pyqtgraph.Qt
import
QtGui
,
QtCore
## avoid module-level import to keep bootstrap snappy.
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
=
QtCore
.
QTimer
()
app
=
QtGui
.
QApplication
.
instance
()
if
self
.
_processRequests
:
if
app
is
None
:
app
=
QtGui
.
QApplication
.
instance
()
raise
Exception
(
"
Must create QApplication before starting QtProcess
"
)
if
app
is
None
:
raise
Exception
(
"
Must create QApplication before starting QtProcess, or use QtProcess(processRequests=False)
"
)
self
.
startRequestProcessing
()
def
startRequestProcessing
(
self
,
interval
=
0.01
):
"""
Start listening for requests coming from the child process.
This allows signals to be connected from the child process to the parent.
"""
self
.
timer
.
timeout
.
connect
(
self
.
processRequests
)
self
.
timer
.
timeout
.
connect
(
self
.
processRequests
)
self
.
timer
.
start
(
1
0
)
self
.
timer
.
start
(
interval
*
100
0
)
def
stopRequestProcessing
(
self
):
self
.
timer
.
stop
()
def
processRequests
(
self
):
def
processRequests
(
self
):
try
:
try
:
Process
.
processRequests
(
self
)
Process
.
processRequests
(
self
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment