From 1418358bfb8722eef2385ed48c5b0fcffddf9324 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Sun, 17 Nov 2013 14:12:00 -0500 Subject: [PATCH] Fixed RemoteGraphicsView passing mouse events on python3 + pyside --- examples/initExample.py | 7 +++++++ pyqtgraph/multiprocess/processes.py | 5 ++--- pyqtgraph/widgets/RemoteGraphicsView.py | 15 +++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/initExample.py b/examples/initExample.py index d8022aba..b61b55cc 100644 --- a/examples/initExample.py +++ b/examples/initExample.py @@ -33,3 +33,10 @@ for gs in ['raster', 'native', 'opengl']: QtGui.QApplication.setGraphicsSystem(gs) 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 \ No newline at end of file diff --git a/pyqtgraph/multiprocess/processes.py b/pyqtgraph/multiprocess/processes.py index 16fd6bab..42eb1910 100644 --- a/pyqtgraph/multiprocess/processes.py +++ b/pyqtgraph/multiprocess/processes.py @@ -1,7 +1,7 @@ from .remoteproxy import RemoteEventHandler, ClosedError, NoResultError, LocalObjectProxy, ObjectProxy import subprocess, atexit, os, sys, time, random, socket, signal import multiprocessing.connection -from pyqtgraph.Qt import USE_PYSIDE +import pyqtgraph as pg try: import cPickle as pickle except ImportError: @@ -98,7 +98,6 @@ class Process(RemoteEventHandler): targetStr = pickle.dumps(target) ## double-pickle target so that child has a chance to ## set its sys.path properly before unpickling the target 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 data = dict( @@ -108,7 +107,7 @@ class Process(RemoteEventHandler): ppid=pid, targetStr=targetStr, path=sysPath, - pyside=pyside, + pyside=pg.Qt.USE_PYSIDE, debug=debug ) pickle.dump(data, self.proc.stdin) diff --git a/pyqtgraph/widgets/RemoteGraphicsView.py b/pyqtgraph/widgets/RemoteGraphicsView.py index ac29f426..7270d449 100644 --- a/pyqtgraph/widgets/RemoteGraphicsView.py +++ b/pyqtgraph/widgets/RemoteGraphicsView.py @@ -83,17 +83,17 @@ class RemoteGraphicsView(QtGui.QWidget): p.end() 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() return QtGui.QWidget.mousePressEvent(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() return QtGui.QWidget.mouseReleaseEvent(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() return QtGui.QWidget.mouseMoveEvent(self, ev) @@ -103,16 +103,16 @@ class RemoteGraphicsView(QtGui.QWidget): return QtGui.QWidget.wheelEvent(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() return QtGui.QWidget.keyEvent(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) 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) def remoteProcess(self): @@ -206,18 +206,21 @@ class Renderer(GraphicsView): def mousePressEvent(self, typ, pos, gpos, btn, btns, mods): typ = QtCore.QEvent.Type(typ) + btn = QtCore.Qt.MouseButton(btn) btns = QtCore.Qt.MouseButtons(btns) mods = QtCore.Qt.KeyboardModifiers(mods) return GraphicsView.mousePressEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods)) def mouseMoveEvent(self, typ, pos, gpos, btn, btns, mods): typ = QtCore.QEvent.Type(typ) + btn = QtCore.Qt.MouseButton(btn) btns = QtCore.Qt.MouseButtons(btns) mods = QtCore.Qt.KeyboardModifiers(mods) return GraphicsView.mouseMoveEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods)) def mouseReleaseEvent(self, typ, pos, gpos, btn, btns, mods): typ = QtCore.QEvent.Type(typ) + btn = QtCore.Qt.MouseButton(btn) btns = QtCore.Qt.MouseButtons(btns) mods = QtCore.Qt.KeyboardModifiers(mods) return GraphicsView.mouseReleaseEvent(self, QtGui.QMouseEvent(typ, pos, gpos, btn, btns, mods))