Commit 1a0b5921 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

remotegraphicsview fix for PyQt 4.10

parent daaf4818
# -*- 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.setWindowTitle('pyqtgraph example: RemoteGraphicsView')
## 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 =
plt.plot([1,4,2,3,6,2,3,4,2,3], pen='g')
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.
self._proc = mp.QtProcess(debug=False)
self._proc = mp.QtProcess(debug=kwds.pop('debug', False)) = self._proc._import('pyqtgraph')**
rpgRemote = self._proc._import('pyqtgraph.widgets.RemoteGraphicsView')
......@@ -174,7 +176,6 @@ class Renderer(GraphicsView):
self.shm = mmap.mmap(-1, size, self.shmtag)
address = ctypes.addressof(ctypes.c_char.from_buffer(self.shm, 0))
## render the scene directly to shared memory
......@@ -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)
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)
p = QtGui.QPainter(self.img)
self.render(p, self.viewRect(), self.rect())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment