Python3 compatibility updates
This commit is contained in:
parent
b1dbec848c
commit
f178919bee
@ -76,7 +76,7 @@ class SRTTransform(QtGui.QTransform):
|
||||
m = pg.SRTTransform3D(m)
|
||||
angle, axis = m.getRotation()
|
||||
if angle != 0 and (axis[0] != 0 or axis[1] != 0 or axis[2] != 1):
|
||||
print angle, axis
|
||||
print("angle: %s axis: %s" % (str(angle), str(axis)))
|
||||
raise Exception("Can only convert 4x4 matrix to 3x3 if rotation is around Z-axis.")
|
||||
self._state = {
|
||||
'pos': Point(m.getTranslation()),
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from Qt import QtCore, QtGui
|
||||
from Vector import Vector
|
||||
from SRTTransform import SRTTransform
|
||||
from .Qt import QtCore, QtGui
|
||||
from .Vector import Vector
|
||||
from .SRTTransform import SRTTransform
|
||||
import pyqtgraph as pg
|
||||
import numpy as np
|
||||
import scipy.linalg
|
||||
@ -136,15 +136,15 @@ class SRTTransform3D(QtGui.QMatrix4x4):
|
||||
try:
|
||||
evals, evecs = scipy.linalg.eig(r)
|
||||
except:
|
||||
print "Rotation matrix:", r
|
||||
print "Scale:", scale
|
||||
print "Original matrix:", m
|
||||
print("Rotation matrix: %s" % str(r))
|
||||
print("Scale: %s" % str(scale))
|
||||
print("Original matrix: %s" % str(m))
|
||||
raise
|
||||
eigIndex = np.argwhere(np.abs(evals-1) < 1e-7)
|
||||
if len(eigIndex) < 1:
|
||||
print "eigenvalues:", evals
|
||||
print "eigenvectors:", evecs
|
||||
print "index:", eigIndex, evals-1
|
||||
print("eigenvalues: %s" % str(evals))
|
||||
print("eigenvectors: %s" % str(evecs))
|
||||
print("index: %s, %s" % (str(eigIndex), str(evals-1)))
|
||||
raise Exception("Could not determine rotation axis.")
|
||||
axis = evecs[eigIndex[0,0]].real
|
||||
axis /= ((axis**2).sum())**0.5
|
||||
@ -259,23 +259,23 @@ if __name__ == '__main__':
|
||||
tr3 = QtGui.QTransform()
|
||||
tr3.translate(20, 0)
|
||||
tr3.rotate(45)
|
||||
print "QTransform -> Transform:", SRTTransform(tr3)
|
||||
print("QTransform -> Transform: %s" % str(SRTTransform(tr3)))
|
||||
|
||||
print "tr1:", tr1
|
||||
print("tr1: %s" % str(tr1))
|
||||
|
||||
tr2.translate(20, 0)
|
||||
tr2.rotate(45)
|
||||
print "tr2:", tr2
|
||||
print("tr2: %s" % str(tr2))
|
||||
|
||||
dt = tr2/tr1
|
||||
print "tr2 / tr1 = ", dt
|
||||
print("tr2 / tr1 = %s" % str(dt))
|
||||
|
||||
print "tr2 * tr1 = ", tr2*tr1
|
||||
print("tr2 * tr1 = %s" % str(tr2*tr1))
|
||||
|
||||
tr4 = SRTTransform()
|
||||
tr4.scale(-1, 1)
|
||||
tr4.rotate(30)
|
||||
print "tr1 * tr4 = ", tr1*tr4
|
||||
print("tr1 * tr4 = %s" % str(tr1*tr4))
|
||||
|
||||
w1 = widgets.TestROI((19,19), (22, 22), invertible=True)
|
||||
#w2 = widgets.TestROI((0,0), (150, 150))
|
||||
|
@ -5,7 +5,7 @@ Copyright 2010 Luke Campagnola
|
||||
Distributed under MIT/X11 license. See license.txt for more infomation.
|
||||
"""
|
||||
|
||||
from Qt import QtGui, QtCore
|
||||
from .Qt import QtGui, QtCore
|
||||
import numpy as np
|
||||
|
||||
class Vector(QtGui.QVector3D):
|
||||
|
@ -25,10 +25,10 @@ class CmdInput(QtGui.QLineEdit):
|
||||
self.execCmd()
|
||||
else:
|
||||
QtGui.QLineEdit.keyPressEvent(self, ev)
|
||||
self.history[0] = unicode(self.text())
|
||||
self.history[0] = asUnicode(self.text())
|
||||
|
||||
def execCmd(self):
|
||||
cmd = unicode(self.text())
|
||||
cmd = asUnicode(self.text())
|
||||
if len(self.history) == 1 or cmd != self.history[1]:
|
||||
self.history.insert(1, cmd)
|
||||
#self.lastCmd = cmd
|
||||
|
@ -2,7 +2,7 @@
|
||||
from pyqtgraph.Qt import QtCore, QtGui
|
||||
import sys, re, os, time, traceback, subprocess
|
||||
import pyqtgraph as pg
|
||||
import template
|
||||
from . import template
|
||||
import pyqtgraph.exceptionHandling as exceptionHandling
|
||||
import pickle
|
||||
|
||||
|
@ -1 +1 @@
|
||||
from Console import ConsoleWidget
|
||||
from .Console import ConsoleWidget
|
@ -101,4 +101,4 @@ class Ui_Form(object):
|
||||
self.runSelectedFrameCheck.setText(QtGui.QApplication.translate("Form", "Run commands in selected stack frame", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.exceptionInfoLabel.setText(QtGui.QApplication.translate("Form", "Exception Info", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
from CmdInput import CmdInput
|
||||
from .CmdInput import CmdInput
|
||||
|
@ -153,7 +153,7 @@
|
||||
<customwidget>
|
||||
<class>CmdInput</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>CmdInput</header>
|
||||
<header>.CmdInput</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
@ -51,16 +51,16 @@ class ExceptionHandler:
|
||||
def __call__(self, *args):
|
||||
## call original exception handler first (prints exception)
|
||||
global original_excepthook, callbacks, clear_tracebacks
|
||||
print "=====", time.strftime("%Y.%m.%d %H:%m:%S", time.localtime(time.time())), "====="
|
||||
print("===== %s =====" % str(time.strftime("%Y.%m.%d %H:%m:%S", time.localtime(time.time()))))
|
||||
ret = original_excepthook(*args)
|
||||
|
||||
for cb in callbacks:
|
||||
try:
|
||||
cb(*args)
|
||||
except:
|
||||
print " --------------------------------------------------------------"
|
||||
print " Error occurred during exception callback", cb
|
||||
print " --------------------------------------------------------------"
|
||||
print(" --------------------------------------------------------------")
|
||||
print(" Error occurred during exception callback %s" % str(cb))
|
||||
print(" --------------------------------------------------------------")
|
||||
traceback.print_exception(*sys.exc_info())
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ class ScatterPlotItem(GraphicsObject):
|
||||
prof = debug.Profiler('ScatterPlotItem.__init__', disabled=True)
|
||||
GraphicsObject.__init__(self)
|
||||
self.setFlag(self.ItemHasNoContents, True)
|
||||
self.data = np.empty(0, dtype=[('x', float), ('y', float), ('size', float), ('symbol', 'S1'), ('pen', object), ('brush', object), ('item', object), ('data', object)])
|
||||
self.data = np.empty(0, dtype=[('x', float), ('y', float), ('size', float), ('symbol', object), ('pen', object), ('brush', object), ('item', object), ('data', object)])
|
||||
self.bounds = [None, None] ## caches data bounds
|
||||
self._maxSpotWidth = 0 ## maximum size of the scale-variant portion of all spots
|
||||
self._maxSpotPxWidth = 0 ## maximum size of the scale-invariant portion of all spots
|
||||
@ -559,7 +559,7 @@ class SpotItem(GraphicsItem):
|
||||
If the spot has no explicit symbol set, then return the ScatterPlotItem's default symbol instead.
|
||||
"""
|
||||
symbol = self._data['symbol']
|
||||
if symbol == '':
|
||||
if symbol is None:
|
||||
symbol = self._plot.opts['symbol']
|
||||
try:
|
||||
n = int(symbol)
|
||||
|
@ -19,6 +19,6 @@ TODO:
|
||||
(RemoteGraphicsView class)
|
||||
"""
|
||||
|
||||
from processes import *
|
||||
from parallelizer import Parallelize, CanceledError
|
||||
from remoteproxy import proxy
|
||||
from .processes import *
|
||||
from .parallelizer import Parallelize, CanceledError
|
||||
from .remoteproxy import proxy
|
@ -6,7 +6,7 @@ md = os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.append(os.path.join(md, '..', '..'))
|
||||
|
||||
from pyqtgraph.Qt import QtCore, QtGui
|
||||
import collections, user
|
||||
import collections
|
||||
app = QtGui.QApplication([])
|
||||
import pyqtgraph.parametertree.parameterTypes as pTypes
|
||||
from pyqtgraph.parametertree import Parameter, ParameterTree, ParameterItem, registerParameterType
|
||||
|
Loading…
Reference in New Issue
Block a user