Fixed RemoteGraphicsView passing mouse events on python3 + pyside
This commit is contained in:
parent
08be09ee40
commit
1418358bfb
@ -33,3 +33,10 @@ for gs in ['raster', 'native', 'opengl']:
|
|||||||
QtGui.QApplication.setGraphicsSystem(gs)
|
QtGui.QApplication.setGraphicsSystem(gs)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
## Enable fault handling to give more helpful error messages on crash.
|
||||||
|
## Only available in python 3.3+
|
||||||
|
try:
|
||||||
|
import faulthandler
|
||||||
|
faulthandler.enable()
|
||||||
|
except ImportError:
|
||||||
|
pass
|
@ -1,7 +1,7 @@
|
|||||||
from .remoteproxy import RemoteEventHandler, ClosedError, NoResultError, LocalObjectProxy, ObjectProxy
|
from .remoteproxy import RemoteEventHandler, ClosedError, NoResultError, LocalObjectProxy, ObjectProxy
|
||||||
import subprocess, atexit, os, sys, time, random, socket, signal
|
import subprocess, atexit, os, sys, time, random, socket, signal
|
||||||
import multiprocessing.connection
|
import multiprocessing.connection
|
||||||
from pyqtgraph.Qt import USE_PYSIDE
|
import pyqtgraph as pg
|
||||||
try:
|
try:
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -98,7 +98,6 @@ class Process(RemoteEventHandler):
|
|||||||
targetStr = pickle.dumps(target) ## double-pickle target so that child has a chance to
|
targetStr = pickle.dumps(target) ## double-pickle target so that child has a chance to
|
||||||
## set its sys.path properly before unpickling the target
|
## set its sys.path properly before unpickling the target
|
||||||
pid = os.getpid() # we must send pid to child because windows does not have getppid
|
pid = os.getpid() # we must send pid to child because windows does not have getppid
|
||||||
pyside = USE_PYSIDE
|
|
||||||
|
|
||||||
## Send everything the remote process needs to start correctly
|
## Send everything the remote process needs to start correctly
|
||||||
data = dict(
|
data = dict(
|
||||||
@ -108,7 +107,7 @@ class Process(RemoteEventHandler):
|
|||||||
ppid=pid,
|
ppid=pid,
|
||||||
targetStr=targetStr,
|
targetStr=targetStr,
|
||||||
path=sysPath,
|
path=sysPath,
|
||||||
pyside=pyside,
|
pyside=pg.Qt.USE_PYSIDE,
|
||||||
debug=debug
|
debug=debug
|
||||||
)
|
)
|
||||||
pickle.dump(data, self.proc.stdin)
|
pickle.dump(data, self.proc.stdin)
|
||||||
|
@ -83,17 +83,17 @@ class RemoteGraphicsView(QtGui.QWidget):
|
|||||||
p.end()
|
p.end()
|
||||||
|
|
||||||
def mousePressEvent(self, ev):
|
def mousePressEvent(self, ev):
|
||||||
self._view.mousePressEvent(ev.type(), ev.pos(), ev.globalPos(), ev.button(), int(ev.buttons()), int(ev.modifiers()), _callSync='off')
|
self._view.mousePressEvent(int(ev.type()), ev.pos(), ev.globalPos(), int(ev.button()), int(ev.buttons()), int(ev.modifiers()), _callSync='off')
|
||||||
ev.accept()
|
ev.accept()
|
||||||
return QtGui.QWidget.mousePressEvent(self, ev)
|
return QtGui.QWidget.mousePressEvent(self, ev)
|
||||||
|
|
||||||
def mouseReleaseEvent(self, ev):
|
def mouseReleaseEvent(self, ev):
|
||||||
self._view.mouseReleaseEvent(ev.type(), ev.pos(), ev.globalPos(), ev.button(), int(ev.buttons()), int(ev.modifiers()), _callSync='off')
|
self._view.mouseReleaseEvent(int(ev.type()), ev.pos(), ev.globalPos(), int(ev.button()), int(ev.buttons()), int(ev.modifiers()), _callSync='off')
|
||||||
ev.accept()
|
ev.accept()
|
||||||
return QtGui.QWidget.mouseReleaseEvent(self, ev)
|
return QtGui.QWidget.mouseReleaseEvent(self, ev)
|
||||||
|
|
||||||
def mouseMoveEvent(self, ev):
|
def mouseMoveEvent(self, ev):
|
||||||
self._view.mouseMoveEvent(ev.type(), ev.pos(), ev.globalPos(), ev.button(), int(ev.buttons()), int(ev.modifiers()), _callSync='off')
|
self._view.mouseMoveEvent(int(ev.type()), ev.pos(), ev.globalPos(), int(ev.button()), int(ev.buttons()), int(ev.modifiers()), _callSync='off')
|
||||||
ev.accept()
|
ev.accept()
|
||||||
return QtGui.QWidget.mouseMoveEvent(self, ev)
|
return QtGui.QWidget.mouseMoveEvent(self, ev)
|
||||||
|
|
||||||
@ -103,16 +103,16 @@ class RemoteGraphicsView(QtGui.QWidget):
|
|||||||
return QtGui.QWidget.wheelEvent(self, ev)
|
return QtGui.QWidget.wheelEvent(self, ev)
|
||||||
|
|
||||||
def keyEvent(self, ev):
|
def keyEvent(self, ev):
|
||||||
if self._view.keyEvent(ev.type(), int(ev.modifiers()), text, autorep, count):
|
if self._view.keyEvent(int(ev.type()), int(ev.modifiers()), text, autorep, count):
|
||||||
ev.accept()
|
ev.accept()
|
||||||
return QtGui.QWidget.keyEvent(self, ev)
|
return QtGui.QWidget.keyEvent(self, ev)
|
||||||
|
|
||||||
def enterEvent(self, ev):
|
def enterEvent(self, ev):
|
||||||
self._view.enterEvent(ev.type(), _callSync='off')
|
self._view.enterEvent(int(ev.type()), _callSync='off')
|
||||||
return QtGui.QWidget.enterEvent(self, ev)
|
return QtGui.QWidget.enterEvent(self, ev)
|
||||||
|
|
||||||
def leaveEvent(self, ev):
|
def leaveEvent(self, ev):
|
||||||
self._view.leaveEvent(ev.type(), _callSync='off')
|
self._view.leaveEvent(int(ev.type()), _callSync='off')
|
||||||
return QtGui.QWidget.leaveEvent(self, ev)
|
return QtGui.QWidget.leaveEvent(self, ev)
|
||||||
|
|
||||||
def remoteProcess(self):
|
def remoteProcess(self):
|
||||||
@ -206,18 +206,21 @@ class Renderer(GraphicsView):
|
|||||||
|
|
||||||
def mousePressEvent(self, typ, pos, gpos, btn, btns, mods):
|
def mousePressEvent(self, typ, pos, gpos, btn, btns, mods):
|
||||||
typ = QtCore.QEvent.Type(typ)
|
typ = QtCore.QEvent.Type(typ)
|
||||||
|
btn = QtCore.Qt.MouseButton(btn)
|
||||||
btns = QtCore.Qt.MouseButtons(btns)
|
btns = QtCore.Qt.MouseButtons(btns)
|
||||||
mods = QtCore.Qt.KeyboardModifiers(mods)
|
mods = QtCore.Qt.KeyboardModifiers(mods)
|
||||||
return GraphicsView.mousePressEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods))
|
return GraphicsView.mousePressEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods))
|
||||||
|
|
||||||
def mouseMoveEvent(self, typ, pos, gpos, btn, btns, mods):
|
def mouseMoveEvent(self, typ, pos, gpos, btn, btns, mods):
|
||||||
typ = QtCore.QEvent.Type(typ)
|
typ = QtCore.QEvent.Type(typ)
|
||||||
|
btn = QtCore.Qt.MouseButton(btn)
|
||||||
btns = QtCore.Qt.MouseButtons(btns)
|
btns = QtCore.Qt.MouseButtons(btns)
|
||||||
mods = QtCore.Qt.KeyboardModifiers(mods)
|
mods = QtCore.Qt.KeyboardModifiers(mods)
|
||||||
return GraphicsView.mouseMoveEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods))
|
return GraphicsView.mouseMoveEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods))
|
||||||
|
|
||||||
def mouseReleaseEvent(self, typ, pos, gpos, btn, btns, mods):
|
def mouseReleaseEvent(self, typ, pos, gpos, btn, btns, mods):
|
||||||
typ = QtCore.QEvent.Type(typ)
|
typ = QtCore.QEvent.Type(typ)
|
||||||
|
btn = QtCore.Qt.MouseButton(btn)
|
||||||
btns = QtCore.Qt.MouseButtons(btns)
|
btns = QtCore.Qt.MouseButtons(btns)
|
||||||
mods = QtCore.Qt.KeyboardModifiers(mods)
|
mods = QtCore.Qt.KeyboardModifiers(mods)
|
||||||
return GraphicsView.mouseReleaseEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods))
|
return GraphicsView.mouseReleaseEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods))
|
||||||
|
Loading…
Reference in New Issue
Block a user