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
1a0b5921
Commit
1a0b5921
authored
Apr 07, 2013
by
Luke Campagnola
Browse files
remotegraphicsview fix for PyQt 4.10
parent
daaf4818
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/RemoteGraphicsView.py
View file @
1a0b5921
# -*- coding: utf-8 -*-
"""
Very simple example demonstrating RemoteGraphicsView
Very simple example demonstrating RemoteGraphicsView.
This allows graphics to be rendered in a child process and displayed in the
parent, which can improve CPU usage on multi-core processors.
"""
import
initExample
## Add path to library (just for examples; you do not need this)
from
pyqtgraph.Qt
import
QtGui
,
QtCore
import
pyqtgraph
as
pg
from
pyqtgraph.widgets.RemoteGraphicsView
import
RemoteGraphicsView
app
=
pg
.
mkQApp
()
v
=
RemoteGraphicsView
()
## Create the widget
v
=
RemoteGraphicsView
(
debug
=
False
)
v
.
show
()
v
.
setWindowTitle
(
'pyqtgraph example: RemoteGraphicsView'
)
## v.pg is a proxy to the remote process' pyqtgraph module. All attribute
## requests and function calls made with this object are forwarded to the
## remote process and executed there.
## remote process and executed there. See pyqtgraph.multiprocess.remoteproxy
## for more inormation.
plt
=
v
.
pg
.
PlotItem
()
v
.
setCentralItem
(
plt
)
plt
.
plot
([
1
,
4
,
2
,
3
,
6
,
2
,
3
,
4
,
2
,
3
],
pen
=
'g'
)
...
...
pyqtgraph/widgets/RemoteGraphicsView.py
View file @
1a0b5921
from
pyqtgraph.Qt
import
QtGui
,
QtCore
,
USE_PYSIDE
if
not
USE_PYSIDE
:
import
sip
import
pyqtgraph.multiprocess
as
mp
import
pyqtgraph
as
pg
from
.GraphicsView
import
GraphicsView
...
...
@@ -21,7 +23,7 @@ class RemoteGraphicsView(QtGui.QWidget):
self
.
_sizeHint
=
(
640
,
480
)
## no clue why this is needed, but it seems to be the default sizeHint for GraphicsView.
## without it, the widget will not compete for space against another GraphicsView.
QtGui
.
QWidget
.
__init__
(
self
)
self
.
_proc
=
mp
.
QtProcess
(
debug
=
False
)
self
.
_proc
=
mp
.
QtProcess
(
debug
=
kwds
.
pop
(
'debug'
,
False
)
)
self
.
pg
=
self
.
_proc
.
_import
(
'pyqtgraph'
)
self
.
pg
.
setConfigOptions
(
**
self
.
pg
.
CONFIG_OPTIONS
)
rpgRemote
=
self
.
_proc
.
_import
(
'pyqtgraph.widgets.RemoteGraphicsView'
)
...
...
@@ -174,7 +176,6 @@ class Renderer(GraphicsView):
self
.
shm
=
mmap
.
mmap
(
-
1
,
size
,
self
.
shmtag
)
else
:
self
.
shm
.
resize
(
size
)
address
=
ctypes
.
addressof
(
ctypes
.
c_char
.
from_buffer
(
self
.
shm
,
0
))
## render the scene directly to shared memory
if
USE_PYSIDE
:
...
...
@@ -182,7 +183,8 @@ class Renderer(GraphicsView):
#ch = ctypes.c_char_p(address)
self
.
img
=
QtGui
.
QImage
(
ch
,
self
.
width
(),
self
.
height
(),
QtGui
.
QImage
.
Format_ARGB32
)
else
:
self
.
img
=
QtGui
.
QImage
(
address
,
self
.
width
(),
self
.
height
(),
QtGui
.
QImage
.
Format_ARGB32
)
address
=
ctypes
.
addressof
(
ctypes
.
c_char
.
from_buffer
(
self
.
shm
,
0
))
self
.
img
=
QtGui
.
QImage
(
sip
.
voidptr
(
address
),
self
.
width
(),
self
.
height
(),
QtGui
.
QImage
.
Format_ARGB32
)
self
.
img
.
fill
(
0xffffffff
)
p
=
QtGui
.
QPainter
(
self
.
img
)
self
.
render
(
p
,
self
.
viewRect
(),
self
.
rect
())
...
...
Write
Preview
Markdown
is supported
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