Fixes for Python3, PySide
This commit is contained in:
parent
051a91c688
commit
362a0dcd04
|
@ -1260,7 +1260,7 @@ def isocurve(data, level, connected=False, extendToEdge=False, path=False):
|
|||
points[b[1]].append([b,a])
|
||||
|
||||
## rearrange into chains
|
||||
for k in points.keys():
|
||||
for k in list(points.keys()):
|
||||
try:
|
||||
chains = points[k]
|
||||
except KeyError: ## already used this point elsewhere
|
||||
|
|
|
@ -4,7 +4,7 @@ from pyqtgraph.Point import Point
|
|||
import pyqtgraph.functions as fn
|
||||
import weakref
|
||||
from pyqtgraph.pgcollections import OrderedDict
|
||||
import operator
|
||||
import operator, sys
|
||||
|
||||
class FiniteCache(OrderedDict):
|
||||
"""Caches a finite number of objects, removing
|
||||
|
@ -17,7 +17,7 @@ class FiniteCache(OrderedDict):
|
|||
self.pop(item, None) # make sure item is added to end
|
||||
OrderedDict.__setitem__(self, item, val)
|
||||
while len(self) > self._length:
|
||||
del self[self.keys()[0]]
|
||||
del self[list(self.keys())[0]]
|
||||
|
||||
def __getitem__(self, item):
|
||||
val = dict.__getitem__(self, item)
|
||||
|
@ -197,14 +197,14 @@ class GraphicsItem(object):
|
|||
|
||||
## check local cache
|
||||
if direction is None and dt == self._pixelVectorCache[0]:
|
||||
return map(Point, self._pixelVectorCache[1]) ## return a *copy*
|
||||
return tuple(map(Point, self._pixelVectorCache[1])) ## return a *copy*
|
||||
|
||||
## check global cache
|
||||
key = (dt.m11(), dt.m21(), dt.m31(), dt.m12(), dt.m22(), dt.m32(), dt.m31(), dt.m32())
|
||||
pv = self._pixelVectorGlobalCache.get(key, None)
|
||||
if pv is not None:
|
||||
self._pixelVectorCache = [dt, pv]
|
||||
return map(Point,pv) ## return a *copy*
|
||||
return tuple(map(Point,pv)) ## return a *copy*
|
||||
|
||||
|
||||
if direction is None:
|
||||
|
|
|
@ -1808,7 +1808,7 @@ class LineSegmentROI(ROI):
|
|||
for i in range(len(imgPts)-1):
|
||||
d = Point(imgPts[i+1] - imgPts[i])
|
||||
o = Point(imgPts[i])
|
||||
r = fn.affineSlice(data, shape=(int(d.length()),), vectors=[d.norm()], origin=o, axes=axes, order=1)
|
||||
r = fn.affineSlice(data, shape=(int(d.length()),), vectors=[Point(d.norm())], origin=o, axes=axes, order=1)
|
||||
rgns.append(r)
|
||||
|
||||
return np.concatenate(rgns, axis=axes[0])
|
||||
|
|
|
@ -41,7 +41,7 @@ def drawSymbol(painter, symbol, size, pen, brush):
|
|||
if isinstance(symbol, basestring):
|
||||
symbol = Symbols[symbol]
|
||||
if np.isscalar(symbol):
|
||||
symbol = Symbols.values()[symbol % len(Symbols)]
|
||||
symbol = list(Symbols.values())[symbol % len(Symbols)]
|
||||
painter.drawPath(symbol)
|
||||
|
||||
|
||||
|
|
|
@ -1198,7 +1198,7 @@ class ViewBox(GraphicsWidget):
|
|||
if ViewBox is None: ## can happen as python is shutting down
|
||||
return
|
||||
## Called with ID and name of view (the view itself is no longer available)
|
||||
for v in ViewBox.AllViews.keys():
|
||||
for v in list(ViewBox.AllViews.keys()):
|
||||
if id(v) == vid:
|
||||
ViewBox.AllViews.pop(v)
|
||||
break
|
||||
|
|
|
@ -4,13 +4,19 @@ import sys, pickle, os
|
|||
if __name__ == '__main__':
|
||||
if hasattr(os, 'setpgrp'):
|
||||
os.setpgrp() ## prevents signals (notably keyboard interrupt) being forwarded from parent to this process
|
||||
name, port, authkey, ppid, targetStr, path = pickle.load(sys.stdin)
|
||||
if sys.version[0] == '3':
|
||||
name, port, authkey, ppid, targetStr, path, pyside = pickle.load(sys.stdin.buffer)
|
||||
else:
|
||||
name, port, authkey, ppid, targetStr, path, pyside = pickle.load(sys.stdin)
|
||||
#print "key:", ' '.join([str(ord(x)) for x in authkey])
|
||||
if path is not None:
|
||||
## rewrite sys.path without assigning a new object--no idea who already has a reference to the existing list.
|
||||
while len(sys.path) > 0:
|
||||
sys.path.pop()
|
||||
sys.path.extend(path)
|
||||
|
||||
if pyside:
|
||||
import PySide
|
||||
#import pyqtgraph
|
||||
#import pyqtgraph.multiprocess.processes
|
||||
target = pickle.loads(targetStr) ## unpickling the target should import everything we need
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os, sys, time, multiprocessing, re
|
||||
from processes import ForkedProcess
|
||||
from remoteproxy import ClosedError
|
||||
from .processes import ForkedProcess
|
||||
from .remoteproxy import ClosedError
|
||||
|
||||
class CanceledError(Exception):
|
||||
"""Raised when the progress dialog is canceled during a processing operation."""
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
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 cPickle as pickle
|
||||
import multiprocessing.connection
|
||||
from pyqtgraph.Qt import USE_PYSIDE
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
|
||||
__all__ = ['Process', 'QtProcess', 'ForkedProcess', 'ClosedError', 'NoResultError']
|
||||
|
||||
|
@ -75,7 +79,10 @@ 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 sent pid to child because windows does not have getppid
|
||||
pickle.dump((name+'_child', port, authkey, pid, targetStr, sysPath), self.proc.stdin)
|
||||
pyside = USE_PYSIDE
|
||||
|
||||
## Send everything the remote process needs to start correctly
|
||||
pickle.dump((name+'_child', port, authkey, pid, targetStr, sysPath, pyside), self.proc.stdin)
|
||||
self.proc.stdin.close()
|
||||
|
||||
## open connection for remote process
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import os, __builtin__, time, sys, traceback, weakref
|
||||
import cPickle as pickle
|
||||
import os, time, sys, traceback, weakref
|
||||
import numpy as np
|
||||
try:
|
||||
import __builtin__ as builtins
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import builtins
|
||||
import pickle
|
||||
|
||||
class ClosedError(Exception):
|
||||
"""Raised when an event handler receives a request to close the connection
|
||||
|
@ -181,7 +186,7 @@ class RemoteEventHandler(object):
|
|||
elif cmd == 'import':
|
||||
name = opts['module']
|
||||
fromlist = opts.get('fromlist', [])
|
||||
mod = __builtin__.__import__(name, fromlist=fromlist)
|
||||
mod = builtins.__import__(name, fromlist=fromlist)
|
||||
|
||||
if len(fromlist) == 0:
|
||||
parts = name.lstrip('.').split('.')
|
||||
|
|
|
@ -27,7 +27,7 @@ class RemoteGraphicsView(QtGui.QWidget):
|
|||
rpgRemote = self._proc._import('pyqtgraph.widgets.RemoteGraphicsView')
|
||||
self._view = rpgRemote.Renderer(*args, **kwds)
|
||||
self._view._setProxyOptions(deferGetattr=True)
|
||||
self.setFocusPolicy(self._view.focusPolicy())
|
||||
self.setFocusPolicy(QtCore.Qt.FocusPolicy(self._view.focusPolicy()))
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||
self.setMouseTracking(True)
|
||||
self.shm = None
|
||||
|
|
Loading…
Reference in New Issue
Block a user