remotegraphicsview fix for PyQt 4.10
This commit is contained in:
parent
daaf481830
commit
1a0b5921df
@ -1,20 +1,26 @@
|
||||
# -*- 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')
|
||||
|
@ -1,4 +1,6 @@
|
||||
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())
|
||||
|
Loading…
Reference in New Issue
Block a user