Use Qt6 Enum Namespace
This namespace appears to be valid in PySide2/PyQt5 5.12+ so we may as well migrate to the newer namespace ourselves.
This commit is contained in:
parent
29bdf9949e
commit
d455da9aec
@ -101,7 +101,7 @@ class MainWindow(pg.GraphicsLayoutWidget):
|
||||
{'crv': curve2, 'buf': np.zeros( length ), 'ptr':0, 'ds': DataSource( signal_period=0.65 ) },
|
||||
{'crv': curve3, 'buf': np.zeros( length ), 'ptr':0, 'ds': DataSource( signal_period=0.52 ) },
|
||||
)
|
||||
self.timer = QtCore.QTimer(timerType=QtCore.Qt.PreciseTimer)
|
||||
self.timer = QtCore.QTimer(timerType=QtCore.Qt.TimerType.PreciseTimer)
|
||||
self.timer.timeout.connect(self.update)
|
||||
timestamp = time.perf_counter()
|
||||
for dic in self.traces:
|
||||
|
@ -51,7 +51,7 @@ class Graph(pg.GraphItem):
|
||||
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if ev.button() != QtCore.Qt.LeftButton:
|
||||
if ev.button() != QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.ignore()
|
||||
return
|
||||
|
||||
|
@ -41,7 +41,7 @@ def format(color, style=''):
|
||||
_format = QTextCharFormat()
|
||||
_format.setForeground(_color)
|
||||
if 'bold' in style:
|
||||
_format.setFontWeight(QFont.Bold)
|
||||
_format.setFontWeight(QFont.Weight.Bold)
|
||||
if 'italic' in style:
|
||||
_format.setFontItalic(True)
|
||||
|
||||
@ -275,7 +275,7 @@ class ExampleLoader(QtGui.QMainWindow):
|
||||
self.hl = PythonHighlighter(self.ui.codeView.document())
|
||||
app = QtGui.QApplication.instance()
|
||||
app.paletteChanged.connect(self.updateTheme)
|
||||
self.codeLayout.addItem(QtGui.QSpacerItem(100,100,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding), 0, 0)
|
||||
self.codeLayout.addItem(QtGui.QSpacerItem(100,100,QtGui.QSizePolicy.Policy.Expanding,QtGui.QSizePolicy.Policy.Expanding), 0, 0)
|
||||
self.codeLayout.addWidget(self.codeBtn, 1, 1)
|
||||
self.codeBtn.hide()
|
||||
|
||||
@ -301,8 +301,8 @@ class ExampleLoader(QtGui.QMainWindow):
|
||||
# first, a dark background
|
||||
c = QtGui.QColor('#171717')
|
||||
p = self.ui.codeView.palette()
|
||||
p.setColor(QtGui.QPalette.Active, QtGui.QPalette.Base, c)
|
||||
p.setColor(QtGui.QPalette.Inactive, QtGui.QPalette.Base, c)
|
||||
p.setColor(QtGui.QPalette.ColorGroup.Active, QtGui.QPalette.ColorRole.Base, c)
|
||||
p.setColor(QtGui.QPalette.ColorGroup.Inactive, QtGui.QPalette.ColorRole.Base, c)
|
||||
self.ui.codeView.setPalette(p)
|
||||
# then, a light font
|
||||
f = QtGui.QTextCharFormat()
|
||||
|
@ -12,6 +12,7 @@ from pyqtgraph.Qt import QtGui, QtCore
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.ptime import time
|
||||
# pg.setConfigOptions(useOpenGL=True)
|
||||
app = pg.mkQApp("MultiPlot Speed Test")
|
||||
|
||||
plot = pg.plot()
|
||||
@ -22,7 +23,7 @@ nPlots = 100
|
||||
nSamples = 500
|
||||
curves = []
|
||||
for idx in range(nPlots):
|
||||
curve = pg.PlotCurveItem(pen=(idx,nPlots*1.3))
|
||||
curve = pg.PlotCurveItem(pen=({'color': (idx, nPlots*1.3), 'width': 1}), skipFiniteCheck=True)
|
||||
plot.addItem(curve)
|
||||
curve.setPos(0,idx*6)
|
||||
curves.append(curve)
|
||||
@ -45,7 +46,7 @@ def update():
|
||||
count += 1
|
||||
|
||||
for i in range(nPlots):
|
||||
curves[i].setData(data[(ptr+i)%data.shape[0]], skipFiniteCheck=True)
|
||||
curves[i].setData(data[(ptr+i)%data.shape[0]])
|
||||
|
||||
ptr += nPlots
|
||||
now = time()
|
||||
|
@ -78,7 +78,7 @@ class Ui_MainWindow(object):
|
||||
self.gridLayout_4.setObjectName(u"gridLayout_4")
|
||||
self.rawImg = RawImageWidget(self.page_2)
|
||||
self.rawImg.setObjectName(u"rawImg")
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.rawImg.sizePolicy().hasHeightForWidth())
|
||||
@ -126,7 +126,7 @@ class Ui_MainWindow(object):
|
||||
|
||||
self.label_3 = QLabel(self.centralwidget)
|
||||
self.label_3.setObjectName(u"label_3")
|
||||
self.label_3.setAlignment(Qt.AlignCenter)
|
||||
self.label_3.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.label_3)
|
||||
|
||||
@ -148,7 +148,7 @@ class Ui_MainWindow(object):
|
||||
|
||||
self.label_2 = QLabel(self.centralwidget)
|
||||
self.label_2.setObjectName(u"label_2")
|
||||
self.label_2.setAlignment(Qt.AlignCenter)
|
||||
self.label_2.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.horizontalLayout.addWidget(self.label_2)
|
||||
|
||||
@ -170,7 +170,7 @@ class Ui_MainWindow(object):
|
||||
|
||||
self.label_4 = QLabel(self.centralwidget)
|
||||
self.label_4.setObjectName(u"label_4")
|
||||
self.label_4.setAlignment(Qt.AlignCenter)
|
||||
self.label_4.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.horizontalLayout_3.addWidget(self.label_4)
|
||||
|
||||
@ -200,7 +200,7 @@ class Ui_MainWindow(object):
|
||||
|
||||
self.gridLayout_2.addWidget(self.gradient, 7, 2, 1, 2)
|
||||
|
||||
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
|
||||
|
||||
self.gridLayout_2.addItem(self.horizontalSpacer, 3, 3, 1, 1)
|
||||
|
||||
@ -209,7 +209,7 @@ class Ui_MainWindow(object):
|
||||
font = QFont()
|
||||
font.setPointSize(12)
|
||||
self.fpsLabel.setFont(font)
|
||||
self.fpsLabel.setAlignment(Qt.AlignCenter)
|
||||
self.fpsLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.gridLayout_2.addWidget(self.fpsLabel, 0, 0, 1, 4)
|
||||
|
||||
@ -227,14 +227,14 @@ class Ui_MainWindow(object):
|
||||
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
|
||||
self.framesSpin = QSpinBox(self.centralwidget)
|
||||
self.framesSpin.setObjectName(u"framesSpin")
|
||||
self.framesSpin.setButtonSymbols(QAbstractSpinBox.NoButtons)
|
||||
self.framesSpin.setButtonSymbols(QAbstractSpinBox.ButtonSymbols.NoButtons)
|
||||
self.framesSpin.setValue(10)
|
||||
|
||||
self.horizontalLayout_4.addWidget(self.framesSpin)
|
||||
|
||||
self.widthSpin = QSpinBox(self.centralwidget)
|
||||
self.widthSpin.setObjectName(u"widthSpin")
|
||||
self.widthSpin.setButtonSymbols(QAbstractSpinBox.PlusMinus)
|
||||
self.widthSpin.setButtonSymbols(QAbstractSpinBox.ButtonSymbols.PlusMinus)
|
||||
self.widthSpin.setMaximum(10000)
|
||||
self.widthSpin.setValue(512)
|
||||
|
||||
@ -242,7 +242,7 @@ class Ui_MainWindow(object):
|
||||
|
||||
self.heightSpin = QSpinBox(self.centralwidget)
|
||||
self.heightSpin.setObjectName(u"heightSpin")
|
||||
self.heightSpin.setButtonSymbols(QAbstractSpinBox.NoButtons)
|
||||
self.heightSpin.setButtonSymbols(QAbstractSpinBox.ButtonSymbols.NoButtons)
|
||||
self.heightSpin.setMaximum(10000)
|
||||
self.heightSpin.setValue(512)
|
||||
|
||||
|
@ -48,7 +48,7 @@ class movableRect(QtGui.QGraphicsRectItem):
|
||||
self.setPen(self.savedPen)
|
||||
ev.ignore()
|
||||
def mousePressEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.accept()
|
||||
self.pressDelta = self.mapToParent(ev.pos()) - self.pos()
|
||||
else:
|
||||
|
@ -17,10 +17,10 @@ win.resize(1000,800)
|
||||
|
||||
lw = pg.GraphicsLayoutWidget()
|
||||
lw.setFixedWidth(1000)
|
||||
lw.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||
lw.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)
|
||||
|
||||
scr = QtGui.QScrollArea()
|
||||
scr.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
|
||||
scr.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
|
||||
scr.setWidget(lw)
|
||||
win.setCentralWidget(scr)
|
||||
win.setWindowTitle('pyqtgraph example: Color maps')
|
||||
|
@ -66,10 +66,10 @@ win.resize(1000,800)
|
||||
|
||||
lw = pg.GraphicsLayoutWidget()
|
||||
lw.setFixedWidth(1000)
|
||||
lw.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||
lw.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)
|
||||
|
||||
scr = QtGui.QScrollArea()
|
||||
scr.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
|
||||
scr.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
|
||||
scr.setWidget(lw)
|
||||
win.setCentralWidget(scr)
|
||||
win.setWindowTitle('pyqtgraph example: Linearized color maps')
|
||||
|
@ -67,7 +67,7 @@ class MenuBox(pg.GraphicsObject):
|
||||
|
||||
# On right-click, raise the context menu
|
||||
def mouseClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.RightButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
if self.raiseContextMenu(ev):
|
||||
ev.accept()
|
||||
|
||||
@ -101,7 +101,7 @@ class MenuBox(pg.GraphicsObject):
|
||||
|
||||
alpha = QtGui.QWidgetAction(self.menu)
|
||||
alphaSlider = QtGui.QSlider()
|
||||
alphaSlider.setOrientation(QtCore.Qt.Horizontal)
|
||||
alphaSlider.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
alphaSlider.setMaximum(255)
|
||||
alphaSlider.setValue(255)
|
||||
alphaSlider.valueChanged.connect(self.setAlpha)
|
||||
|
@ -20,12 +20,12 @@ class CustomViewBox(pg.ViewBox):
|
||||
|
||||
## reimplement right-click to zoom out
|
||||
def mouseClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.RightButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
self.autoRange()
|
||||
|
||||
## reimplement mouseDragEvent to disable continuous axis zoom
|
||||
def mouseDragEvent(self, ev, axis=None):
|
||||
if axis is not None and ev.button() == QtCore.Qt.RightButton:
|
||||
if axis is not None and ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
ev.ignore()
|
||||
else:
|
||||
pg.ViewBox.mouseDragEvent(self, ev, axis=axis)
|
||||
|
@ -22,7 +22,7 @@ class Ui_Form(object):
|
||||
self.gridLayout_2.setObjectName(u"gridLayout_2")
|
||||
self.splitter = QSplitter(Form)
|
||||
self.splitter.setObjectName(u"splitter")
|
||||
self.splitter.setOrientation(Qt.Horizontal)
|
||||
self.splitter.setOrientation(Qt.Orientation.Horizontal)
|
||||
self.widget = QWidget(self.splitter)
|
||||
self.widget.setObjectName(u"widget")
|
||||
self.gridLayout = QGridLayout(self.widget)
|
||||
@ -68,7 +68,7 @@ class Ui_Form(object):
|
||||
font = QFont()
|
||||
font.setBold(True)
|
||||
self.loadedFileLabel.setFont(font)
|
||||
self.loadedFileLabel.setAlignment(Qt.AlignCenter)
|
||||
self.loadedFileLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.verticalLayout.addWidget(self.loadedFileLabel)
|
||||
|
||||
|
@ -344,7 +344,7 @@ class CircularSolid(pg.GraphicsObject, ParamObj):
|
||||
return self.path
|
||||
|
||||
def paint(self, p, *args):
|
||||
p.setRenderHints(p.renderHints() | p.Antialiasing)
|
||||
p.setRenderHints(p.renderHints() | p.RenderHint.Antialiasing)
|
||||
p.setPen(self.pen)
|
||||
p.fillPath(self.path, self.brush)
|
||||
p.drawPath(self.path)
|
||||
@ -512,8 +512,8 @@ class Ray(pg.GraphicsObject, ParamObj):
|
||||
|
||||
def paint(self, p, *args):
|
||||
#p.setPen(pg.mkPen((255,0,0, 150)))
|
||||
p.setRenderHints(p.renderHints() | p.Antialiasing)
|
||||
p.setCompositionMode(p.CompositionMode_Plus)
|
||||
p.setRenderHints(p.renderHints() | p.RenderHint.Antialiasing)
|
||||
p.setCompositionMode(p.CompositionMode.CompositionMode_Plus)
|
||||
p.setPen(wlPen(self['wl']))
|
||||
p.drawPath(self.path)
|
||||
|
||||
|
@ -57,14 +57,14 @@ class RelativityGUI(QtGui.QWidget):
|
||||
self.layout.setContentsMargins(0,0,0,0)
|
||||
self.setLayout(self.layout)
|
||||
self.splitter = QtGui.QSplitter()
|
||||
self.splitter.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.splitter.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.layout.addWidget(self.splitter)
|
||||
|
||||
self.tree = ParameterTree(showHeader=False)
|
||||
self.splitter.addWidget(self.tree)
|
||||
|
||||
self.splitter2 = QtGui.QSplitter()
|
||||
self.splitter2.setOrientation(QtCore.Qt.Vertical)
|
||||
self.splitter2.setOrientation(QtCore.Qt.Orientation.Vertical)
|
||||
self.splitter.addWidget(self.splitter2)
|
||||
|
||||
self.worldlinePlots = pg.GraphicsLayoutWidget()
|
||||
|
@ -24,7 +24,7 @@ def format(color, style=''):
|
||||
_format = QTextCharFormat()
|
||||
_format.setForeground(_color)
|
||||
if 'bold' in style:
|
||||
_format.setFontWeight(QFont.Bold)
|
||||
_format.setFontWeight(QFont.Weight.Bold)
|
||||
if 'italic' in style:
|
||||
_format.setFontItalic(True)
|
||||
|
||||
|
@ -166,7 +166,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
items = self.items(ev.scenePos())
|
||||
for i in items:
|
||||
if i.isEnabled() and i.isVisible() and (i.flags() & i.ItemIsFocusable):
|
||||
i.setFocus(QtCore.Qt.MouseFocusReason)
|
||||
i.setFocus(QtCore.Qt.FocusReason.MouseFocusReason)
|
||||
break
|
||||
|
||||
def _moveEventIsAllowed(self):
|
||||
@ -201,7 +201,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
now = ptime.time()
|
||||
init = False
|
||||
## keep track of which buttons are involved in dragging
|
||||
for btn in [QtCore.Qt.LeftButton, QtCore.Qt.MiddleButton, QtCore.Qt.RightButton]:
|
||||
for btn in [QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.MouseButton.MiddleButton, QtCore.Qt.MouseButton.RightButton]:
|
||||
if not (ev.buttons() & btn):
|
||||
continue
|
||||
if btn not in self.dragButtons: ## see if we've dragged far enough yet
|
||||
@ -304,9 +304,9 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
# Update last hover event unless:
|
||||
# - mouse is dragging (move+buttons); in this case we want the dragged
|
||||
# item to continue receiving events until the drag is over
|
||||
# - event is not a mouse event (QEvent.Leave sometimes appears here)
|
||||
if (ev.type() == ev.GraphicsSceneMousePress or
|
||||
(ev.type() == ev.GraphicsSceneMouseMove and not ev.buttons())):
|
||||
# - event is not a mouse event (QEvent.Type.Leave sometimes appears here)
|
||||
if (ev.type() == ev.Type.GraphicsSceneMousePress or
|
||||
(ev.type() == ev.Type.GraphicsSceneMouseMove and not ev.buttons())):
|
||||
self.lastHoverEvent = event ## save this so we can ask about accepted events later.
|
||||
|
||||
def sendDragEvent(self, ev, init=False, final=False):
|
||||
@ -345,7 +345,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
#print " --> accepted"
|
||||
self.dragItem = item
|
||||
if item.flags() & item.ItemIsFocusable:
|
||||
item.setFocus(QtCore.Qt.MouseFocusReason)
|
||||
item.setFocus(QtCore.Qt.FocusReason.MouseFocusReason)
|
||||
break
|
||||
elif self.dragItem is not None:
|
||||
event.currentItem = self.dragItem
|
||||
@ -390,7 +390,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
|
||||
if ev.isAccepted():
|
||||
if item.flags() & item.ItemIsFocusable:
|
||||
item.setFocus(QtCore.Qt.MouseFocusReason)
|
||||
item.setFocus(QtCore.Qt.FocusReason.MouseFocusReason)
|
||||
break
|
||||
self.sigMouseClicked.emit(ev)
|
||||
return ev.isAccepted()
|
||||
@ -419,7 +419,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
item = QtGui.QGraphicsScene.itemAt(self, *args)
|
||||
return self.translateGraphicsItem(item)
|
||||
|
||||
def itemsNearEvent(self, event, selMode=QtCore.Qt.IntersectsItemShape, sortOrder=QtCore.Qt.DescendingOrder, hoverable=False):
|
||||
def itemsNearEvent(self, event, selMode=QtCore.Qt.ItemSelectionMode.IntersectsItemShape, sortOrder=QtCore.Qt.SortOrder.DescendingOrder, hoverable=False):
|
||||
"""
|
||||
Return an iterator that iterates first through the items that directly intersect point (in Z order)
|
||||
followed by any other items that are within the scene's click radius.
|
||||
|
@ -25,7 +25,7 @@ class ExportDialog(QtGui.QWidget):
|
||||
self.scene = scene
|
||||
|
||||
self.selectBox = QtGui.QGraphicsRectItem()
|
||||
self.selectBox.setPen(fn.mkPen('y', width=3, style=QtCore.Qt.DashLine))
|
||||
self.selectBox.setPen(fn.mkPen('y', width=3, style=QtCore.Qt.PenStyle.DashLine))
|
||||
self.selectBox.hide()
|
||||
self.scene.addItem(self.selectBox)
|
||||
|
||||
|
@ -18,7 +18,7 @@ class MouseDragEvent(object):
|
||||
self.currentItem = None
|
||||
self._buttonDownScenePos = {}
|
||||
self._buttonDownScreenPos = {}
|
||||
for btn in [QtCore.Qt.LeftButton, QtCore.Qt.MiddleButton, QtCore.Qt.RightButton]:
|
||||
for btn in [QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.MouseButton.MiddleButton, QtCore.Qt.MouseButton.RightButton]:
|
||||
self._buttonDownScenePos[btn] = moveEvent.buttonDownScenePos(btn)
|
||||
self._buttonDownScreenPos[btn] = moveEvent.buttonDownScreenPos(btn)
|
||||
self._scenePos = moveEvent.scenePos()
|
||||
|
@ -11,7 +11,6 @@ This module exists to smooth out some of the differences between PySide and PyQt
|
||||
"""
|
||||
|
||||
import os, sys, re, time, subprocess, warnings
|
||||
import enum
|
||||
|
||||
from .python2_3 import asUnicode
|
||||
|
||||
@ -329,34 +328,6 @@ if QT_LIB == PYSIDE6:
|
||||
|
||||
|
||||
if QT_LIB == PYQT6:
|
||||
# module.Class.EnumClass.Enum -> module.Class.Enum
|
||||
def promote_enums(module):
|
||||
class_names = [x for x in dir(module) if x.startswith('Q')]
|
||||
for class_name in class_names:
|
||||
klass = getattr(module, class_name)
|
||||
if not isinstance(klass, sip.wrappertype):
|
||||
continue
|
||||
attrib_names = [x for x in dir(klass) if x[0].isupper()]
|
||||
for attrib_name in attrib_names:
|
||||
attrib = getattr(klass, attrib_name)
|
||||
if not isinstance(attrib, enum.EnumMeta):
|
||||
continue
|
||||
for e in attrib:
|
||||
setattr(klass, e.name, e)
|
||||
|
||||
promote_enums(QtCore)
|
||||
promote_enums(QtGui)
|
||||
promote_enums(QtWidgets)
|
||||
|
||||
# QKeyEvent::key() returns an int
|
||||
# so comparison with a Key_* enum will always be False
|
||||
# here we convert the enum to its int value
|
||||
keys = ['Up', 'Down', 'Right', 'Left', 'Return', 'Enter', 'Delete', 'Backspace',
|
||||
'PageUp', 'PageDown', 'Home', 'End', 'Tab', 'Backtab', 'Escape', 'Space']
|
||||
for name in keys:
|
||||
e = getattr(QtCore.Qt.Key, 'Key_' + name)
|
||||
setattr(QtCore.Qt, e.name, e.value)
|
||||
|
||||
# shim the old names for QPointF mouse coords
|
||||
QtGui.QSinglePointEvent.localPos = lambda o : o.position()
|
||||
QtGui.QSinglePointEvent.windowPos = lambda o : o.scenePosition()
|
||||
|
@ -16,8 +16,8 @@ class ThreadsafeTimer(QtCore.QObject):
|
||||
self.timer.timeout.connect(self.timerFinished)
|
||||
self.timer.moveToThread(QtCore.QCoreApplication.instance().thread())
|
||||
self.moveToThread(QtCore.QCoreApplication.instance().thread())
|
||||
self.sigTimerStopRequested.connect(self.stop, QtCore.Qt.QueuedConnection)
|
||||
self.sigTimerStartRequested.connect(self.start, QtCore.Qt.QueuedConnection)
|
||||
self.sigTimerStopRequested.connect(self.stop, QtCore.Qt.ConnectionType.QueuedConnection)
|
||||
self.sigTimerStartRequested.connect(self.start, QtCore.Qt.ConnectionType.QueuedConnection)
|
||||
|
||||
|
||||
def start(self, timeout):
|
||||
|
@ -31,7 +31,7 @@ class Canvas(QtGui.QWidget):
|
||||
self.view = ViewBox()
|
||||
self.ui.view.setCentralItem(self.view)
|
||||
self.itemList = self.ui.itemList
|
||||
self.itemList.setSelectionMode(self.itemList.ExtendedSelection)
|
||||
self.itemList.setSelectionMode(self.itemList.SelectionMode.ExtendedSelection)
|
||||
self.allowTransforms = allowTransforms
|
||||
self.multiSelectBox = SelectBox()
|
||||
self.view.addItem(self.multiSelectBox)
|
||||
@ -165,13 +165,13 @@ class Canvas(QtGui.QWidget):
|
||||
citem = item.canvasItem()
|
||||
except AttributeError:
|
||||
return
|
||||
if item.checkState(0) == QtCore.Qt.Checked:
|
||||
if item.checkState(0) == QtCore.Qt.CheckState.Checked:
|
||||
for i in range(item.childCount()):
|
||||
item.child(i).setCheckState(0, QtCore.Qt.Checked)
|
||||
item.child(i).setCheckState(0, QtCore.Qt.CheckState.Checked)
|
||||
citem.show()
|
||||
else:
|
||||
for i in range(item.childCount()):
|
||||
item.child(i).setCheckState(0, QtCore.Qt.Unchecked)
|
||||
item.child(i).setCheckState(0, QtCore.Qt.CheckState.Unchecked)
|
||||
citem.hide()
|
||||
|
||||
def treeItemSelected(self):
|
||||
@ -344,14 +344,14 @@ class Canvas(QtGui.QWidget):
|
||||
insertLocation = i+1
|
||||
|
||||
node = QtGui.QTreeWidgetItem([name])
|
||||
flags = node.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsDragEnabled
|
||||
flags = node.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsDragEnabled
|
||||
if not isinstance(citem, GroupCanvasItem):
|
||||
flags = flags & ~QtCore.Qt.ItemIsDropEnabled
|
||||
flags = flags & ~QtCore.Qt.ItemFlag.ItemIsDropEnabled
|
||||
node.setFlags(flags)
|
||||
if citem.opts['visible']:
|
||||
node.setCheckState(0, QtCore.Qt.Checked)
|
||||
node.setCheckState(0, QtCore.Qt.CheckState.Checked)
|
||||
else:
|
||||
node.setCheckState(0, QtCore.Qt.Unchecked)
|
||||
node.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
|
||||
|
||||
node.name = name
|
||||
parent.insertChild(insertLocation, node)
|
||||
@ -391,13 +391,13 @@ class Canvas(QtGui.QWidget):
|
||||
|
||||
def itemVisibilityChanged(self, item):
|
||||
listItem = item.listItem
|
||||
checked = listItem.checkState(0) == QtCore.Qt.Checked
|
||||
checked = listItem.checkState(0) == QtCore.Qt.CheckState.Checked
|
||||
vis = item.isVisible()
|
||||
if vis != checked:
|
||||
if vis:
|
||||
listItem.setCheckState(0, QtCore.Qt.Checked)
|
||||
listItem.setCheckState(0, QtCore.Qt.CheckState.Checked)
|
||||
else:
|
||||
listItem.setCheckState(0, QtCore.Qt.Unchecked)
|
||||
listItem.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
|
||||
|
||||
def removeItem(self, item):
|
||||
if isinstance(item, QtGui.QTreeWidgetItem):
|
||||
|
@ -66,7 +66,7 @@ class CanvasItem(QtCore.QObject):
|
||||
self.alphaLabel = QtGui.QLabel(translate("CanvasItem", "Alpha"))
|
||||
self.alphaSlider = QtGui.QSlider()
|
||||
self.alphaSlider.setMaximum(1023)
|
||||
self.alphaSlider.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.alphaSlider.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.alphaSlider.setValue(1023)
|
||||
self.layout.addWidget(self.alphaLabel, 0, 0)
|
||||
self.layout.addWidget(self.alphaSlider, 0, 1)
|
||||
|
@ -28,20 +28,20 @@ class Ui_Form(object):
|
||||
self.gridLayout_2.setObjectName(u"gridLayout_2")
|
||||
self.splitter = QSplitter(Form)
|
||||
self.splitter.setObjectName(u"splitter")
|
||||
self.splitter.setOrientation(Qt.Horizontal)
|
||||
self.splitter.setOrientation(Qt.Orientation.Horizontal)
|
||||
self.view = GraphicsView(self.splitter)
|
||||
self.view.setObjectName(u"view")
|
||||
self.splitter.addWidget(self.view)
|
||||
self.vsplitter = QSplitter(self.splitter)
|
||||
self.vsplitter.setObjectName(u"vsplitter")
|
||||
self.vsplitter.setOrientation(Qt.Vertical)
|
||||
self.vsplitter.setOrientation(Qt.Orientation.Vertical)
|
||||
self.canvasCtrlWidget = QWidget(self.vsplitter)
|
||||
self.canvasCtrlWidget.setObjectName(u"canvasCtrlWidget")
|
||||
self.gridLayout = QGridLayout(self.canvasCtrlWidget)
|
||||
self.gridLayout.setObjectName(u"gridLayout")
|
||||
self.autoRangeBtn = QPushButton(self.canvasCtrlWidget)
|
||||
self.autoRangeBtn.setObjectName(u"autoRangeBtn")
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(1)
|
||||
sizePolicy.setHeightForWidth(self.autoRangeBtn.sizePolicy().hasHeightForWidth())
|
||||
@ -70,7 +70,7 @@ class Ui_Form(object):
|
||||
__qtreewidgetitem.setText(0, u"1");
|
||||
self.itemList.setHeaderItem(__qtreewidgetitem)
|
||||
self.itemList.setObjectName(u"itemList")
|
||||
sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
sizePolicy1.setHorizontalStretch(0)
|
||||
sizePolicy1.setVerticalStretch(100)
|
||||
sizePolicy1.setHeightForWidth(self.itemList.sizePolicy().hasHeightForWidth())
|
||||
|
@ -18,7 +18,7 @@ class Ui_Form(object):
|
||||
if not Form.objectName():
|
||||
Form.setObjectName(u"Form")
|
||||
Form.resize(224, 117)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
|
||||
|
@ -541,7 +541,7 @@ class ColorMap(object):
|
||||
color = np.concatenate( (col_n, col_p) )
|
||||
grad.setStops(list(zip(pos, color)))
|
||||
if self.mapping_mode == self.REPEAT:
|
||||
grad.setSpread( QtGui.QGradient.RepeatSpread )
|
||||
grad.setSpread( QtGui.QGradient.Spread.RepeatSpread )
|
||||
return grad
|
||||
|
||||
def getBrush(self, span=(0.,1.), orientation='vertical'):
|
||||
|
@ -11,17 +11,17 @@ class CmdInput(QtGui.QLineEdit):
|
||||
self.ptr = 0
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.key() == QtCore.Qt.Key_Up:
|
||||
if ev.key() == QtCore.Qt.Key.Key_Up:
|
||||
if self.ptr < len(self.history) - 1:
|
||||
self.setHistory(self.ptr+1)
|
||||
ev.accept()
|
||||
return
|
||||
elif ev.key() == QtCore.Qt.Key_Down:
|
||||
elif ev.key() == QtCore.Qt.Key.Key_Down:
|
||||
if self.ptr > 0:
|
||||
self.setHistory(self.ptr-1)
|
||||
ev.accept()
|
||||
return
|
||||
elif ev.key() == QtCore.Qt.Key_Return:
|
||||
elif ev.key() == QtCore.Qt.Key.Key_Return:
|
||||
self.execCmd()
|
||||
else:
|
||||
super().keyPressEvent(ev)
|
||||
|
@ -230,7 +230,7 @@ class ConsoleWidget(QtGui.QWidget):
|
||||
atBottom = scroll == sb.maximum()
|
||||
scrollToBottom = atBottom
|
||||
|
||||
self.output.moveCursor(QtGui.QTextCursor.End)
|
||||
self.output.moveCursor(QtGui.QTextCursor.MoveOperation.End)
|
||||
if html:
|
||||
self.output.textCursor().insertHtml(strn)
|
||||
else:
|
||||
|
@ -26,7 +26,7 @@ class Ui_Form(object):
|
||||
self.gridLayout.setObjectName(u"gridLayout")
|
||||
self.splitter = QSplitter(Form)
|
||||
self.splitter.setObjectName(u"splitter")
|
||||
self.splitter.setOrientation(Qt.Vertical)
|
||||
self.splitter.setOrientation(Qt.Orientation.Vertical)
|
||||
self.layoutWidget = QWidget(self.splitter)
|
||||
self.layoutWidget.setObjectName(u"layoutWidget")
|
||||
self.verticalLayout = QVBoxLayout(self.layoutWidget)
|
||||
@ -117,7 +117,7 @@ class Ui_Form(object):
|
||||
|
||||
self.gridLayout_2.addWidget(self.exceptionInfoLabel, 1, 0, 1, 7)
|
||||
|
||||
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
|
||||
|
||||
self.gridLayout_2.addItem(self.horizontalSpacer, 0, 5, 1, 1)
|
||||
|
||||
|
@ -149,7 +149,7 @@ class SplitContainer(Container, QtGui.QSplitter):
|
||||
|
||||
class HContainer(SplitContainer):
|
||||
def __init__(self, area):
|
||||
SplitContainer.__init__(self, area, QtCore.Qt.Horizontal)
|
||||
SplitContainer.__init__(self, area, QtCore.Qt.Orientation.Horizontal)
|
||||
|
||||
def type(self):
|
||||
return 'horizontal'
|
||||
@ -180,7 +180,7 @@ class HContainer(SplitContainer):
|
||||
|
||||
class VContainer(SplitContainer):
|
||||
def __init__(self, area):
|
||||
SplitContainer.__init__(self, area, QtCore.Qt.Vertical)
|
||||
SplitContainer.__init__(self, area, QtCore.Qt.Orientation.Vertical)
|
||||
|
||||
def type(self):
|
||||
return 'vertical'
|
||||
@ -254,7 +254,7 @@ class TContainer(Container, QtGui.QWidget):
|
||||
self.tabClicked(item.label)
|
||||
|
||||
def tabClicked(self, tab, ev=None):
|
||||
if ev is None or ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev is None or ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
for i in range(self.count()):
|
||||
w = self.widget(i)
|
||||
if w is tab.dock:
|
||||
|
@ -24,7 +24,7 @@ class Dock(QtGui.QWidget, DockDrop):
|
||||
self.moveLabel = True ## If false, the dock is no longer allowed to move the label.
|
||||
self.autoOrient = autoOrientation
|
||||
self.orientation = 'horizontal'
|
||||
#self.label.setAlignment(QtCore.Qt.AlignHCenter)
|
||||
#self.label.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
|
||||
self.topLayout = QtGui.QGridLayout()
|
||||
self.topLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.topLayout.setSpacing(0)
|
||||
@ -36,7 +36,7 @@ class Dock(QtGui.QWidget, DockDrop):
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.layout.setSpacing(0)
|
||||
self.widgetArea.setLayout(self.layout)
|
||||
self.widgetArea.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||
self.widgetArea.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)
|
||||
self.widgets = []
|
||||
self._container = None
|
||||
self.currentRow = 0
|
||||
@ -265,7 +265,7 @@ class DockLabel(VerticalLabel):
|
||||
self.fixedWidth = False
|
||||
self.fontSize = fontSize
|
||||
VerticalLabel.__init__(self, text, orientation='horizontal', forceWidth=False)
|
||||
self.setAlignment(QtCore.Qt.AlignTop|QtCore.Qt.AlignHCenter)
|
||||
self.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop|QtCore.Qt.AlignmentFlag.AlignHCenter)
|
||||
self.dock = dock
|
||||
self.updateStyle()
|
||||
self.setAutoFillBackground(False)
|
||||
@ -275,7 +275,7 @@ class DockLabel(VerticalLabel):
|
||||
if showCloseButton:
|
||||
self.closeButton = QtGui.QToolButton(self)
|
||||
self.closeButton.clicked.connect(self.sigCloseClicked)
|
||||
self.closeButton.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_TitleBarCloseButton))
|
||||
self.closeButton.setIcon(QtGui.QApplication.style().standardIcon(QtGui.QStyle.StandardPixmap.SP_TitleBarCloseButton))
|
||||
|
||||
def updateStyle(self):
|
||||
r = '3px'
|
||||
@ -339,7 +339,7 @@ class DockLabel(VerticalLabel):
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
self.mouseMoved = (lpos - self.pressPos).manhattanLength() > QtGui.QApplication.startDragDistance()
|
||||
|
||||
if self.mouseMoved and ev.buttons() == QtCore.Qt.LeftButton:
|
||||
if self.mouseMoved and ev.buttons() == QtCore.Qt.MouseButton.LeftButton:
|
||||
self.dock.startDrag()
|
||||
ev.accept()
|
||||
|
||||
@ -349,7 +349,7 @@ class DockLabel(VerticalLabel):
|
||||
self.sigClicked.emit(self, ev)
|
||||
|
||||
def mouseDoubleClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
self.dock.float()
|
||||
|
||||
def resizeEvent (self, ev):
|
||||
|
@ -91,7 +91,7 @@ class DropAreaOverlay(QtGui.QWidget):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.dropArea = None
|
||||
self.hide()
|
||||
self.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
|
||||
self.setAttribute(QtCore.Qt.WidgetAttribute.WA_TransparentForMouseEvents)
|
||||
|
||||
def setDropArea(self, area):
|
||||
self.dropArea = area
|
||||
|
@ -45,8 +45,8 @@ class Exporter(object):
|
||||
if opts is None:
|
||||
opts = {}
|
||||
self.fileDialog = FileDialog()
|
||||
self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
|
||||
self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
|
||||
self.fileDialog.setFileMode(QtGui.QFileDialog.FileMode.AnyFile)
|
||||
self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptMode.AcceptSave)
|
||||
if filter is not None:
|
||||
if isinstance(filter, basestring):
|
||||
self.fileDialog.setNameFilter(filter)
|
||||
|
@ -20,7 +20,7 @@ class ImageExporter(Exporter):
|
||||
scene = item
|
||||
bgbrush = scene.views()[0].backgroundBrush()
|
||||
bg = bgbrush.color()
|
||||
if bgbrush.style() == QtCore.Qt.NoBrush:
|
||||
if bgbrush.style() == QtCore.Qt.BrushStyle.NoBrush:
|
||||
bg.setAlpha(0)
|
||||
|
||||
self.params = Parameter(name='params', type='group', children=[
|
||||
@ -97,7 +97,7 @@ class ImageExporter(Exporter):
|
||||
'background': self.params['background'],
|
||||
'painter': painter,
|
||||
'resolutionScale': resolutionScale})
|
||||
painter.setRenderHint(QtGui.QPainter.Antialiasing, self.params['antialias'])
|
||||
painter.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing, self.params['antialias'])
|
||||
self.getScene().render(painter, QtCore.QRectF(targetRect), QtCore.QRectF(sourceRect))
|
||||
finally:
|
||||
self.setExportMode(False)
|
||||
|
@ -91,7 +91,7 @@ class MatplotlibExporter(Exporter):
|
||||
|
||||
opts = item.opts
|
||||
pen = fn.mkPen(opts['pen'])
|
||||
if pen.style() == QtCore.Qt.NoPen:
|
||||
if pen.style() == QtCore.Qt.PenStyle.NoPen:
|
||||
linestyle = ''
|
||||
else:
|
||||
linestyle = '-'
|
||||
|
@ -39,7 +39,7 @@ class PrintExporter(Exporter):
|
||||
printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution)
|
||||
dialog = QtGui.QPrintDialog(printer)
|
||||
dialog.setWindowTitle(translate('Exporter', "Print Document"))
|
||||
if dialog.exec_() != QtGui.QDialog.Accepted:
|
||||
if dialog.exec_() != QtGui.QDialog.DialogCode.Accepted:
|
||||
return
|
||||
|
||||
#dpi = QtGui.QDesktopWidget().physicalDpiX()
|
||||
|
@ -26,7 +26,7 @@ class SVGExporter(Exporter):
|
||||
scene = item
|
||||
bgbrush = scene.views()[0].backgroundBrush()
|
||||
bg = bgbrush.color()
|
||||
if bgbrush.style() == QtCore.Qt.NoBrush:
|
||||
if bgbrush.style() == QtCore.Qt.BrushStyle.NoBrush:
|
||||
bg.setAlpha(0)
|
||||
|
||||
self.params = Parameter(name='params', type='group', children=[
|
||||
@ -207,7 +207,7 @@ def _generateItemSvg(item, nodes=None, root=None, options={}):
|
||||
try:
|
||||
p.setTransform(tr)
|
||||
opt = QtGui.QStyleOptionGraphicsItem()
|
||||
if item.flags() & QtGui.QGraphicsItem.ItemUsesExtendedStyleOption:
|
||||
if item.flags() & QtGui.QGraphicsItem.GraphicsItemFlag.ItemUsesExtendedStyleOption:
|
||||
opt.exposedRect = item.boundingRect()
|
||||
item.paint(p, opt, None)
|
||||
finally:
|
||||
@ -253,7 +253,7 @@ def _generateItemSvg(item, nodes=None, root=None, options={}):
|
||||
childGroup = g1 ## add children directly to this node unless we are clipping
|
||||
if not isinstance(item, QtGui.QGraphicsScene):
|
||||
## See if this item clips its children
|
||||
if item.flags() & item.ItemClipsChildrenToShape:
|
||||
if item.flags() & item.GraphicsItemFlag.ItemClipsChildrenToShape:
|
||||
## Generate svg for just the path
|
||||
path = QtGui.QGraphicsPathItem(item.mapToScene(item.shape()))
|
||||
item.scene().addItem(path)
|
||||
@ -416,7 +416,7 @@ def itemTransform(item, root):
|
||||
return tr
|
||||
|
||||
|
||||
if item.flags() & item.ItemIgnoresTransformations:
|
||||
if item.flags() & item.GraphicsItemFlag.ItemIgnoresTransformations:
|
||||
pos = item.pos()
|
||||
parent = item.parentItem()
|
||||
if parent is not None:
|
||||
@ -433,7 +433,7 @@ def itemTransform(item, root):
|
||||
if nextRoot is None:
|
||||
nextRoot = root
|
||||
break
|
||||
if nextRoot is root or (nextRoot.flags() & nextRoot.ItemIgnoresTransformations):
|
||||
if nextRoot is root or (nextRoot.flags() & nextRoot.GraphicsItemFlag.ItemIgnoresTransformations):
|
||||
break
|
||||
|
||||
if isinstance(nextRoot, QtGui.QGraphicsScene):
|
||||
|
@ -528,7 +528,7 @@ class Flowchart(Node):
|
||||
startDir = '.'
|
||||
self.fileDialog = FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
|
||||
self.fileDialog.setDefaultSuffix("fc")
|
||||
self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
|
||||
self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptMode.AcceptSave)
|
||||
self.fileDialog.show()
|
||||
self.fileDialog.fileSelected.connect(self.saveFile)
|
||||
return
|
||||
@ -605,8 +605,8 @@ class FlowchartCtrlWidget(QtGui.QWidget):
|
||||
self.ui.ctrlList.setColumnCount(2)
|
||||
#self.ui.ctrlList.setColumnWidth(0, 200)
|
||||
self.ui.ctrlList.setColumnWidth(1, 20)
|
||||
self.ui.ctrlList.setVerticalScrollMode(self.ui.ctrlList.ScrollPerPixel)
|
||||
self.ui.ctrlList.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.ui.ctrlList.setVerticalScrollMode(self.ui.ctrlList.ScrollMode.ScrollPerPixel)
|
||||
self.ui.ctrlList.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
|
||||
self.chartWidget = FlowchartWidget(chart, self)
|
||||
#self.chartWidget.viewBox().autoRange()
|
||||
@ -765,7 +765,7 @@ class FlowchartWidget(dockarea.DockArea):
|
||||
self.ctrl = ctrl
|
||||
self.hoverItem = None
|
||||
#self.setMinimumWidth(250)
|
||||
#self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding))
|
||||
#self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Preferred, QtGui.QSizePolicy.Policy.Expanding))
|
||||
|
||||
#self.ui = FlowchartTemplate.Ui_Form()
|
||||
#self.ui.setupUi(self)
|
||||
@ -791,7 +791,7 @@ class FlowchartWidget(dockarea.DockArea):
|
||||
self.selNameLabel = QtGui.QLabel()
|
||||
self.selDescLabel.setWordWrap(True)
|
||||
self.selectedTree = DataTreeWidget()
|
||||
#self.selectedTree.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||
#self.selectedTree.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
||||
#self.selInfoLayout.addWidget(self.selNameLabel)
|
||||
self.selInfoLayout.addWidget(self.selDescLabel)
|
||||
self.selInfoLayout.addWidget(self.selectedTree)
|
||||
@ -846,7 +846,7 @@ class FlowchartWidget(dockarea.DockArea):
|
||||
|
||||
def showViewMenu(self, ev):
|
||||
#QtGui.QPushButton.mouseReleaseEvent(self.ui.addNodeBtn, ev)
|
||||
#if ev.button() == QtCore.Qt.RightButton:
|
||||
#if ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
#self.menuPos = self.view.mapToScene(ev.pos())
|
||||
#self.nodeMenu.popup(ev.globalPos())
|
||||
#print "Flowchart.showViewMenu called"
|
||||
|
@ -68,7 +68,7 @@ class Ui_Form(object):
|
||||
font = QFont()
|
||||
font.setBold(True)
|
||||
self.fileNameLabel.setFont(font)
|
||||
self.fileNameLabel.setAlignment(Qt.AlignCenter)
|
||||
self.fileNameLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.gridLayout.addWidget(self.fileNameLabel, 0, 1, 1, 1)
|
||||
|
||||
|
@ -15,7 +15,7 @@ class FlowchartGraphicsView(GraphicsView):
|
||||
GraphicsView.__init__(self, *args, useOpenGL=False)
|
||||
self._vb = FlowchartViewBox(widget, lockAspect=True, invertY=True)
|
||||
self.setCentralItem(self._vb)
|
||||
self.setRenderHint(QtGui.QPainter.Antialiasing, True)
|
||||
self.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing, True)
|
||||
|
||||
def viewBox(self):
|
||||
return self._vb
|
||||
|
@ -28,7 +28,7 @@ class Ui_Form(object):
|
||||
self.gridLayout.setObjectName(u"gridLayout")
|
||||
self.selDescLabel = QLabel(self.selInfoWidget)
|
||||
self.selDescLabel.setObjectName(u"selDescLabel")
|
||||
self.selDescLabel.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
|
||||
self.selDescLabel.setAlignment(Qt.AlignLeading|Qt.AlignmentFlag.AlignLeft|Qt.AlignmentFlag.AlignTop)
|
||||
self.selDescLabel.setWordWrap(True)
|
||||
|
||||
self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1)
|
||||
|
@ -455,7 +455,7 @@ class TextItem(QtWidgets.QGraphicsTextItem):
|
||||
self.on_update()
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.key() == QtCore.Qt.Key_Enter or ev.key() == QtCore.Qt.Key_Return:
|
||||
if ev.key() == QtCore.Qt.Key.Key_Enter or ev.key() == QtCore.Qt.Key.Key_Return:
|
||||
if self.on_update is not None:
|
||||
self.on_update()
|
||||
return
|
||||
@ -482,7 +482,7 @@ class NodeGraphicsItem(GraphicsObject):
|
||||
self.hovered = False
|
||||
|
||||
self.node = node
|
||||
flags = self.ItemIsMovable | self.ItemIsSelectable | self.ItemIsFocusable |self.ItemSendsGeometryChanges
|
||||
flags = self.GraphicsItemFlag.ItemIsMovable | self.GraphicsItemFlag.ItemIsSelectable | self.GraphicsItemFlag.ItemIsFocusable | self.GraphicsItemFlag.ItemSendsGeometryChanges
|
||||
#flags = self.ItemIsFocusable |self.ItemSendsGeometryChanges
|
||||
|
||||
self.setFlags(flags)
|
||||
@ -490,7 +490,7 @@ class NodeGraphicsItem(GraphicsObject):
|
||||
self.nameItem = TextItem(self.node.name(), self, self.labelChanged)
|
||||
self.nameItem.setDefaultTextColor(QtGui.QColor(50, 50, 50))
|
||||
self.nameItem.moveBy(self.bounds.width()/2. - self.nameItem.boundingRect().width()/2., 0)
|
||||
self.nameItem.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
|
||||
self.nameItem.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextEditorInteraction)
|
||||
self.updateTerminals()
|
||||
#self.setZValue(10)
|
||||
|
||||
@ -587,7 +587,7 @@ class NodeGraphicsItem(GraphicsObject):
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
#print "Node.mouseClickEvent called."
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.accept()
|
||||
#print " ev.button: left"
|
||||
sel = self.isSelected()
|
||||
@ -600,7 +600,7 @@ class NodeGraphicsItem(GraphicsObject):
|
||||
self.update()
|
||||
#return ret
|
||||
|
||||
elif ev.button() == QtCore.Qt.RightButton:
|
||||
elif ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
#print " ev.button: right"
|
||||
ev.accept()
|
||||
#pos = ev.screenPos()
|
||||
@ -609,20 +609,20 @@ class NodeGraphicsItem(GraphicsObject):
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
#print "Node.mouseDrag"
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.accept()
|
||||
self.setPos(self.pos()+self.mapToParent(ev.pos())-self.mapToParent(ev.lastPos()))
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if not ev.isExit() and ev.acceptClicks(QtCore.Qt.LeftButton):
|
||||
ev.acceptDrags(QtCore.Qt.LeftButton)
|
||||
if not ev.isExit() and ev.acceptClicks(QtCore.Qt.MouseButton.LeftButton):
|
||||
ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton)
|
||||
self.hovered = True
|
||||
else:
|
||||
self.hovered = False
|
||||
self.update()
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.key() == QtCore.Qt.Key_Delete or ev.key() == QtCore.Qt.Key_Backspace:
|
||||
if ev.key() == QtCore.Qt.Key.Key_Delete or ev.key() == QtCore.Qt.Key.Key_Backspace:
|
||||
ev.accept()
|
||||
if not self.node._allowRemove:
|
||||
return
|
||||
@ -631,7 +631,7 @@ class NodeGraphicsItem(GraphicsObject):
|
||||
ev.ignore()
|
||||
|
||||
def itemChange(self, change, val):
|
||||
if change == self.ItemPositionHasChanged:
|
||||
if change == self.GraphicsItemChange.ItemPositionHasChanged:
|
||||
for k, t in self.terminals.items():
|
||||
t[1].nodeMoved()
|
||||
return GraphicsObject.itemChange(self, change, val)
|
||||
|
@ -286,7 +286,7 @@ class TextItem(QtWidgets.QGraphicsTextItem):
|
||||
self.on_update()
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.key() == QtCore.Qt.Key_Enter or ev.key() == QtCore.Qt.Key_Return:
|
||||
if ev.key() == QtCore.Qt.Key.Key_Enter or ev.key() == QtCore.Qt.Key.Key_Return:
|
||||
if self.on_update is not None:
|
||||
self.on_update()
|
||||
return
|
||||
@ -306,7 +306,7 @@ class TerminalGraphicsItem(GraphicsObject):
|
||||
self.newConnection = None
|
||||
self.setFiltersChildEvents(True) ## to pick up mouse events on the rectitem
|
||||
if self.term.isRenamable():
|
||||
self.label.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
|
||||
self.label.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextEditorInteraction)
|
||||
self.setZValue(1)
|
||||
self.menu = None
|
||||
|
||||
@ -357,10 +357,10 @@ class TerminalGraphicsItem(GraphicsObject):
|
||||
ev.ignore() ## necessary to allow click/drag events to process correctly
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.accept()
|
||||
self.label.setFocus(QtCore.Qt.MouseFocusReason)
|
||||
elif ev.button() == QtCore.Qt.RightButton:
|
||||
self.label.setFocus(QtCore.Qt.FocusReason.MouseFocusReason)
|
||||
elif ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
ev.accept()
|
||||
self.raiseContextMenu(ev)
|
||||
|
||||
@ -401,7 +401,7 @@ class TerminalGraphicsItem(GraphicsObject):
|
||||
self.term.node().removeTerminal(self.term)
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if ev.button() != QtCore.Qt.LeftButton:
|
||||
if ev.button() != QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.ignore()
|
||||
return
|
||||
|
||||
@ -438,9 +438,9 @@ class TerminalGraphicsItem(GraphicsObject):
|
||||
self.newConnection.setTarget(self.mapToView(ev.pos()))
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if not ev.isExit() and ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||
ev.acceptClicks(QtCore.Qt.LeftButton) ## we don't use the click, but we also don't want anyone else to use it.
|
||||
ev.acceptClicks(QtCore.Qt.RightButton)
|
||||
if not ev.isExit() and ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton):
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.LeftButton) ## we don't use the click, but we also don't want anyone else to use it.
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.RightButton)
|
||||
self.box.setBrush(fn.mkBrush('w'))
|
||||
else:
|
||||
self.box.setBrush(self.brush)
|
||||
@ -460,8 +460,8 @@ class ConnectionItem(GraphicsObject):
|
||||
def __init__(self, source, target=None):
|
||||
GraphicsObject.__init__(self)
|
||||
self.setFlags(
|
||||
self.ItemIsSelectable |
|
||||
self.ItemIsFocusable
|
||||
self.GraphicsItemFlag.ItemIsSelectable |
|
||||
self.GraphicsItemFlag.ItemIsFocusable
|
||||
)
|
||||
self.source = source
|
||||
self.target = target
|
||||
@ -527,7 +527,7 @@ class ConnectionItem(GraphicsObject):
|
||||
ev.ignore()
|
||||
return
|
||||
|
||||
if ev.key() == QtCore.Qt.Key_Delete or ev.key() == QtCore.Qt.Key_Backspace:
|
||||
if ev.key() == QtCore.Qt.Key.Key_Delete or ev.key() == QtCore.Qt.Key.Key_Backspace:
|
||||
self.source.disconnect(self.target)
|
||||
ev.accept()
|
||||
else:
|
||||
@ -537,7 +537,7 @@ class ConnectionItem(GraphicsObject):
|
||||
ev.ignore()
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.accept()
|
||||
sel = self.isSelected()
|
||||
self.setSelected(True)
|
||||
@ -546,7 +546,7 @@ class ConnectionItem(GraphicsObject):
|
||||
self.update()
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if (not ev.isExit()) and ev.acceptClicks(QtCore.Qt.LeftButton):
|
||||
if (not ev.isExit()) and ev.acceptClicks(QtCore.Qt.MouseButton.LeftButton):
|
||||
self.hovered = True
|
||||
else:
|
||||
self.hovered = False
|
||||
|
@ -63,18 +63,18 @@ class ColumnSelectNode(Node):
|
||||
self.columnList.clear()
|
||||
for c in cols:
|
||||
item = QtGui.QListWidgetItem(c)
|
||||
item.setFlags(QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsUserCheckable)
|
||||
item.setFlags(QtCore.Qt.ItemFlag.ItemIsEnabled|QtCore.Qt.ItemFlag.ItemIsUserCheckable)
|
||||
if c in self.columns:
|
||||
item.setCheckState(QtCore.Qt.Checked)
|
||||
item.setCheckState(QtCore.Qt.CheckState.Checked)
|
||||
else:
|
||||
item.setCheckState(QtCore.Qt.Unchecked)
|
||||
item.setCheckState(QtCore.Qt.CheckState.Unchecked)
|
||||
self.columnList.addItem(item)
|
||||
self.columnList.blockSignals(False)
|
||||
|
||||
|
||||
def itemChanged(self, item):
|
||||
col = str(item.text())
|
||||
if item.checkState() == QtCore.Qt.Checked:
|
||||
if item.checkState() == QtCore.Qt.CheckState.Checked:
|
||||
if col not in self.columns:
|
||||
self.columns.add(col)
|
||||
self.addOutput(col)
|
||||
|
@ -307,7 +307,7 @@ def mkBrush(*args, **kwds):
|
||||
elif len(args) == 1:
|
||||
arg = args[0]
|
||||
if arg is None:
|
||||
return QtGui.QBrush(QtCore.Qt.NoBrush)
|
||||
return QtGui.QBrush(QtCore.Qt.BrushStyle.NoBrush)
|
||||
elif isinstance(arg, QtGui.QBrush):
|
||||
return QtGui.QBrush(arg)
|
||||
else:
|
||||
@ -330,7 +330,6 @@ def mkPen(*args, **kargs):
|
||||
mkPen(None) # (no pen)
|
||||
|
||||
In these examples, *color* may be replaced with any arguments accepted by :func:`mkColor() <pyqtgraph.mkColor>` """
|
||||
|
||||
color = kargs.get('color', None)
|
||||
width = kargs.get('width', 1)
|
||||
style = kargs.get('style', None)
|
||||
@ -345,7 +344,7 @@ def mkPen(*args, **kargs):
|
||||
if isinstance(arg, QtGui.QPen):
|
||||
return QtGui.QPen(arg) ## return a copy of this pen
|
||||
elif arg is None:
|
||||
style = QtCore.Qt.NoPen
|
||||
style = QtCore.Qt.PenStyle.NoPen
|
||||
else:
|
||||
color = arg
|
||||
if len(args) > 1:
|
||||
@ -1619,7 +1618,7 @@ def makeQImage(imgData, alpha=None, copy=True, transpose=True):
|
||||
|
||||
copied = False
|
||||
if imgData.ndim == 2:
|
||||
imgFormat = QtGui.QImage.Format_Grayscale8
|
||||
imgFormat = QtGui.QImage.Format.Format_Grayscale8
|
||||
elif imgData.ndim == 3:
|
||||
# If we didn't explicitly specify alpha, check the array shape.
|
||||
if alpha is None:
|
||||
@ -1638,9 +1637,9 @@ def makeQImage(imgData, alpha=None, copy=True, transpose=True):
|
||||
profile("add alpha channel")
|
||||
|
||||
if alpha:
|
||||
imgFormat = QtGui.QImage.Format_ARGB32
|
||||
imgFormat = QtGui.QImage.Format.Format_ARGB32
|
||||
else:
|
||||
imgFormat = QtGui.QImage.Format_RGB32
|
||||
imgFormat = QtGui.QImage.Format.Format_RGB32
|
||||
else:
|
||||
raise TypeError("Image array must have ndim = 2 or 3.")
|
||||
|
||||
@ -1706,7 +1705,7 @@ def imageToArray(img, copy=False, transpose=True):
|
||||
arr = qimage_to_ndarray(img)
|
||||
|
||||
fmt = img.format()
|
||||
if fmt == img.Format_RGB32:
|
||||
if fmt == img.Format.Format_RGB32:
|
||||
arr[...,3] = 255
|
||||
|
||||
if copy:
|
||||
@ -1936,7 +1935,7 @@ def arrayToQPath(x, y, connect='all', finiteCheck=True):
|
||||
arr = np.frombuffer(backstore, dtype=[('c', '>i4'), ('x', '>f8'), ('y', '>f8')],
|
||||
count=n, offset=4)
|
||||
struct.pack_into('>i', backstore, 0, n)
|
||||
# cStart, fillRule (Qt.OddEvenFill)
|
||||
# cStart, fillRule (Qt.FillRule.OddEvenFill)
|
||||
struct.pack_into('>ii', backstore, 4+n*20, 0, 0)
|
||||
|
||||
# Fill array with vertex values
|
||||
|
@ -99,12 +99,12 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
||||
self.setBrush(fn.mkBrush(self.opts['brush']))
|
||||
|
||||
if self.opts['pxMode']:
|
||||
self.setFlags(self.flags() | self.ItemIgnoresTransformations)
|
||||
self.setFlags(self.flags() | self.GraphicsItemFlag.ItemIgnoresTransformations)
|
||||
else:
|
||||
self.setFlags(self.flags() & ~self.ItemIgnoresTransformations)
|
||||
self.setFlags(self.flags() & ~self.GraphicsItemFlag.ItemIgnoresTransformations)
|
||||
|
||||
def paint(self, p, *args):
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
super().paint(p, *args)
|
||||
|
||||
#p.setPen(fn.mkPen('r'))
|
||||
|
@ -611,8 +611,8 @@ class AxisItem(GraphicsWidget):
|
||||
finally:
|
||||
painter.end()
|
||||
self.picture = picture
|
||||
#p.setRenderHint(p.Antialiasing, False) ## Sometimes we get a segfault here ???
|
||||
#p.setRenderHint(p.TextAntialiasing, True)
|
||||
#p.setRenderHint(p.RenderHint.Antialiasing, False) ## Sometimes we get a segfault here ???
|
||||
#p.setRenderHint(p.RenderHint.TextAntialiasing, True)
|
||||
self.picture.play(p)
|
||||
|
||||
def setTicks(self, ticks):
|
||||
@ -1066,7 +1066,7 @@ class AxisItem(GraphicsWidget):
|
||||
if s is None:
|
||||
rects.append(None)
|
||||
else:
|
||||
br = p.boundingRect(QtCore.QRectF(0, 0, 100, 100), QtCore.Qt.AlignCenter, asUnicode(s))
|
||||
br = p.boundingRect(QtCore.QRectF(0, 0, 100, 100), QtCore.Qt.AlignmentFlag.AlignCenter, asUnicode(s))
|
||||
## boundingRect is usually just a bit too large
|
||||
## (but this probably depends on per-font metrics?)
|
||||
br.setHeight(br.height() * 0.8)
|
||||
@ -1110,7 +1110,7 @@ class AxisItem(GraphicsWidget):
|
||||
continue
|
||||
vstr = asUnicode(vstr)
|
||||
x = tickPositions[i][j]
|
||||
#textRect = p.boundingRect(QtCore.QRectF(0, 0, 100, 100), QtCore.Qt.AlignCenter, vstr)
|
||||
#textRect = p.boundingRect(QtCore.QRectF(0, 0, 100, 100), QtCore.Qt.AlignmentFlag.AlignCenter, vstr)
|
||||
textRect = rects[j]
|
||||
height = textRect.height()
|
||||
width = textRect.width()
|
||||
@ -1118,25 +1118,25 @@ class AxisItem(GraphicsWidget):
|
||||
offset = max(0,self.style['tickLength']) + textOffset
|
||||
|
||||
if self.orientation == 'left':
|
||||
alignFlags = QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter
|
||||
alignFlags = QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignVCenter
|
||||
rect = QtCore.QRectF(tickStop-offset-width, x-(height/2), width, height)
|
||||
elif self.orientation == 'right':
|
||||
alignFlags = QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter
|
||||
alignFlags = QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignVCenter
|
||||
rect = QtCore.QRectF(tickStop+offset, x-(height/2), width, height)
|
||||
elif self.orientation == 'top':
|
||||
alignFlags = QtCore.Qt.AlignHCenter|QtCore.Qt.AlignBottom
|
||||
alignFlags = QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignBottom
|
||||
rect = QtCore.QRectF(x-width/2., tickStop-offset-height, width, height)
|
||||
elif self.orientation == 'bottom':
|
||||
alignFlags = QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop
|
||||
alignFlags = QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignTop
|
||||
rect = QtCore.QRectF(x-width/2., tickStop+offset, width, height)
|
||||
|
||||
if QT_LIB == 'PyQt6':
|
||||
# PyQt6 doesn't allow or-ing of different enum types
|
||||
# so we need to take its value property
|
||||
textFlags = alignFlags.value | QtCore.Qt.TextDontClip.value
|
||||
textFlags = alignFlags.value | QtCore.Qt.TextFlag.TextDontClip.value
|
||||
else:
|
||||
# for PyQt5, the following expression is not commutative!
|
||||
textFlags = alignFlags | QtCore.Qt.TextDontClip
|
||||
textFlags = alignFlags | QtCore.Qt.TextFlag.TextDontClip
|
||||
|
||||
#p.setPen(self.pen())
|
||||
#p.drawText(rect, textFlags, vstr)
|
||||
@ -1151,8 +1151,8 @@ class AxisItem(GraphicsWidget):
|
||||
def drawPicture(self, p, axisSpec, tickSpecs, textSpecs):
|
||||
profiler = debug.Profiler()
|
||||
|
||||
p.setRenderHint(p.Antialiasing, False)
|
||||
p.setRenderHint(p.TextAntialiasing, True)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing, False)
|
||||
p.setRenderHint(p.RenderHint.TextAntialiasing, True)
|
||||
|
||||
## draw long line along axis
|
||||
pen, p1, p2 = axisSpec
|
||||
|
@ -50,7 +50,7 @@ class ButtonItem(GraphicsObject):
|
||||
self.setOpacity(0.7)
|
||||
|
||||
def paint(self, p, *args):
|
||||
p.setRenderHint(p.Antialiasing)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing)
|
||||
p.drawPixmap(0, 0, self.pixmap)
|
||||
|
||||
def boundingRect(self):
|
||||
|
@ -30,7 +30,7 @@ class CurvePoint(GraphicsObject):
|
||||
self.setProperty('index', 0)
|
||||
|
||||
if hasattr(self, 'ItemHasNoContents'):
|
||||
self.setFlags(self.flags() | self.ItemHasNoContents)
|
||||
self.setFlags(self.flags() | self.GraphicsItemFlag.ItemHasNoContents)
|
||||
|
||||
if pos is not None:
|
||||
self.setPos(pos)
|
||||
@ -113,7 +113,7 @@ class CurveArrow(CurvePoint):
|
||||
CurvePoint.__init__(self, curve, index=index, pos=pos)
|
||||
if opts.get('pxMode', True):
|
||||
opts['pxMode'] = False
|
||||
self.setFlags(self.flags() | self.ItemIgnoresTransformations)
|
||||
self.setFlags(self.flags() | self.GraphicsItemFlag.ItemIgnoresTransformations)
|
||||
opts['angle'] = 0
|
||||
self.arrow = ArrowItem.ArrowItem(**opts)
|
||||
self.arrow.setParentItem(self)
|
||||
|
@ -83,8 +83,8 @@ class TickSliderItem(GraphicsWidget):
|
||||
}
|
||||
|
||||
self.setOrientation(orientation)
|
||||
#self.setFrameStyle(QtGui.QFrame.NoFrame | QtGui.QFrame.Plain)
|
||||
#self.setBackgroundRole(QtGui.QPalette.NoRole)
|
||||
#self.setFrameStyle(QtGui.QFrame.Shape.NoFrame | QtGui.QFrame.Shadow.Plain)
|
||||
#self.setBackgroundRole(QtGui.QPalette.ColorRole.NoRole)
|
||||
#self.setMouseTracking(True)
|
||||
|
||||
#def boundingRect(self):
|
||||
@ -214,7 +214,7 @@ class TickSliderItem(GraphicsWidget):
|
||||
self.sigTicksChangeFinished.emit(self)
|
||||
|
||||
def tickClicked(self, tick, ev):
|
||||
if ev.button() == QtCore.Qt.RightButton and tick.removeAllowed:
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton and tick.removeAllowed:
|
||||
self.removeTick(tick)
|
||||
|
||||
def widgetLength(self):
|
||||
@ -231,7 +231,7 @@ class TickSliderItem(GraphicsWidget):
|
||||
#bounds.setLeft(min(-self.tickSize*0.5, bounds.left()))
|
||||
#bounds.setRight(max(self.length + self.tickSize, bounds.right()))
|
||||
#self.setSceneRect(bounds)
|
||||
#self.fitInView(bounds, QtCore.Qt.KeepAspectRatio)
|
||||
#self.fitInView(bounds, QtCore.Qt.AspectRatioMode.KeepAspectRatio)
|
||||
|
||||
def setLength(self, newLen):
|
||||
#private
|
||||
@ -256,18 +256,18 @@ class TickSliderItem(GraphicsWidget):
|
||||
|
||||
#pos = self.mapToScene(ev.pos())
|
||||
|
||||
#if ev.button() == QtCore.Qt.LeftButton and self.allowAdd:
|
||||
#if ev.button() == QtCore.Qt.MouseButton.LeftButton and self.allowAdd:
|
||||
#if pos.x() < 0 or pos.x() > self.length:
|
||||
#return
|
||||
#if pos.y() < 0 or pos.y() > self.tickSize:
|
||||
#return
|
||||
#pos.setX(min(max(pos.x(), 0), self.length))
|
||||
#self.addTick(pos.x()/self.length)
|
||||
#elif ev.button() == QtCore.Qt.RightButton:
|
||||
#elif ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
#self.showMenu(ev)
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.LeftButton and self.allowAdd:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton and self.allowAdd:
|
||||
pos = ev.pos()
|
||||
if pos.x() < 0 or pos.x() > self.length:
|
||||
return
|
||||
@ -275,10 +275,10 @@ class TickSliderItem(GraphicsWidget):
|
||||
return
|
||||
pos.setX(min(max(pos.x(), 0), self.length))
|
||||
self.addTick(pos.x()/self.length)
|
||||
elif ev.button() == QtCore.Qt.RightButton:
|
||||
elif ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
self.showMenu(ev)
|
||||
|
||||
#if ev.button() == QtCore.Qt.RightButton:
|
||||
#if ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
#if self.moving:
|
||||
#ev.accept()
|
||||
#self.setPos(self.startPosition)
|
||||
@ -291,8 +291,8 @@ class TickSliderItem(GraphicsWidget):
|
||||
###remove
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if (not ev.isExit()) and ev.acceptClicks(QtCore.Qt.LeftButton):
|
||||
ev.acceptClicks(QtCore.Qt.RightButton)
|
||||
if (not ev.isExit()) and ev.acceptClicks(QtCore.Qt.MouseButton.LeftButton):
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.RightButton)
|
||||
## show ghost tick
|
||||
#self.currentPen = fn.mkPen(255, 0,0)
|
||||
#else:
|
||||
@ -426,14 +426,14 @@ class GradientEditorItem(TickSliderItem):
|
||||
self.rectSize = 15
|
||||
self.gradRect = QtGui.QGraphicsRectItem(QtCore.QRectF(0, self.rectSize, 100, self.rectSize))
|
||||
self.backgroundRect = QtGui.QGraphicsRectItem(QtCore.QRectF(0, -self.rectSize, 100, self.rectSize))
|
||||
self.backgroundRect.setBrush(QtGui.QBrush(QtCore.Qt.DiagCrossPattern))
|
||||
self.backgroundRect.setBrush(QtGui.QBrush(QtCore.Qt.BrushStyle.DiagCrossPattern))
|
||||
self.colorMode = 'rgb'
|
||||
|
||||
TickSliderItem.__init__(self, *args, **kargs)
|
||||
|
||||
self.colorDialog = QtGui.QColorDialog()
|
||||
self.colorDialog.setOption(QtGui.QColorDialog.ShowAlphaChannel, True)
|
||||
self.colorDialog.setOption(QtGui.QColorDialog.DontUseNativeDialog, True)
|
||||
self.colorDialog.setOption(QtGui.QColorDialog.ColorDialogOption.ShowAlphaChannel, True)
|
||||
self.colorDialog.setOption(QtGui.QColorDialog.ColorDialogOption.DontUseNativeDialog, True)
|
||||
|
||||
self.colorDialog.currentColorChanged.connect(self.currentColorChanged)
|
||||
self.colorDialog.rejected.connect(self.currentColorRejected)
|
||||
@ -615,9 +615,9 @@ class GradientEditorItem(TickSliderItem):
|
||||
|
||||
def tickClicked(self, tick, ev):
|
||||
#private
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
self.raiseColorDialog(tick)
|
||||
elif ev.button() == QtCore.Qt.RightButton:
|
||||
elif ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
self.raiseTickContextMenu(tick, ev)
|
||||
|
||||
def raiseColorDialog(self, tick):
|
||||
@ -906,7 +906,7 @@ class Tick(QtGui.QGraphicsWidget): ## NOTE: Making this a subclass of GraphicsO
|
||||
return self.pg
|
||||
|
||||
def paint(self, p, *args):
|
||||
p.setRenderHints(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHints(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
p.fillPath(self.pg, fn.mkBrush(self.color))
|
||||
|
||||
p.setPen(self.currentPen)
|
||||
@ -914,7 +914,7 @@ class Tick(QtGui.QGraphicsWidget): ## NOTE: Making this a subclass of GraphicsO
|
||||
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if self.movable and ev.button() == QtCore.Qt.LeftButton:
|
||||
if self.movable and ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
if ev.isStart():
|
||||
self.moving = True
|
||||
self.cursorOffset = self.pos() - self.mapToParent(ev.buttonDownPos())
|
||||
@ -935,7 +935,7 @@ class Tick(QtGui.QGraphicsWidget): ## NOTE: Making this a subclass of GraphicsO
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
ev.accept()
|
||||
if ev.button() == QtCore.Qt.RightButton and self.moving:
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton and self.moving:
|
||||
self.setPos(self.startPosition)
|
||||
self.moving = False
|
||||
self.sigMoving.emit(self, self.startPosition)
|
||||
@ -944,9 +944,9 @@ class Tick(QtGui.QGraphicsWidget): ## NOTE: Making this a subclass of GraphicsO
|
||||
self.sigClicked.emit(self, ev)
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if (not ev.isExit()) and ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||
ev.acceptClicks(QtCore.Qt.LeftButton)
|
||||
ev.acceptClicks(QtCore.Qt.RightButton)
|
||||
if (not ev.isExit()) and ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton):
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.LeftButton)
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.RightButton)
|
||||
self.currentPen = self.hoverPen
|
||||
else:
|
||||
self.currentPen = self.pen
|
||||
|
@ -14,7 +14,7 @@ class GradientLegend(UIGraphicsItem):
|
||||
self.size = size
|
||||
self.offset = offset
|
||||
UIGraphicsItem.__init__(self)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.MouseButton.NoButton)
|
||||
self.brush = QtGui.QBrush(QtGui.QColor(200,0,0))
|
||||
self.pen = QtGui.QPen(QtGui.QColor(0,0,0))
|
||||
self.labels = {'max': 1, 'min': 0}
|
||||
@ -57,7 +57,7 @@ class GradientLegend(UIGraphicsItem):
|
||||
labelWidth = 0
|
||||
labelHeight = 0
|
||||
for k in self.labels:
|
||||
b = p.boundingRect(QtCore.QRectF(0, 0, 0, 0), QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter, str(k))
|
||||
b = p.boundingRect(QtCore.QRectF(0, 0, 0, 0), QtCore.Qt.AlignmentFlag.AlignLeft | QtCore.Qt.AlignmentFlag.AlignVCenter, str(k))
|
||||
labelWidth = max(labelWidth, b.width())
|
||||
labelHeight = max(labelHeight, b.height())
|
||||
|
||||
@ -111,4 +111,4 @@ class GradientLegend(UIGraphicsItem):
|
||||
lw = labelWidth
|
||||
for k in self.labels:
|
||||
y = y1 + self.labels[k] * (y2-y1)
|
||||
p.drawText(QtCore.QRectF(tx, y - lh/2, lw, lh), QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter, str(k))
|
||||
p.drawText(QtCore.QRectF(tx, y - lh/2, lw, lh), QtCore.Qt.AlignmentFlag.AlignLeft | QtCore.Qt.AlignmentFlag.AlignVCenter, str(k))
|
||||
|
@ -131,7 +131,7 @@ class GraphItem(GraphicsObject):
|
||||
if self.picture == None:
|
||||
self.generatePicture()
|
||||
if getConfigOption('antialias') is True:
|
||||
p.setRenderHint(p.Antialiasing)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing)
|
||||
self.picture.play(p)
|
||||
|
||||
def boundingRect(self):
|
||||
|
@ -168,7 +168,7 @@ class GraphicsItem(object):
|
||||
p = p.parentItem()
|
||||
if p is None:
|
||||
break
|
||||
if p.flags() & self.ItemClipsChildrenToShape:
|
||||
if p.flags() & self.GraphicsItemFlag.ItemClipsChildrenToShape:
|
||||
parents.append(p)
|
||||
return parents
|
||||
|
||||
@ -447,7 +447,7 @@ class GraphicsItem(object):
|
||||
|
||||
#def itemChange(self, change, value):
|
||||
#ret = self._qtBaseClass.itemChange(self, change, value)
|
||||
#if change == self.ItemParentHasChanged or change == self.ItemSceneHasChanged:
|
||||
#if change == self.GraphicsItemChange.ItemParentHasChanged or change == self.ItemSceneHasChanged:
|
||||
#print "Item scene changed:", self
|
||||
#self.setChildScene(self) ## This is bizarre.
|
||||
#return ret
|
||||
|
@ -26,7 +26,7 @@ class GraphicsLayout(GraphicsWidget):
|
||||
self.itemBorders = {} ## {item1: QtGui.QGraphicsRectItem, ...} border rects
|
||||
self.currentRow = 0
|
||||
self.currentCol = 0
|
||||
self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding))
|
||||
self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding))
|
||||
|
||||
#def resizeEvent(self, ev):
|
||||
#ret = GraphicsWidget.resizeEvent(self, ev)
|
||||
|
@ -14,12 +14,12 @@ class GraphicsObject(GraphicsItem, QtGui.QGraphicsObject):
|
||||
def __init__(self, *args):
|
||||
self.__inform_view_on_changes = True
|
||||
QtGui.QGraphicsObject.__init__(self, *args)
|
||||
self.setFlag(self.ItemSendsGeometryChanges)
|
||||
self.setFlag(self.GraphicsItemFlag.ItemSendsGeometryChanges)
|
||||
GraphicsItem.__init__(self)
|
||||
|
||||
def itemChange(self, change, value):
|
||||
ret = super().itemChange(change, value)
|
||||
if change in [self.ItemParentHasChanged, self.ItemSceneHasChanged]:
|
||||
if change in [self.GraphicsItemChange.ItemParentHasChanged, self.GraphicsItemChange.ItemSceneHasChanged]:
|
||||
self.parentChanged()
|
||||
try:
|
||||
inform_view_on_change = self.__inform_view_on_changes
|
||||
@ -28,12 +28,12 @@ class GraphicsObject(GraphicsItem, QtGui.QGraphicsObject):
|
||||
# (if it was triggered during the gc of the object).
|
||||
pass
|
||||
else:
|
||||
if inform_view_on_change and change in [self.ItemPositionHasChanged, self.ItemTransformHasChanged]:
|
||||
if inform_view_on_change and change in [self.GraphicsItemChange.ItemPositionHasChanged, self.GraphicsItemChange.ItemTransformHasChanged]:
|
||||
self.informViewBoundsChanged()
|
||||
|
||||
## workaround for pyqt bug:
|
||||
## http://www.riverbankcomputing.com/pipermail/pyqt/2012-August/031818.html
|
||||
if QT_LIB in ['PyQt4', 'PyQt5'] and change == self.ItemParentChange and isinstance(ret, QtGui.QGraphicsItem):
|
||||
if QT_LIB == 'PyQt5' and change == self.GraphicsItemChange.ItemParentChange and isinstance(ret, QtGui.QGraphicsItem):
|
||||
ret = sip.cast(ret, QtGui.QGraphicsItem)
|
||||
|
||||
return ret
|
||||
|
@ -17,8 +17,8 @@ class GridItem(UIGraphicsItem):
|
||||
def __init__(self, pen='default', textPen='default'):
|
||||
UIGraphicsItem.__init__(self)
|
||||
#QtGui.QGraphicsItem.__init__(self, *args)
|
||||
#self.setFlag(QtGui.QGraphicsItem.ItemClipsToShape)
|
||||
#self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache)
|
||||
#self.setFlag(QtGui.QGraphicsItem.GraphicsItemFlag.ItemClipsToShape)
|
||||
#self.setCacheMode(QtGui.QGraphicsItem.CacheMode.DeviceCoordinateCache)
|
||||
|
||||
self.opts = {}
|
||||
|
||||
|
@ -159,13 +159,13 @@ class HistogramLUTItem(GraphicsWidget):
|
||||
self.layout.addItem(self.vb, avg[1], 0)
|
||||
self.layout.addItem(self.gradient, avg[2], 0)
|
||||
|
||||
self.gradient.setFlag(self.gradient.ItemStacksBehindParent)
|
||||
self.vb.setFlag(self.gradient.ItemStacksBehindParent)
|
||||
self.gradient.setFlag(self.gradient.GraphicsItemFlag.ItemStacksBehindParent)
|
||||
self.vb.setFlag(self.gradient.GraphicsItemFlag.ItemStacksBehindParent)
|
||||
|
||||
self.gradient.sigGradientChanged.connect(self.gradientChanged)
|
||||
self.vb.sigRangeChanged.connect(self.viewRangeChanged)
|
||||
|
||||
comp = QtGui.QPainter.CompositionMode_Plus
|
||||
comp = QtGui.QPainter.CompositionMode.CompositionMode_Plus
|
||||
self.plots = [
|
||||
PlotCurveItem(pen=(200, 200, 200, 100)), # mono
|
||||
PlotCurveItem(pen=(255, 0, 0, 100), compositionMode=comp), # r
|
||||
@ -239,7 +239,7 @@ class HistogramLUTItem(GraphicsWidget):
|
||||
p2mn = gradRect.bottomLeft()
|
||||
p2mx = gradRect.bottomRight()
|
||||
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
for pen in [fn.mkPen((0, 0, 0, 100), width=3), pen]:
|
||||
p.setPen(pen)
|
||||
|
||||
|
@ -902,7 +902,7 @@ class ImageItem(GraphicsObject):
|
||||
parent items, but its position will be transformed as usual.
|
||||
(see ``GraphicsItem::ItemIgnoresTransformations`` in the Qt documentation)
|
||||
"""
|
||||
self.setFlag(self.ItemIgnoresTransformations, b)
|
||||
self.setFlag(self.GraphicsItemFlag.ItemIgnoresTransformations, b)
|
||||
|
||||
def setScaledMode(self):
|
||||
self.setPxMode(False)
|
||||
@ -949,7 +949,7 @@ class ImageItem(GraphicsObject):
|
||||
return max(1, int(1.0 / w)), max(1, int(1.0 / h))
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if ev.button() != QtCore.Qt.LeftButton:
|
||||
if ev.button() != QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.ignore()
|
||||
return
|
||||
elif self.drawKernel is not None:
|
||||
@ -957,10 +957,10 @@ class ImageItem(GraphicsObject):
|
||||
self.drawAt(ev.pos(), ev)
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.RightButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
if self.raiseContextMenu(ev):
|
||||
ev.accept()
|
||||
if self.drawKernel is not None and ev.button() == QtCore.Qt.LeftButton:
|
||||
if self.drawKernel is not None and ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
self.drawAt(ev.pos(), ev)
|
||||
|
||||
def raiseContextMenu(self, ev):
|
||||
@ -985,11 +985,11 @@ class ImageItem(GraphicsObject):
|
||||
return self.menu
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if not ev.isExit() and self.drawKernel is not None and ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||
ev.acceptClicks(QtCore.Qt.LeftButton) ## we don't use the click, but we also don't want anyone else to use it.
|
||||
ev.acceptClicks(QtCore.Qt.RightButton)
|
||||
if not ev.isExit() and self.drawKernel is not None and ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton):
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.LeftButton) ## we don't use the click, but we also don't want anyone else to use it.
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.RightButton)
|
||||
elif not ev.isExit() and self.removable:
|
||||
ev.acceptClicks(QtCore.Qt.RightButton) ## accept context menu clicks
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.RightButton) ## accept context menu clicks
|
||||
|
||||
def tabletEvent(self, ev):
|
||||
pass
|
||||
|
@ -283,7 +283,7 @@ class InfiniteLine(GraphicsObject):
|
||||
|
||||
## broken in 4.7
|
||||
#def itemChange(self, change, val):
|
||||
#if change in [self.ItemScenePositionHasChanged, self.ItemSceneHasChanged]:
|
||||
#if change in [self.GraphicsItemChange.ItemScenePositionHasChanged, self.GraphicsItemChange.ItemSceneHasChanged]:
|
||||
#self.updateLine()
|
||||
#print "update", change
|
||||
#print self.getBoundingParents()
|
||||
@ -339,11 +339,11 @@ class InfiniteLine(GraphicsObject):
|
||||
return self._boundingRect
|
||||
|
||||
def paint(self, p, *args):
|
||||
p.setRenderHint(p.Antialiasing)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing)
|
||||
|
||||
left, right = self._endPoints
|
||||
pen = self.currentPen
|
||||
pen.setJoinStyle(QtCore.Qt.MiterJoin)
|
||||
pen.setJoinStyle(QtCore.Qt.PenJoinStyle.MiterJoin)
|
||||
p.setPen(pen)
|
||||
p.drawLine(Point(left, 0), Point(right, 0))
|
||||
|
||||
@ -386,7 +386,7 @@ class InfiniteLine(GraphicsObject):
|
||||
return (0,0)
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if self.movable and ev.button() == QtCore.Qt.LeftButton:
|
||||
if self.movable and ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
if ev.isStart():
|
||||
self.moving = True
|
||||
self.cursorOffset = self.pos() - self.mapToParent(ev.buttonDownPos())
|
||||
@ -404,7 +404,7 @@ class InfiniteLine(GraphicsObject):
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
self.sigClicked.emit(self, ev)
|
||||
if self.moving and ev.button() == QtCore.Qt.RightButton:
|
||||
if self.moving and ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
ev.accept()
|
||||
self.setPos(self.startPosition)
|
||||
self.moving = False
|
||||
@ -412,7 +412,7 @@ class InfiniteLine(GraphicsObject):
|
||||
self.sigPositionChangeFinished.emit(self)
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if (not ev.isExit()) and self.movable and ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||
if (not ev.isExit()) and self.movable and ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton):
|
||||
self.setMouseHover(True)
|
||||
else:
|
||||
self.setMouseHover(False)
|
||||
@ -582,7 +582,7 @@ class InfLineLabel(TextItem):
|
||||
self.valueChanged()
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if self.movable and ev.button() == QtCore.Qt.LeftButton:
|
||||
if self.movable and ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
if ev.isStart():
|
||||
self._moving = True
|
||||
self._cursorOffset = self._posToRel(ev.buttonDownPos())
|
||||
@ -599,14 +599,14 @@ class InfLineLabel(TextItem):
|
||||
self._moving = False
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if self.moving and ev.button() == QtCore.Qt.RightButton:
|
||||
if self.moving and ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
ev.accept()
|
||||
self.orthoPos = self._startPosition
|
||||
self.moving = False
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if not ev.isExit() and self.movable:
|
||||
ev.acceptDrags(QtCore.Qt.LeftButton)
|
||||
ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton)
|
||||
|
||||
def viewTransformChanged(self):
|
||||
GraphicsItem.viewTransformChanged(self)
|
||||
|
@ -10,7 +10,7 @@ class ItemGroup(GraphicsObject):
|
||||
def __init__(self, *args):
|
||||
GraphicsObject.__init__(self, *args)
|
||||
if hasattr(self, "ItemHasNoContents"):
|
||||
self.setFlag(self.ItemHasNoContents)
|
||||
self.setFlag(self.GraphicsItemFlag.ItemHasNoContents)
|
||||
|
||||
def boundingRect(self):
|
||||
return QtCore.QRectF()
|
||||
|
@ -119,10 +119,10 @@ class LabelItem(GraphicsWidget, GraphicsWidgetAnchor):
|
||||
self.setMinimumHeight(bounds.height())
|
||||
|
||||
self._sizeHint = {
|
||||
QtCore.Qt.MinimumSize: (bounds.width(), bounds.height()),
|
||||
QtCore.Qt.PreferredSize: (bounds.width(), bounds.height()),
|
||||
QtCore.Qt.MaximumSize: (-1, -1), #bounds.width()*2, bounds.height()*2),
|
||||
QtCore.Qt.MinimumDescent: (0, 0) ##?? what is this?
|
||||
QtCore.Qt.SizeHint.MinimumSize: (bounds.width(), bounds.height()),
|
||||
QtCore.Qt.SizeHint.PreferredSize: (bounds.width(), bounds.height()),
|
||||
QtCore.Qt.SizeHint.MaximumSize: (-1, -1), #bounds.width()*2, bounds.height()*2),
|
||||
QtCore.Qt.SizeHint.MinimumDescent: (0, 0) ##?? what is this?
|
||||
}
|
||||
self.updateGeometry()
|
||||
|
||||
|
@ -65,7 +65,7 @@ class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
|
||||
"""
|
||||
GraphicsWidget.__init__(self)
|
||||
GraphicsWidgetAnchor.__init__(self)
|
||||
self.setFlag(self.ItemIgnoresTransformations)
|
||||
self.setFlag(self.GraphicsItemFlag.ItemIgnoresTransformations)
|
||||
self.layout = QtGui.QGraphicsGridLayout()
|
||||
self.layout.setVerticalSpacing(verSpacing)
|
||||
self.layout.setHorizontalSpacing(horSpacing)
|
||||
@ -326,10 +326,10 @@ class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
|
||||
p.drawRect(self.boundingRect())
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
ev.acceptDrags(QtCore.Qt.LeftButton)
|
||||
ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton)
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
ev.accept()
|
||||
dpos = ev.pos() - ev.lastPos()
|
||||
self.autoAnchor(self.pos() + dpos)
|
||||
@ -349,7 +349,7 @@ class ItemSample(GraphicsWidget):
|
||||
def paint(self, p, *args):
|
||||
opts = self.item.opts
|
||||
if opts.get('antialias'):
|
||||
p.setRenderHint(p.Antialiasing)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing)
|
||||
|
||||
visible = self.item.isVisible()
|
||||
if not visible:
|
||||
@ -384,7 +384,7 @@ class ItemSample(GraphicsWidget):
|
||||
def mouseClickEvent(self, event):
|
||||
"""Use the mouseClick event to toggle the visibility of the plotItem
|
||||
"""
|
||||
if event.button() == QtCore.Qt.LeftButton:
|
||||
if event.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
visible = self.item.isVisible()
|
||||
self.item.setVisible(not visible)
|
||||
|
||||
|
@ -253,7 +253,7 @@ class LinearRegionItem(GraphicsObject):
|
||||
self.sigRegionChangeFinished.emit(self)
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if not self.movable or ev.button() != QtCore.Qt.LeftButton:
|
||||
if not self.movable or ev.button() != QtCore.Qt.MouseButton.LeftButton:
|
||||
return
|
||||
ev.accept()
|
||||
|
||||
@ -279,7 +279,7 @@ class LinearRegionItem(GraphicsObject):
|
||||
self.sigRegionChanged.emit(self)
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if self.moving and ev.button() == QtCore.Qt.RightButton:
|
||||
if self.moving and ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
ev.accept()
|
||||
for i, l in enumerate(self.lines):
|
||||
l.setPos(self.startPositions[i])
|
||||
@ -288,7 +288,7 @@ class LinearRegionItem(GraphicsObject):
|
||||
self.sigRegionChangeFinished.emit(self)
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if self.movable and (not ev.isExit()) and ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||
if self.movable and (not ev.isExit()) and ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton):
|
||||
self.setMouseHover(True)
|
||||
else:
|
||||
self.setMouseHover(False)
|
||||
|
@ -183,7 +183,7 @@ class PColorMeshItem(GraphicsObject):
|
||||
else:
|
||||
p.setPen(fn.mkPen(self.edgecolors))
|
||||
if self.antialiasing:
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
|
||||
|
||||
## Prepare colormap
|
||||
|
@ -51,7 +51,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
self.clear()
|
||||
|
||||
## this is disastrous for performance.
|
||||
#self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache)
|
||||
#self.setCacheMode(QtGui.QGraphicsItem.CacheMode.DeviceCoordinateCache)
|
||||
|
||||
self.metaData = {}
|
||||
self.opts = {
|
||||
@ -99,14 +99,14 @@ class PlotCurveItem(GraphicsObject):
|
||||
|
||||
============================================ ============================================================
|
||||
**Most common arguments:**
|
||||
QtGui.QPainter.CompositionMode_SourceOver Default; image replaces the background if it
|
||||
QtGui.QPainter.CompositionMode.CompositionMode_SourceOver Default; image replaces the background if it
|
||||
is opaque. Otherwise, it uses the alpha channel to blend
|
||||
the image with the background.
|
||||
QtGui.QPainter.CompositionMode_Overlay The image color is mixed with the background color to
|
||||
QtGui.QPainter.CompositionMode.CompositionMode_Overlay The image color is mixed with the background color to
|
||||
reflect the lightness or darkness of the background.
|
||||
QtGui.QPainter.CompositionMode_Plus Both the alpha and color of the image and background pixels
|
||||
QtGui.QPainter.CompositionMode.CompositionMode_Plus Both the alpha and color of the image and background pixels
|
||||
are added together.
|
||||
QtGui.QPainter.CompositionMode_Multiply The output is the image color multiplied by the background.
|
||||
QtGui.QPainter.CompositionMode.CompositionMode_Multiply The output is the image color multiplied by the background.
|
||||
============================================ ============================================================
|
||||
"""
|
||||
self.opts['compositionMode'] = mode
|
||||
@ -178,7 +178,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
spen = self.opts['shadowPen']
|
||||
if not pen.isCosmetic():
|
||||
b = (b[0] - pen.widthF()*0.7072, b[1] + pen.widthF()*0.7072)
|
||||
if spen is not None and not spen.isCosmetic() and spen.style() != QtCore.Qt.NoPen:
|
||||
if spen is not None and not spen.isCosmetic() and spen.style() != QtCore.Qt.PenStyle.NoPen:
|
||||
b = (b[0] - spen.widthF()*0.7072, b[1] + spen.widthF()*0.7072)
|
||||
|
||||
self._boundsCache[ax] = [(frac, orthoRange), b]
|
||||
@ -190,7 +190,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
w = 0
|
||||
if pen.isCosmetic():
|
||||
w += pen.widthF()*0.7072
|
||||
if spen is not None and spen.isCosmetic() and spen.style() != QtCore.Qt.NoPen:
|
||||
if spen is not None and spen.isCosmetic() and spen.style() != QtCore.Qt.PenStyle.NoPen:
|
||||
w = max(w, spen.widthF()*0.7072)
|
||||
if self.clickable:
|
||||
w = max(w, self.opts['mouseWidth']//2 + 1)
|
||||
@ -382,7 +382,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
|
||||
profiler("data checks")
|
||||
|
||||
#self.setCacheMode(QtGui.QGraphicsItem.NoCache) ## Disabling and re-enabling the cache works around a bug in Qt 4.6 causing the cached results to display incorrectly
|
||||
#self.setCacheMode(QtGui.QGraphicsItem.CacheMode.NoCache) ## Disabling and re-enabling the cache works around a bug in Qt 4.6 causing the cached results to display incorrectly
|
||||
## Test this bug with test_PlotWidget and zoom in on the animated plot
|
||||
self.yData = kargs['y'].view(np.ndarray)
|
||||
self.xData = kargs['x'].view(np.ndarray)
|
||||
@ -507,7 +507,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
else:
|
||||
aa = self.opts['antialias']
|
||||
|
||||
p.setRenderHint(p.Antialiasing, aa)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing, aa)
|
||||
|
||||
cmode = self.opts['compositionMode']
|
||||
if cmode is not None:
|
||||
@ -536,7 +536,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
else:
|
||||
sp = fn.mkPen(self.opts['shadowPen'])
|
||||
|
||||
if sp.style() != QtCore.Qt.NoPen:
|
||||
if sp.style() != QtCore.Qt.PenStyle.NoPen:
|
||||
p.setPen(sp)
|
||||
p.drawPath(path)
|
||||
|
||||
@ -643,7 +643,7 @@ class PlotCurveItem(GraphicsObject):
|
||||
return self._mouseShape
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if not self.clickable or ev.button() != QtCore.Qt.LeftButton:
|
||||
if not self.clickable or ev.button() != QtCore.Qt.MouseButton.LeftButton:
|
||||
return
|
||||
if self.mouseShape().contains(ev.pos()):
|
||||
ev.accept()
|
||||
|
@ -155,7 +155,7 @@ class PlotDataItem(GraphicsObject):
|
||||
========== ================================================
|
||||
"""
|
||||
GraphicsObject.__init__(self)
|
||||
self.setFlag(self.ItemHasNoContents)
|
||||
self.setFlag(self.GraphicsItemFlag.ItemHasNoContents)
|
||||
self.xData = None
|
||||
self.yData = None
|
||||
self.xDisp = None
|
||||
|
@ -113,7 +113,7 @@ class PlotItem(GraphicsWidget):
|
||||
|
||||
GraphicsWidget.__init__(self, parent)
|
||||
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)
|
||||
|
||||
## Set up control buttons
|
||||
path = os.path.dirname(__file__)
|
||||
@ -333,11 +333,9 @@ class PlotItem(GraphicsWidget):
|
||||
axis.linkToView(self.vb)
|
||||
self.axes[k] = {'item': axis, 'pos': pos}
|
||||
self.layout.addItem(axis, *pos)
|
||||
# axis.setZValue(-1000)
|
||||
# place axis above images at z=0, items that want to draw over the axes should be placed at z>=1:
|
||||
axis.setZValue(0.5)
|
||||
axis.setFlag(axis.ItemNegativeZStacksBehindParent)
|
||||
|
||||
axis.setFlag(axis.GraphicsItemFlag.ItemNegativeZStacksBehindParent)
|
||||
axisVisible = k in visibleAxes
|
||||
self.showAxis(k, axisVisible)
|
||||
|
||||
@ -428,7 +426,7 @@ class PlotItem(GraphicsWidget):
|
||||
|
||||
def avgParamListClicked(self, item):
|
||||
name = str(item.text())
|
||||
self.paramList[name] = (item.checkState() == QtCore.Qt.Checked)
|
||||
self.paramList[name] = (item.checkState() == QtCore.Qt.CheckState.Checked)
|
||||
self.recomputeAverages()
|
||||
|
||||
def recomputeAverages(self):
|
||||
@ -452,7 +450,7 @@ class PlotItem(GraphicsWidget):
|
||||
### First determine the key of the curve to which this new data should be averaged
|
||||
for i in range(self.ctrl.avgParamList.count()):
|
||||
item = self.ctrl.avgParamList.item(i)
|
||||
if item.checkState() == QtCore.Qt.Checked:
|
||||
if item.checkState() == QtCore.Qt.CheckState.Checked:
|
||||
remKeys.append(str(item.text()))
|
||||
else:
|
||||
addKeys.append(str(item.text()))
|
||||
@ -709,18 +707,18 @@ class PlotItem(GraphicsWidget):
|
||||
p = '.'.join(p)
|
||||
|
||||
## If the parameter is not in the list, add it.
|
||||
matches = self.ctrl.avgParamList.findItems(p, QtCore.Qt.MatchExactly)
|
||||
matches = self.ctrl.avgParamList.findItems(p, QtCore.Qt.MatchFlag.MatchExactly)
|
||||
if len(matches) == 0:
|
||||
i = QtGui.QListWidgetItem(p)
|
||||
if p in self.paramList and self.paramList[p] is True:
|
||||
i.setCheckState(QtCore.Qt.Checked)
|
||||
i.setCheckState(QtCore.Qt.CheckState.Checked)
|
||||
else:
|
||||
i.setCheckState(QtCore.Qt.Unchecked)
|
||||
i.setCheckState(QtCore.Qt.CheckState.Unchecked)
|
||||
self.ctrl.avgParamList.addItem(i)
|
||||
else:
|
||||
i = matches[0]
|
||||
|
||||
self.paramList[p] = (i.checkState() == QtCore.Qt.Checked)
|
||||
self.paramList[p] = (i.checkState() == QtCore.Qt.CheckState.Checked)
|
||||
|
||||
def writeSvgCurves(self, fileName=None):
|
||||
if fileName is None:
|
||||
@ -1304,7 +1302,7 @@ class PlotItem(GraphicsWidget):
|
||||
self.fileDialog = FileDialog()
|
||||
if PlotItem.lastFileDir is not None:
|
||||
self.fileDialog.setDirectory(PlotItem.lastFileDir)
|
||||
self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
|
||||
self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
|
||||
self.fileDialog.setFileMode(QtGui.QFileDialog.FileMode.AnyFile)
|
||||
self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptMode.AcceptSave)
|
||||
self.fileDialog.show()
|
||||
self.fileDialog.fileSelected.connect(handler)
|
||||
|
@ -61,7 +61,7 @@ class Ui_Form(object):
|
||||
self.autoDownsampleCheck.setChecked(True)
|
||||
self.autoDownsampleCheck.setObjectName("autoDownsampleCheck")
|
||||
self.gridLayout_4.addWidget(self.autoDownsampleCheck, 1, 2, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(30, 20, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
spacerItem = QtWidgets.QSpacerItem(30, 20, QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_4.addItem(spacerItem, 2, 0, 1, 1)
|
||||
self.downsampleSpin = QtWidgets.QSpinBox(self.decimateGroup)
|
||||
self.downsampleSpin.setMinimum(1)
|
||||
|
@ -86,7 +86,7 @@ class Ui_Form(object):
|
||||
|
||||
self.gridLayout_4.addWidget(self.autoDownsampleCheck, 1, 2, 1, 1)
|
||||
|
||||
self.horizontalSpacer = QSpacerItem(30, 20, QSizePolicy.Maximum, QSizePolicy.Minimum)
|
||||
self.horizontalSpacer = QSpacerItem(30, 20, QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Minimum)
|
||||
|
||||
self.gridLayout_4.addItem(self.horizontalSpacer, 2, 0, 1, 1)
|
||||
|
||||
@ -161,7 +161,7 @@ class Ui_Form(object):
|
||||
self.gridAlphaSlider.setObjectName(u"gridAlphaSlider")
|
||||
self.gridAlphaSlider.setMaximum(255)
|
||||
self.gridAlphaSlider.setValue(128)
|
||||
self.gridAlphaSlider.setOrientation(Qt.Horizontal)
|
||||
self.gridAlphaSlider.setOrientation(Qt.Orientation.Horizontal)
|
||||
|
||||
self.gridLayout_2.addWidget(self.gridAlphaSlider, 2, 1, 1, 1)
|
||||
|
||||
@ -186,7 +186,7 @@ class Ui_Form(object):
|
||||
self.alphaSlider.setObjectName(u"alphaSlider")
|
||||
self.alphaSlider.setMaximum(1000)
|
||||
self.alphaSlider.setValue(1000)
|
||||
self.alphaSlider.setOrientation(Qt.Horizontal)
|
||||
self.alphaSlider.setOrientation(Qt.Orientation.Horizontal)
|
||||
|
||||
self.horizontalLayout.addWidget(self.alphaSlider)
|
||||
|
||||
|
@ -122,7 +122,7 @@ class ROI(GraphicsObject):
|
||||
Note that clicking is disabled by default to prevent
|
||||
stealing clicks from objects behind the ROI. To
|
||||
enable clicking, call
|
||||
roi.setAcceptedMouseButtons(QtCore.Qt.LeftButton).
|
||||
roi.setAcceptedMouseButtons(QtCore.Qt.MouseButton.LeftButton).
|
||||
See QtGui.QGraphicsItem documentation for more
|
||||
details.
|
||||
sigRemoveRequested Emitted when the user selects 'remove' from the
|
||||
@ -144,7 +144,7 @@ class ROI(GraphicsObject):
|
||||
movable=True, rotatable=True, resizable=True, removable=False,
|
||||
aspectLocked=False):
|
||||
GraphicsObject.__init__(self, parent)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.MouseButton.NoButton)
|
||||
pos = Point(pos)
|
||||
size = Point(size)
|
||||
self.aspectLocked = aspectLocked
|
||||
@ -722,20 +722,20 @@ class ROI(GraphicsObject):
|
||||
def hoverEvent(self, ev):
|
||||
hover = False
|
||||
if not ev.isExit():
|
||||
if self.translatable and ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||
if self.translatable and ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton):
|
||||
hover=True
|
||||
|
||||
for btn in [QtCore.Qt.LeftButton, QtCore.Qt.RightButton, QtCore.Qt.MiddleButton]:
|
||||
for btn in [QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.MouseButton.RightButton, QtCore.Qt.MouseButton.MiddleButton]:
|
||||
if (self.acceptedMouseButtons() & btn) and ev.acceptClicks(btn):
|
||||
hover=True
|
||||
if self.contextMenuEnabled():
|
||||
ev.acceptClicks(QtCore.Qt.RightButton)
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.RightButton)
|
||||
|
||||
if hover:
|
||||
self.setMouseHover(True)
|
||||
ev.acceptClicks(QtCore.Qt.LeftButton) ## If the ROI is hilighted, we should accept all clicks to avoid confusion.
|
||||
ev.acceptClicks(QtCore.Qt.RightButton)
|
||||
ev.acceptClicks(QtCore.Qt.MiddleButton)
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.LeftButton) ## If the ROI is hilighted, we should accept all clicks to avoid confusion.
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.RightButton)
|
||||
ev.acceptClicks(QtCore.Qt.MouseButton.MiddleButton)
|
||||
self.sigHoverEvent.emit(self)
|
||||
else:
|
||||
self.setMouseHover(False)
|
||||
@ -806,10 +806,10 @@ class ROI(GraphicsObject):
|
||||
),
|
||||
category=DeprecationWarning
|
||||
)
|
||||
if ev.button() == QtCore.Qt.RightButton and self.isMoving:
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton and self.isMoving:
|
||||
ev.accept()
|
||||
self.cancelMove()
|
||||
if ev.button() == QtCore.Qt.RightButton and self.contextMenuEnabled():
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton and self.contextMenuEnabled():
|
||||
self.raiseContextMenu(ev)
|
||||
ev.accept()
|
||||
elif ev.button() & self.acceptedMouseButtons():
|
||||
@ -870,7 +870,7 @@ class ROI(GraphicsObject):
|
||||
lp1 = self.mapFromParent(p1) - cs
|
||||
|
||||
if h['type'] == 't':
|
||||
snap = True if (modifiers & QtCore.Qt.ControlModifier) else None
|
||||
snap = True if (modifiers & QtCore.Qt.KeyboardModifier.ControlModifier) else None
|
||||
self.translate(p1-p0, snap=snap, update=False)
|
||||
|
||||
elif h['type'] == 'f':
|
||||
@ -887,12 +887,12 @@ class ROI(GraphicsObject):
|
||||
lp1[1] = 0
|
||||
|
||||
## snap
|
||||
if self.scaleSnap or (modifiers & QtCore.Qt.ControlModifier):
|
||||
if self.scaleSnap or (modifiers & QtCore.Qt.KeyboardModifier.ControlModifier):
|
||||
lp1[0] = round(lp1[0] / self.scaleSnapSize) * self.scaleSnapSize
|
||||
lp1[1] = round(lp1[1] / self.scaleSnapSize) * self.scaleSnapSize
|
||||
|
||||
## preserve aspect ratio (this can override snapping)
|
||||
if h['lockAspect'] or (modifiers & QtCore.Qt.AltModifier):
|
||||
if h['lockAspect'] or (modifiers & QtCore.Qt.KeyboardModifier.AltModifier):
|
||||
#arv = Point(self.preMoveState['size']) -
|
||||
lp1 = lp1.proj(lp0)
|
||||
|
||||
@ -950,7 +950,7 @@ class ROI(GraphicsObject):
|
||||
ang = newState['angle'] - lp0.angle(lp1)
|
||||
if ang is None: ## this should never happen..
|
||||
return
|
||||
if self.rotateSnap or (modifiers & QtCore.Qt.ControlModifier):
|
||||
if self.rotateSnap or (modifiers & QtCore.Qt.KeyboardModifier.ControlModifier):
|
||||
ang = round(ang / self.rotateSnapAngle) * self.rotateSnapAngle
|
||||
|
||||
## create rotation transform
|
||||
@ -986,7 +986,7 @@ class ROI(GraphicsObject):
|
||||
ang = newState['angle'] - lp0.angle(lp1)
|
||||
if ang is None:
|
||||
return
|
||||
if self.rotateSnap or (modifiers & QtCore.Qt.ControlModifier):
|
||||
if self.rotateSnap or (modifiers & QtCore.Qt.KeyboardModifier.ControlModifier):
|
||||
ang = round(ang / self.rotateSnapAngle) * self.rotateSnapAngle
|
||||
|
||||
if self.aspectLocked or h['center'][0] != h['pos'][0]:
|
||||
@ -1087,7 +1087,7 @@ class ROI(GraphicsObject):
|
||||
# Note: don't use self.boundingRect here, because subclasses may need to redefine it.
|
||||
r = QtCore.QRectF(0, 0, self.state['size'][0], self.state['size'][1]).normalized()
|
||||
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
p.setPen(self.currentPen)
|
||||
p.translate(r.left(), r.top())
|
||||
p.scale(r.width(), r.height())
|
||||
@ -1292,7 +1292,7 @@ class ROI(GraphicsObject):
|
||||
if width == 0 or height == 0:
|
||||
return np.empty((width, height), dtype=float)
|
||||
|
||||
im = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32)
|
||||
im = QtGui.QImage(width, height, QtGui.QImage.Format.Format_ARGB32)
|
||||
im.fill(0x0)
|
||||
p = QtGui.QPainter(im)
|
||||
p.setPen(fn.mkPen(None))
|
||||
@ -1372,10 +1372,10 @@ class Handle(UIGraphicsItem):
|
||||
self.menu = self.buildMenu()
|
||||
|
||||
UIGraphicsItem.__init__(self, parent=parent)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.MouseButton.NoButton)
|
||||
self.deletable = deletable
|
||||
if deletable:
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.RightButton)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.MouseButton.RightButton)
|
||||
self.setZValue(11)
|
||||
|
||||
def connectROI(self, roi):
|
||||
@ -1388,9 +1388,9 @@ class Handle(UIGraphicsItem):
|
||||
def setDeletable(self, b):
|
||||
self.deletable = b
|
||||
if b:
|
||||
self.setAcceptedMouseButtons(self.acceptedMouseButtons() | QtCore.Qt.RightButton)
|
||||
self.setAcceptedMouseButtons(self.acceptedMouseButtons() | QtCore.Qt.MouseButton.RightButton)
|
||||
else:
|
||||
self.setAcceptedMouseButtons(self.acceptedMouseButtons() & ~QtCore.Qt.RightButton)
|
||||
self.setAcceptedMouseButtons(self.acceptedMouseButtons() & ~QtCore.Qt.MouseButton.RightButton)
|
||||
|
||||
def removeClicked(self):
|
||||
self.sigRemoveRequested.emit(self)
|
||||
@ -1398,9 +1398,9 @@ class Handle(UIGraphicsItem):
|
||||
def hoverEvent(self, ev):
|
||||
hover = False
|
||||
if not ev.isExit():
|
||||
if ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||
if ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton):
|
||||
hover=True
|
||||
for btn in [QtCore.Qt.LeftButton, QtCore.Qt.RightButton, QtCore.Qt.MiddleButton]:
|
||||
for btn in [QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.MouseButton.RightButton, QtCore.Qt.MouseButton.MiddleButton]:
|
||||
if (self.acceptedMouseButtons() & btn) and ev.acceptClicks(btn):
|
||||
hover=True
|
||||
|
||||
@ -1423,13 +1423,13 @@ class Handle(UIGraphicsItem):
|
||||
category=DeprecationWarning
|
||||
)
|
||||
## right-click cancels drag
|
||||
if ev.button() == QtCore.Qt.RightButton and self.isMoving:
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton and self.isMoving:
|
||||
self.isMoving = False ## prevents any further motion
|
||||
self.movePoint(self.startPos, finish=True)
|
||||
ev.accept()
|
||||
elif ev.button() & self.acceptedMouseButtons():
|
||||
ev.accept()
|
||||
if ev.button() == QtCore.Qt.RightButton and self.deletable:
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton and self.deletable:
|
||||
self.raiseContextMenu(ev)
|
||||
self.sigClicked.emit(self, ev)
|
||||
else:
|
||||
@ -1454,7 +1454,7 @@ class Handle(UIGraphicsItem):
|
||||
menu.popup(QtCore.QPoint(pos.x(), pos.y()))
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if ev.button() != QtCore.Qt.LeftButton:
|
||||
if ev.button() != QtCore.Qt.MouseButton.LeftButton:
|
||||
return
|
||||
ev.accept()
|
||||
|
||||
@ -1515,7 +1515,7 @@ class Handle(UIGraphicsItem):
|
||||
self.path.lineTo(x, y)
|
||||
|
||||
def paint(self, p, opt, widget):
|
||||
p.setRenderHints(p.Antialiasing, True)
|
||||
p.setRenderHints(p.RenderHint.Antialiasing, True)
|
||||
p.setPen(self.currentPen)
|
||||
|
||||
p.drawPath(self.shape())
|
||||
@ -1564,10 +1564,10 @@ class MouseDragHandler(object):
|
||||
self.roi = roi
|
||||
self.dragMode = None
|
||||
self.startState = None
|
||||
self.snapModifier = QtCore.Qt.ControlModifier
|
||||
self.translateModifier = QtCore.Qt.NoModifier
|
||||
self.rotateModifier = QtCore.Qt.AltModifier
|
||||
self.scaleModifier = QtCore.Qt.ShiftModifier
|
||||
self.snapModifier = QtCore.Qt.KeyboardModifier.ControlModifier
|
||||
self.translateModifier = QtCore.Qt.KeyboardModifier.NoModifier
|
||||
self.rotateModifier = QtCore.Qt.KeyboardModifier.AltModifier
|
||||
self.scaleModifier = QtCore.Qt.KeyboardModifier.ShiftModifier
|
||||
self.rotateSpeed = 0.5
|
||||
self.scaleSpeed = 1.01
|
||||
|
||||
@ -1575,7 +1575,7 @@ class MouseDragHandler(object):
|
||||
roi = self.roi
|
||||
|
||||
if ev.isStart():
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
roi.setSelected(True)
|
||||
mods = ev.modifiers() & ~self.snapModifier
|
||||
if roi.translatable and mods == self.translateModifier:
|
||||
@ -1871,7 +1871,7 @@ class EllipseROI(ROI):
|
||||
|
||||
def paint(self, p, opt, widget):
|
||||
r = self.boundingRect()
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
p.setPen(self.currentPen)
|
||||
|
||||
p.scale(r.width(), r.height())## workaround for GL bug
|
||||
@ -1989,7 +1989,7 @@ class PolygonROI(ROI):
|
||||
return [p['item'].pos() for p in self.handles]
|
||||
|
||||
def paint(self, p, *args):
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
p.setPen(self.currentPen)
|
||||
for i in range(len(self.handles)):
|
||||
h1 = self.handles[i]['item'].pos()
|
||||
@ -2103,11 +2103,11 @@ class PolyLineROI(ROI):
|
||||
else:
|
||||
self.segments.insert(index, seg)
|
||||
seg.sigClicked.connect(self.segmentClicked)
|
||||
seg.setAcceptedMouseButtons(QtCore.Qt.LeftButton)
|
||||
seg.setAcceptedMouseButtons(QtCore.Qt.MouseButton.LeftButton)
|
||||
seg.setZValue(self.zValue()+1)
|
||||
for h in seg.handles:
|
||||
h['item'].setDeletable(True)
|
||||
h['item'].setAcceptedMouseButtons(h['item'].acceptedMouseButtons() | QtCore.Qt.LeftButton) ## have these handles take left clicks too, so that handles cannot be added on top of other handles
|
||||
h['item'].setAcceptedMouseButtons(h['item'].acceptedMouseButtons() | QtCore.Qt.MouseButton.LeftButton) ## have these handles take left clicks too, so that handles cannot be added on top of other handles
|
||||
|
||||
def setMouseHover(self, hover):
|
||||
## Inform all the ROI's segments that the mouse is(not) hovering over it
|
||||
@ -2245,7 +2245,7 @@ class LineSegmentROI(ROI):
|
||||
self.movePoint(self.getHandles()[1], p2)
|
||||
|
||||
def paint(self, p, *args):
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
p.setPen(self.currentPen)
|
||||
h1 = self.endpoints[0].pos()
|
||||
h2 = self.endpoints[1].pos()
|
||||
@ -2320,7 +2320,7 @@ class _PolyLineSegment(LineSegmentROI):
|
||||
# accept drags even though we discard them to prevent competition with parent ROI
|
||||
# (unless parent ROI is not movable)
|
||||
if self.parentItem().translatable:
|
||||
ev.acceptDrags(QtCore.Qt.LeftButton)
|
||||
ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton)
|
||||
return LineSegmentROI.hoverEvent(self, ev)
|
||||
|
||||
|
||||
@ -2363,7 +2363,7 @@ class CrosshairROI(ROI):
|
||||
|
||||
def paint(self, p, *args):
|
||||
radius = self.getState()['size'][1]
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
p.setPen(self.currentPen)
|
||||
|
||||
p.drawLine(Point(0, -radius), Point(0, radius))
|
||||
@ -2389,7 +2389,7 @@ class RulerROI(LineSegmentROI):
|
||||
p.resetTransform()
|
||||
|
||||
txt = fn.siFormat(length, suffix='m') + '\n%0.1f deg' % angle
|
||||
p.drawText(QtCore.QRectF(pos.x()-50, pos.y()-50, 100, 100), QtCore.Qt.AlignCenter, txt)
|
||||
p.drawText(QtCore.QRectF(pos.x()-50, pos.y()-50, 100, 100), QtCore.Qt.AlignmentFlag.AlignCenter, txt)
|
||||
|
||||
def boundingRect(self):
|
||||
r = LineSegmentROI.boundingRect(self)
|
||||
@ -2422,7 +2422,7 @@ class TriangleROI(ROI):
|
||||
|
||||
def paint(self, p, *args):
|
||||
r = self.boundingRect()
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
|
||||
p.scale(r.width(), r.height())
|
||||
p.setPen(self.currentPen)
|
||||
p.drawPolygon(self.poly)
|
||||
|
@ -16,8 +16,8 @@ class ScaleBar(GraphicsObject, GraphicsWidgetAnchor):
|
||||
def __init__(self, size, width=5, brush=None, pen=None, suffix='m', offset=None):
|
||||
GraphicsObject.__init__(self)
|
||||
GraphicsWidgetAnchor.__init__(self)
|
||||
self.setFlag(self.ItemHasNoContents)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
|
||||
self.setFlag(self.GraphicsItemFlag.ItemHasNoContents)
|
||||
self.setAcceptedMouseButtons(QtCore.Qt.MouseButton.NoButton)
|
||||
|
||||
if brush is None:
|
||||
brush = getConfigOption('foreground')
|
||||
|
@ -119,11 +119,11 @@ def renderSymbol(symbol, size, pen, brush, device=None):
|
||||
## Render a spot with the given parameters to a pixmap
|
||||
penPxWidth = max(math.ceil(pen.widthF()), 1)
|
||||
if device is None:
|
||||
device = QtGui.QImage(int(size+penPxWidth), int(size+penPxWidth), QtGui.QImage.Format_ARGB32)
|
||||
device = QtGui.QImage(int(size+penPxWidth), int(size+penPxWidth), QtGui.QImage.Format.Format_ARGB32)
|
||||
device.fill(0)
|
||||
p = QtGui.QPainter(device)
|
||||
try:
|
||||
p.setRenderHint(p.Antialiasing)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing)
|
||||
p.translate(device.width()*0.5, device.height()*0.5)
|
||||
drawSymbol(p, symbol, size, pen, brush)
|
||||
finally:
|
||||
@ -1140,7 +1140,7 @@ class ScatterPlotItem(GraphicsObject):
|
||||
|
||||
else:
|
||||
# render each symbol individually
|
||||
p.setRenderHint(p.Antialiasing, aa)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing, aa)
|
||||
|
||||
for pt, style in zip(
|
||||
pts[:, viewMask].T,
|
||||
@ -1164,7 +1164,7 @@ class ScatterPlotItem(GraphicsObject):
|
||||
drawSymbol(p2, *style)
|
||||
p2.end()
|
||||
|
||||
p.setRenderHint(p.Antialiasing, aa)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing, aa)
|
||||
self.picture.play(p)
|
||||
|
||||
def points(self):
|
||||
@ -1224,7 +1224,7 @@ class ScatterPlotItem(GraphicsObject):
|
||||
& (self.data['y'] - h < b))
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.LeftButton:
|
||||
if ev.button() == QtCore.Qt.MouseButton.LeftButton:
|
||||
pts = self.pointsAt(ev.pos())
|
||||
if len(pts) > 0:
|
||||
self.ptsClicked = pts
|
||||
|
@ -247,7 +247,7 @@ class TargetItem(UIGraphicsItem):
|
||||
return dti.map(tr.map(self._path))
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
if not self.movable or int(ev.button() & QtCore.Qt.LeftButton) == 0:
|
||||
if not self.movable or int(ev.button() & QtCore.Qt.MouseButton.LeftButton) == 0:
|
||||
return
|
||||
ev.accept()
|
||||
if ev.isStart():
|
||||
@ -263,7 +263,7 @@ class TargetItem(UIGraphicsItem):
|
||||
self.sigPositionChangeFinished.emit(self)
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if self.moving and ev.button() == QtCore.Qt.RightButton:
|
||||
if self.moving and ev.button() == QtCore.Qt.MouseButton.RightButton:
|
||||
ev.accept()
|
||||
self.moving = False
|
||||
self.sigPositionChanged.emit(self)
|
||||
@ -283,7 +283,7 @@ class TargetItem(UIGraphicsItem):
|
||||
self.update()
|
||||
|
||||
def hoverEvent(self, ev):
|
||||
if self.movable and (not ev.isExit()) and ev.acceptDrags(QtCore.Qt.LeftButton):
|
||||
if self.movable and (not ev.isExit()) and ev.acceptDrags(QtCore.Qt.MouseButton.LeftButton):
|
||||
self.setMouseHover(True)
|
||||
else:
|
||||
self.setMouseHover(False)
|
||||
@ -459,7 +459,7 @@ class TargetLabel(TextItem):
|
||||
|
||||
def mouseDragEvent(self, ev):
|
||||
targetItem = self.parentItem()
|
||||
if not targetItem.movable or int(ev.button() & QtCore.Qt.LeftButton) == 0:
|
||||
if not targetItem.movable or int(ev.button() & QtCore.Qt.MouseButton.LeftButton) == 0:
|
||||
return
|
||||
ev.accept()
|
||||
if ev.isStart():
|
||||
|
@ -171,10 +171,10 @@ class TextItem(GraphicsObject):
|
||||
self.updateTransform()
|
||||
p.setTransform(self.sceneTransform())
|
||||
|
||||
if self.border.style() != QtCore.Qt.NoPen or self.fill.style() != QtCore.Qt.NoBrush:
|
||||
if self.border.style() != QtCore.Qt.PenStyle.NoPen or self.fill.style() != QtCore.Qt.BrushStyle.NoBrush:
|
||||
p.setPen(self.border)
|
||||
p.setBrush(self.fill)
|
||||
p.setRenderHint(p.Antialiasing, True)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing, True)
|
||||
p.drawPolygon(self.textItem.mapToParent(self.textItem.boundingRect()))
|
||||
|
||||
def setVisible(self, v):
|
||||
|
@ -29,7 +29,7 @@ class UIGraphicsItem(GraphicsObject):
|
||||
============== =============================================================================
|
||||
"""
|
||||
GraphicsObject.__init__(self, parent)
|
||||
self.setFlag(self.ItemSendsScenePositionChanges)
|
||||
self.setFlag(self.GraphicsItemFlag.ItemSendsScenePositionChanges)
|
||||
|
||||
if bounds is None:
|
||||
self._bounds = QtCore.QRectF(0, 0, 1, 1)
|
||||
@ -49,10 +49,10 @@ class UIGraphicsItem(GraphicsObject):
|
||||
|
||||
## workaround for pyqt bug:
|
||||
## http://www.riverbankcomputing.com/pipermail/pyqt/2012-August/031818.html
|
||||
if QT_LIB in ['PyQt4', 'PyQt5'] and change == self.ItemParentChange and isinstance(ret, QtGui.QGraphicsItem):
|
||||
if QT_LIB == 'PyQt5' and change == self.GraphicsItemChange.ItemParentChange and isinstance(ret, QtGui.QGraphicsItem):
|
||||
ret = sip.cast(ret, QtGui.QGraphicsItem)
|
||||
|
||||
if change == self.ItemScenePositionHasChanged:
|
||||
if change == self.GraphicsItemChange.ItemScenePositionHasChanged:
|
||||
self.setNewBounds()
|
||||
return ret
|
||||
|
||||
|
@ -56,7 +56,10 @@ class ChildGroup(ItemGroup):
|
||||
|
||||
def itemChange(self, change, value):
|
||||
ret = ItemGroup.itemChange(self, change, value)
|
||||
if change == self.ItemChildAddedChange or change == self.ItemChildRemovedChange:
|
||||
if change in [
|
||||
self.GraphicsItemChange.ItemChildAddedChange,
|
||||
self.GraphicsItemChange.ItemChildRemovedChange,
|
||||
]:
|
||||
try:
|
||||
itemsChangedListeners = self.itemsChangedListeners
|
||||
except AttributeError:
|
||||
@ -177,8 +180,8 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
self.locateGroup = None ## items displayed when using ViewBox.locate(item)
|
||||
|
||||
self.setFlag(self.ItemClipsChildrenToShape)
|
||||
self.setFlag(self.ItemIsFocusable, True) ## so we can receive key presses
|
||||
self.setFlag(self.GraphicsItemFlag.ItemClipsChildrenToShape)
|
||||
self.setFlag(self.GraphicsItemFlag.ItemIsFocusable, True) ## so we can receive key presses
|
||||
|
||||
## childGroup is required so that ViewBox has local coordinates similar to device coordinates.
|
||||
## this is a workaround for a Qt + OpenGL bug that causes improper clipping
|
||||
@ -217,7 +220,7 @@ class ViewBox(GraphicsWidget):
|
||||
self.axHistoryPointer = -1 # pointer into the history. Allows forward/backward movement, not just "undo"
|
||||
|
||||
self.setZValue(-100)
|
||||
self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding))
|
||||
self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding))
|
||||
|
||||
self.setAspectLocked(lockAspect)
|
||||
|
||||
@ -1225,7 +1228,7 @@ class ViewBox(GraphicsWidget):
|
||||
self.sigRangeChangedManually.emit(mask)
|
||||
|
||||
def mouseClickEvent(self, ev):
|
||||
if ev.button() == QtCore.Qt.RightButton and self.menuEnabled():
|
||||
if ev.button() == QtCore.Qt.MouseButton.RightButton and self.menuEnabled():
|
||||
ev.accept()
|
||||
self.raiseContextMenu(ev)
|
||||
|
||||
@ -1257,7 +1260,7 @@ class ViewBox(GraphicsWidget):
|
||||
mask[1-axis] = 0.0
|
||||
|
||||
## Scale or translate based on mouse button
|
||||
if ev.button() in [QtCore.Qt.LeftButton, QtCore.Qt.MiddleButton]:
|
||||
if ev.button() in [QtCore.Qt.MouseButton.LeftButton, QtCore.Qt.MouseButton.MiddleButton]:
|
||||
if self.state['mouseMode'] == ViewBox.RectMode and axis is None:
|
||||
if ev.isFinish(): ## This is the final move in the drag; change the view scale now
|
||||
#print "finish"
|
||||
@ -1282,7 +1285,7 @@ class ViewBox(GraphicsWidget):
|
||||
if x is not None or y is not None:
|
||||
self.translateBy(x=x, y=y)
|
||||
self.sigRangeChangedManually.emit(self.state['mouseEnabled'])
|
||||
elif ev.button() & QtCore.Qt.RightButton:
|
||||
elif ev.button() & QtCore.Qt.MouseButton.RightButton:
|
||||
#print "vb.rightDrag"
|
||||
if self.state['aspectLocked'] is not False:
|
||||
mask[0] = 0
|
||||
@ -1298,7 +1301,7 @@ class ViewBox(GraphicsWidget):
|
||||
x = s[0] if mouseEnabled[0] == 1 else None
|
||||
y = s[1] if mouseEnabled[1] == 1 else None
|
||||
|
||||
center = Point(tr.map(ev.buttonDownPos(QtCore.Qt.RightButton)))
|
||||
center = Point(tr.map(ev.buttonDownPos(QtCore.Qt.MouseButton.RightButton)))
|
||||
self._resetTarget()
|
||||
self.scaleBy(x=x, y=y, center=center)
|
||||
self.sigRangeChangedManually.emit(self.state['mouseEnabled'])
|
||||
@ -1318,7 +1321,7 @@ class ViewBox(GraphicsWidget):
|
||||
self.scaleHistory(-1)
|
||||
elif ev.text() in ['+', '=']:
|
||||
self.scaleHistory(1)
|
||||
elif ev.key() == QtCore.Qt.Key_Backspace:
|
||||
elif ev.key() == QtCore.Qt.Key.Key_Backspace:
|
||||
self.scaleHistory(len(self.axHistory))
|
||||
else:
|
||||
ev.ignore()
|
||||
@ -1421,7 +1424,7 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
itemBounds.append((bounds, useX, useY, pxPad))
|
||||
else:
|
||||
if item.flags() & item.ItemHasNoContents:
|
||||
if item.flags() & item.GraphicsItemFlag.ItemHasNoContents:
|
||||
continue
|
||||
bounds = self.mapFromItemToView(item, item.boundingRect()).boundingRect()
|
||||
itemBounds.append((bounds, True, True, 0))
|
||||
|
@ -30,7 +30,7 @@ class Ui_Form(object):
|
||||
|
||||
self.linkCombo = QComboBox(Form)
|
||||
self.linkCombo.setObjectName(u"linkCombo")
|
||||
self.linkCombo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
|
||||
self.linkCombo.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
|
||||
|
||||
self.gridLayout.addWidget(self.linkCombo, 7, 2, 1, 2)
|
||||
|
||||
|
@ -220,7 +220,7 @@ class ImageView(QtGui.QWidget):
|
||||
self.ui.roiPlot.registerPlot(self.name + '_ROI')
|
||||
self.view.register(self.name)
|
||||
|
||||
self.noRepeatKeys = [QtCore.Qt.Key_Right, QtCore.Qt.Key_Left, QtCore.Qt.Key_Up, QtCore.Qt.Key_Down, QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]
|
||||
self.noRepeatKeys = [QtCore.Qt.Key.Key_Right, QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Up, QtCore.Qt.Key.Key_Down, QtCore.Qt.Key.Key_PageUp, QtCore.Qt.Key.Key_PageDown]
|
||||
|
||||
self.roiClicked() ## initialize roi plot to correct shape / visibility
|
||||
|
||||
@ -435,17 +435,17 @@ class ImageView(QtGui.QWidget):
|
||||
super().keyPressEvent(ev)
|
||||
return
|
||||
|
||||
if ev.key() == QtCore.Qt.Key_Space:
|
||||
if ev.key() == QtCore.Qt.Key.Key_Space:
|
||||
if self.playRate == 0:
|
||||
self.play()
|
||||
else:
|
||||
self.play(0)
|
||||
ev.accept()
|
||||
elif ev.key() == QtCore.Qt.Key_Home:
|
||||
elif ev.key() == QtCore.Qt.Key.Key_Home:
|
||||
self.setCurrentIndex(0)
|
||||
self.play(0)
|
||||
ev.accept()
|
||||
elif ev.key() == QtCore.Qt.Key_End:
|
||||
elif ev.key() == QtCore.Qt.Key.Key_End:
|
||||
self.setCurrentIndex(self.getProcessedImage().shape[0]-1)
|
||||
self.play(0)
|
||||
ev.accept()
|
||||
@ -463,7 +463,7 @@ class ImageView(QtGui.QWidget):
|
||||
super().keyReleaseEvent(ev)
|
||||
return
|
||||
|
||||
if ev.key() in [QtCore.Qt.Key_Space, QtCore.Qt.Key_Home, QtCore.Qt.Key_End]:
|
||||
if ev.key() in [QtCore.Qt.Key.Key_Space, QtCore.Qt.Key.Key_Home, QtCore.Qt.Key.Key_End]:
|
||||
ev.accept()
|
||||
elif ev.key() in self.noRepeatKeys:
|
||||
ev.accept()
|
||||
@ -480,22 +480,22 @@ class ImageView(QtGui.QWidget):
|
||||
def evalKeyState(self):
|
||||
if len(self.keysPressed) == 1:
|
||||
key = list(self.keysPressed.keys())[0]
|
||||
if key == QtCore.Qt.Key_Right:
|
||||
if key == QtCore.Qt.Key.Key_Right:
|
||||
self.play(20)
|
||||
self.jumpFrames(1)
|
||||
self.lastPlayTime = ptime.time() + 0.2 ## 2ms wait before start
|
||||
## This happens *after* jumpFrames, since it might take longer than 2ms
|
||||
elif key == QtCore.Qt.Key_Left:
|
||||
elif key == QtCore.Qt.Key.Key_Left:
|
||||
self.play(-20)
|
||||
self.jumpFrames(-1)
|
||||
self.lastPlayTime = ptime.time() + 0.2
|
||||
elif key == QtCore.Qt.Key_Up:
|
||||
elif key == QtCore.Qt.Key.Key_Up:
|
||||
self.play(-100)
|
||||
elif key == QtCore.Qt.Key_Down:
|
||||
elif key == QtCore.Qt.Key.Key_Down:
|
||||
self.play(100)
|
||||
elif key == QtCore.Qt.Key_PageUp:
|
||||
elif key == QtCore.Qt.Key.Key_PageUp:
|
||||
self.play(-1000)
|
||||
elif key == QtCore.Qt.Key_PageDown:
|
||||
elif key == QtCore.Qt.Key.Key_PageDown:
|
||||
self.play(1000)
|
||||
else:
|
||||
self.play(0)
|
||||
|
@ -28,7 +28,7 @@ class Ui_Form(object):
|
||||
self.gridLayout_3.setObjectName(u"gridLayout_3")
|
||||
self.splitter = QSplitter(Form)
|
||||
self.splitter.setObjectName(u"splitter")
|
||||
self.splitter.setOrientation(Qt.Vertical)
|
||||
self.splitter.setOrientation(Qt.Orientation.Vertical)
|
||||
self.layoutWidget = QWidget(self.splitter)
|
||||
self.layoutWidget.setObjectName(u"layoutWidget")
|
||||
self.gridLayout = QGridLayout(self.layoutWidget)
|
||||
@ -47,7 +47,7 @@ class Ui_Form(object):
|
||||
|
||||
self.roiBtn = QPushButton(self.layoutWidget)
|
||||
self.roiBtn.setObjectName(u"roiBtn")
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(1)
|
||||
sizePolicy.setHeightForWidth(self.roiBtn.sizePolicy().hasHeightForWidth())
|
||||
@ -66,7 +66,7 @@ class Ui_Form(object):
|
||||
self.splitter.addWidget(self.layoutWidget)
|
||||
self.roiPlot = PlotWidget(self.splitter)
|
||||
self.roiPlot.setObjectName(u"roiPlot")
|
||||
sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||
sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
|
||||
sizePolicy1.setHorizontalStretch(0)
|
||||
sizePolicy1.setVerticalStretch(0)
|
||||
sizePolicy1.setHeightForWidth(self.roiPlot.sizePolicy().hasHeightForWidth())
|
||||
@ -125,13 +125,13 @@ class Ui_Form(object):
|
||||
|
||||
self.label_8 = QLabel(self.normGroup)
|
||||
self.label_8.setObjectName(u"label_8")
|
||||
self.label_8.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
|
||||
self.label_8.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)
|
||||
|
||||
self.gridLayout_2.addWidget(self.label_8, 2, 1, 1, 1)
|
||||
|
||||
self.label_9 = QLabel(self.normGroup)
|
||||
self.label_9.setObjectName(u"label_9")
|
||||
self.label_9.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
|
||||
self.label_9.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)
|
||||
|
||||
self.gridLayout_2.addWidget(self.label_9, 2, 3, 1, 1)
|
||||
|
||||
@ -142,7 +142,7 @@ class Ui_Form(object):
|
||||
|
||||
self.label_10 = QLabel(self.normGroup)
|
||||
self.label_10.setObjectName(u"label_10")
|
||||
self.label_10.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
|
||||
self.label_10.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)
|
||||
|
||||
self.gridLayout_2.addWidget(self.label_10, 2, 5, 1, 1)
|
||||
|
||||
|
@ -33,7 +33,7 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
|
||||
|
||||
QtWidgets.QOpenGLWidget.__init__(self, parent)
|
||||
|
||||
self.setFocusPolicy(QtCore.Qt.ClickFocus)
|
||||
self.setFocusPolicy(QtCore.Qt.FocusPolicy.ClickFocus)
|
||||
|
||||
if rotationMethod not in {"euler", "quaternion"}:
|
||||
raise RuntimeError("Rotation method should be either 'euler' or 'quaternion'")
|
||||
@ -53,7 +53,7 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
|
||||
self.reset()
|
||||
self.items = []
|
||||
|
||||
self.noRepeatKeys = [QtCore.Qt.Key_Right, QtCore.Qt.Key_Left, QtCore.Qt.Key_Up, QtCore.Qt.Key_Down, QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]
|
||||
self.noRepeatKeys = [QtCore.Qt.Key.Key_Right, QtCore.Qt.Key.Key_Left, QtCore.Qt.Key.Key_Up, QtCore.Qt.Key.Key_Down, QtCore.Qt.Key.Key_PageUp, QtCore.Qt.Key.Key_PageDown]
|
||||
self.keysPressed = {}
|
||||
self.keyTimer = QtCore.QTimer()
|
||||
self.keyTimer.timeout.connect(self.evalKeyState)
|
||||
@ -437,13 +437,13 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
|
||||
diff = lpos - self.mousePos
|
||||
self.mousePos = lpos
|
||||
|
||||
if ev.buttons() == QtCore.Qt.LeftButton:
|
||||
if (ev.modifiers() & QtCore.Qt.ControlModifier):
|
||||
if ev.buttons() == QtCore.Qt.MouseButton.LeftButton:
|
||||
if (ev.modifiers() & QtCore.Qt.KeyboardModifier.ControlModifier):
|
||||
self.pan(diff.x(), diff.y(), 0, relative='view')
|
||||
else:
|
||||
self.orbit(-diff.x(), diff.y())
|
||||
elif ev.buttons() == QtCore.Qt.MiddleButton:
|
||||
if (ev.modifiers() & QtCore.Qt.ControlModifier):
|
||||
elif ev.buttons() == QtCore.Qt.MouseButton.MiddleButton:
|
||||
if (ev.modifiers() & QtCore.Qt.KeyboardModifier.ControlModifier):
|
||||
self.pan(diff.x(), 0, diff.y(), relative='view-upright')
|
||||
else:
|
||||
self.pan(diff.x(), diff.y(), 0, relative='view-upright')
|
||||
@ -469,7 +469,7 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
|
||||
delta = ev.angleDelta().x()
|
||||
if delta == 0:
|
||||
delta = ev.angleDelta().y()
|
||||
if (ev.modifiers() & QtCore.Qt.ControlModifier):
|
||||
if (ev.modifiers() & QtCore.Qt.KeyboardModifier.ControlModifier):
|
||||
self.opts['fov'] *= 0.999**delta
|
||||
else:
|
||||
self.opts['distance'] *= 0.999**delta
|
||||
@ -498,17 +498,17 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
|
||||
speed = 2.0
|
||||
if len(self.keysPressed) > 0:
|
||||
for key in self.keysPressed:
|
||||
if key == QtCore.Qt.Key_Right:
|
||||
if key == QtCore.Qt.Key.Key_Right:
|
||||
self.orbit(azim=-speed, elev=0)
|
||||
elif key == QtCore.Qt.Key_Left:
|
||||
elif key == QtCore.Qt.Key.Key_Left:
|
||||
self.orbit(azim=speed, elev=0)
|
||||
elif key == QtCore.Qt.Key_Up:
|
||||
elif key == QtCore.Qt.Key.Key_Up:
|
||||
self.orbit(azim=0, elev=-speed)
|
||||
elif key == QtCore.Qt.Key_Down:
|
||||
elif key == QtCore.Qt.Key.Key_Down:
|
||||
self.orbit(azim=0, elev=speed)
|
||||
elif key == QtCore.Qt.Key_PageUp:
|
||||
elif key == QtCore.Qt.Key.Key_PageUp:
|
||||
pass
|
||||
elif key == QtCore.Qt.Key_PageDown:
|
||||
elif key == QtCore.Qt.Key.Key_PageDown:
|
||||
pass
|
||||
self.keyTimer.start(16)
|
||||
else:
|
||||
|
@ -16,7 +16,7 @@ class GLTextItem(GLGraphicsItem):
|
||||
self.setGLOptions(glopts)
|
||||
|
||||
self.pos = np.array([0.0, 0.0, 0.0])
|
||||
self.color = QtCore.Qt.white
|
||||
self.color = QtCore.Qt.GlobalColor.white
|
||||
self.text = ''
|
||||
self.font = QtGui.QFont('Helvetica', 16)
|
||||
|
||||
@ -75,7 +75,7 @@ class GLTextItem(GLGraphicsItem):
|
||||
painter = QtGui.QPainter(self.view())
|
||||
painter.setPen(self.color)
|
||||
painter.setFont(self.font)
|
||||
painter.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing)
|
||||
painter.setRenderHints(QtGui.QPainter.RenderHint.Antialiasing | QtGui.QPainter.RenderHint.TextAntialiasing)
|
||||
painter.drawText(text_pos[0], text_pos[1], self.text)
|
||||
painter.end()
|
||||
|
||||
|
@ -42,17 +42,17 @@ class ParameterItem(QtGui.QTreeWidgetItem):
|
||||
## called when Parameter opts changed
|
||||
opts = self.param.opts
|
||||
|
||||
flags = QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled
|
||||
flags = QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled
|
||||
if opts.get('renamable', False):
|
||||
if opts.get('title', None) is not None:
|
||||
raise Exception("Cannot make parameter with both title != None and renamable == True.")
|
||||
flags |= QtCore.Qt.ItemIsEditable
|
||||
flags |= QtCore.Qt.ItemFlag.ItemIsEditable
|
||||
|
||||
## handle movable / dropEnabled options
|
||||
if opts.get('movable', False):
|
||||
flags |= QtCore.Qt.ItemIsDragEnabled
|
||||
flags |= QtCore.Qt.ItemFlag.ItemIsDragEnabled
|
||||
if opts.get('dropEnabled', False):
|
||||
flags |= QtCore.Qt.ItemIsDropEnabled
|
||||
flags |= QtCore.Qt.ItemFlag.ItemIsDropEnabled
|
||||
self.setFlags(flags)
|
||||
|
||||
|
||||
@ -166,9 +166,9 @@ class ParameterItem(QtGui.QTreeWidgetItem):
|
||||
if QT_LIB == 'PyQt6':
|
||||
# PyQt6 doesn't allow or-ing of different enum types
|
||||
# so we need to take its value property
|
||||
textFlags = QtCore.Qt.TextSingleLine.value
|
||||
textFlags = QtCore.Qt.TextFlag.TextSingleLine.value
|
||||
else:
|
||||
textFlags = QtCore.Qt.TextSingleLine
|
||||
textFlags = QtCore.Qt.TextFlag.TextSingleLine
|
||||
size = fm.size(textFlags, self.text(0))
|
||||
size.setHeight(int(size.height() * 1.35))
|
||||
size.setWidth(int(size.width() * 1.15))
|
||||
|
@ -18,8 +18,8 @@ class ParameterTree(TreeWidget):
|
||||
============== ========================================================
|
||||
"""
|
||||
TreeWidget.__init__(self, parent)
|
||||
self.setVerticalScrollMode(self.ScrollPerPixel)
|
||||
self.setHorizontalScrollMode(self.ScrollPerPixel)
|
||||
self.setVerticalScrollMode(self.ScrollMode.ScrollPerPixel)
|
||||
self.setHorizontalScrollMode(self.ScrollMode.ScrollPerPixel)
|
||||
self.setAnimated(False)
|
||||
self.setColumnCount(2)
|
||||
self.setHeaderLabels(["Parameter", "Value"])
|
||||
|
@ -47,7 +47,7 @@ class WidgetParameterItem(ParameterItem):
|
||||
if self.asSubItem:
|
||||
self.subItem = QtGui.QTreeWidgetItem()
|
||||
self.subItem.depth = self.depth + 1
|
||||
self.subItem.setFlags(QtCore.Qt.NoItemFlags)
|
||||
self.subItem.setFlags(QtCore.Qt.ItemFlag.NoItemFlags)
|
||||
self.addChild(self.subItem)
|
||||
|
||||
self.defaultBtn = QtGui.QPushButton()
|
||||
@ -178,11 +178,11 @@ class WidgetParameterItem(ParameterItem):
|
||||
## filter widget's events
|
||||
## catch TAB to change focus
|
||||
## catch focusOut to hide editor
|
||||
if ev.type() == ev.KeyPress:
|
||||
if ev.key() == QtCore.Qt.Key_Tab:
|
||||
if ev.type() == ev.Type.KeyPress:
|
||||
if ev.key() == QtCore.Qt.Key.Key_Tab:
|
||||
self.focusNext(forward=True)
|
||||
return True ## don't let anyone else see this event
|
||||
elif ev.key() == QtCore.Qt.Key_Backtab:
|
||||
elif ev.key() == QtCore.Qt.Key.Key_Backtab:
|
||||
self.focusNext(forward=False)
|
||||
return True ## don't let anyone else see this event
|
||||
|
||||
@ -256,7 +256,7 @@ class WidgetParameterItem(ParameterItem):
|
||||
def showEditor(self):
|
||||
self.widget.show()
|
||||
self.displayLabel.hide()
|
||||
self.widget.setFocus(QtCore.Qt.OtherFocusReason)
|
||||
self.widget.setFocus(QtCore.Qt.FocusReason.OtherFocusReason)
|
||||
if isinstance(self.widget, SpinBox):
|
||||
self.widget.selectNumber() # select the numerical portion of the text for quick editing
|
||||
|
||||
@ -418,7 +418,7 @@ class GroupParameterItem(ParameterItem):
|
||||
addText = param.opts['addText']
|
||||
if 'addList' in param.opts:
|
||||
self.addWidget = QtGui.QComboBox()
|
||||
self.addWidget.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.addWidget.setSizeAdjustPolicy(QtGui.QComboBox.SizeAdjustPolicy.AdjustToContents)
|
||||
self.updateAddList()
|
||||
self.addWidget.currentIndexChanged.connect(self.addChanged)
|
||||
else:
|
||||
@ -432,7 +432,7 @@ class GroupParameterItem(ParameterItem):
|
||||
l.addStretch()
|
||||
self.addWidgetBox = w
|
||||
self.addItem = QtGui.QTreeWidgetItem([])
|
||||
self.addItem.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
self.addItem.setFlags(QtCore.Qt.ItemFlag.ItemIsEnabled)
|
||||
self.addItem.depth = self.depth + 1
|
||||
ParameterItem.addChild(self, self.addItem)
|
||||
self.addItem.setSizeHint(0, self.addWidgetBox.sizeHint())
|
||||
|
@ -20,9 +20,9 @@ class BusyCursor(object):
|
||||
if QT_LIB == 'PySide':
|
||||
# pass CursorShape rather than QCursor for PySide
|
||||
# see https://bugreports.qt.io/browse/PYSIDE-243
|
||||
QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
|
||||
QtGui.QApplication.setOverrideCursor(QtCore.Qt.CursorShape.WaitCursor)
|
||||
else:
|
||||
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
|
||||
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
|
||||
BusyCursor.active.append(self)
|
||||
self._active = True
|
||||
else:
|
||||
|
@ -23,8 +23,8 @@ class ColorButton(QtGui.QPushButton):
|
||||
QtGui.QPushButton.__init__(self, parent)
|
||||
self.setColor(color)
|
||||
self.colorDialog = QtGui.QColorDialog()
|
||||
self.colorDialog.setOption(QtGui.QColorDialog.ShowAlphaChannel, True)
|
||||
self.colorDialog.setOption(QtGui.QColorDialog.DontUseNativeDialog, True)
|
||||
self.colorDialog.setOption(QtGui.QColorDialog.ColorDialogOption.ShowAlphaChannel, True)
|
||||
self.colorDialog.setOption(QtGui.QColorDialog.ColorDialogOption.DontUseNativeDialog, True)
|
||||
self.colorDialog.currentColorChanged.connect(self.dialogColorChanged)
|
||||
self.colorDialog.rejected.connect(self.colorRejected)
|
||||
self.colorDialog.colorSelected.connect(self.colorSelected)
|
||||
@ -41,7 +41,7 @@ class ColorButton(QtGui.QPushButton):
|
||||
## draw white base, then texture for indicating transparency, then actual color
|
||||
p.setBrush(functions.mkBrush('w'))
|
||||
p.drawRect(rect)
|
||||
p.setBrush(QtGui.QBrush(QtCore.Qt.DiagCrossPattern))
|
||||
p.setBrush(QtGui.QBrush(QtCore.Qt.BrushStyle.DiagCrossPattern))
|
||||
p.drawRect(rect)
|
||||
p.setBrush(functions.mkBrush(self._color))
|
||||
p.drawRect(rect)
|
||||
|
@ -24,7 +24,7 @@ class ComboBox(QtGui.QComboBox):
|
||||
|
||||
#self.value = default
|
||||
if 'darwin' in sys.platform: ## because MacOSX can show names that are wider than the comboBox
|
||||
self.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.setSizeAdjustPolicy(QtGui.QComboBox.SizeAdjustPolicy.AdjustToContents)
|
||||
#self.setMinimumContentsLength(10)
|
||||
self._chosenText = None
|
||||
self._items = OrderedDict()
|
||||
|
@ -21,7 +21,7 @@ class DataTreeWidget(QtGui.QTreeWidget):
|
||||
"""
|
||||
def __init__(self, parent=None, data=None):
|
||||
QtGui.QTreeWidget.__init__(self, parent)
|
||||
self.setVerticalScrollMode(self.ScrollPerPixel)
|
||||
self.setVerticalScrollMode(self.ScrollMode.ScrollPerPixel)
|
||||
self.setData(data)
|
||||
self.setColumnCount(3)
|
||||
self.setHeaderLabels(['key / index', 'type', 'value'])
|
||||
|
@ -11,4 +11,4 @@ class FileDialog(QtGui.QFileDialog):
|
||||
QtGui.QFileDialog.__init__(self, *args)
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
self.setOption(QtGui.QFileDialog.DontUseNativeDialog)
|
||||
self.setOption(QtGui.QFileDialog.Option.DontUseNativeDialog)
|
@ -38,8 +38,8 @@ class GradientWidget(GraphicsView):
|
||||
self.item.sigGradientChangeFinished.connect(self.sigGradientChangeFinished)
|
||||
self.setCentralItem(self.item)
|
||||
self.setOrientation(orientation)
|
||||
self.setCacheMode(self.CacheNone)
|
||||
self.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing)
|
||||
self.setCacheMode(self.CacheModeFlag.CacheNone)
|
||||
self.setRenderHints(QtGui.QPainter.RenderHint.Antialiasing | QtGui.QPainter.RenderHint.TextAntialiasing)
|
||||
|
||||
if QT_LIB == 'PyQt6':
|
||||
# PyQt6 doesn't allow or-ing of different enum types
|
||||
@ -47,16 +47,16 @@ class GradientWidget(GraphicsView):
|
||||
NoFrame = QtWidgets.QFrame.Shape.NoFrame.value
|
||||
Plain = QtWidgets.QFrame.Shadow.Plain.value
|
||||
else:
|
||||
NoFrame = QtWidgets.QFrame.NoFrame
|
||||
Plain = QtWidgets.QFrame.Plain
|
||||
NoFrame = QtWidgets.QFrame.Shape.NoFrame
|
||||
Plain = QtWidgets.QFrame.Shadow.Plain
|
||||
frame_style = NoFrame | Plain
|
||||
|
||||
self.setFrameStyle(frame_style)
|
||||
#self.setBackgroundRole(QtGui.QPalette.NoRole)
|
||||
#self.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.NoBrush))
|
||||
#self.setBackgroundRole(QtGui.QPalette.ColorRole.NoRole)
|
||||
#self.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.BrushStyle.NoBrush))
|
||||
#self.setAutoFillBackground(False)
|
||||
#self.setAttribute(QtCore.Qt.WA_PaintOnScreen, False)
|
||||
#self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, True)
|
||||
#self.setAttribute(QtCore.Qt.WindowType.WindowType.WidgetAttribute.WA_PaintOnScreen, False)
|
||||
#self.setAttribute(QtCore.Qt.WindowType.WindowType.WidgetAttribute.WA_OpaquePaintEvent, True)
|
||||
|
||||
def setOrientation(self, ort):
|
||||
"""Set the orientation of the widget. May be one of 'bottom', 'top',
|
||||
|
@ -73,22 +73,21 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
useOpenGL = getConfigOption('useOpenGL')
|
||||
|
||||
self.useOpenGL(useOpenGL)
|
||||
|
||||
self.setCacheMode(self.CacheBackground)
|
||||
self.setCacheMode(self.CacheModeFlag.CacheBackground)
|
||||
|
||||
## This might help, but it's probably dangerous in the general case..
|
||||
#self.setOptimizationFlag(self.DontSavePainterState, True)
|
||||
|
||||
self.setBackgroundRole(QtGui.QPalette.NoRole)
|
||||
self.setBackgroundRole(QtGui.QPalette.ColorRole.NoRole)
|
||||
self.setBackground(background)
|
||||
|
||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
self.setFrameShape(QtGui.QFrame.NoFrame)
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.setTransformationAnchor(QtGui.QGraphicsView.NoAnchor)
|
||||
self.setResizeAnchor(QtGui.QGraphicsView.AnchorViewCenter)
|
||||
self.setViewportUpdateMode(QtGui.QGraphicsView.MinimalViewportUpdate)
|
||||
self.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus)
|
||||
self.setFrameShape(QtGui.QFrame.Shape.NoFrame)
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
self.setTransformationAnchor(QtGui.QGraphicsView.ViewportAnchor.NoAnchor)
|
||||
self.setResizeAnchor(QtGui.QGraphicsView.ViewportAnchor.AnchorViewCenter)
|
||||
self.setViewportUpdateMode(QtGui.QGraphicsView.ViewportUpdateMode.MinimalViewportUpdate)
|
||||
|
||||
|
||||
self.lockedViewports = []
|
||||
@ -124,9 +123,9 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
"""Enable or disable default antialiasing.
|
||||
Note that this will only affect items that do not specify their own antialiasing options."""
|
||||
if aa:
|
||||
self.setRenderHints(self.renderHints() | QtGui.QPainter.Antialiasing)
|
||||
self.setRenderHints(self.renderHints() | QtGui.QPainter.RenderHint.Antialiasing)
|
||||
else:
|
||||
self.setRenderHints(self.renderHints() & ~QtGui.QPainter.Antialiasing)
|
||||
self.setRenderHints(self.renderHints() & ~QtGui.QPainter.RenderHint.Antialiasing)
|
||||
|
||||
def setBackground(self, background):
|
||||
"""
|
||||
@ -216,9 +215,9 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
self.resetTransform()
|
||||
else:
|
||||
if self.aspectLocked:
|
||||
self.fitInView(self.range, QtCore.Qt.KeepAspectRatio)
|
||||
self.fitInView(self.range, QtCore.Qt.AspectRatioMode.KeepAspectRatio)
|
||||
else:
|
||||
self.fitInView(self.range, QtCore.Qt.IgnoreAspectRatio)
|
||||
self.fitInView(self.range, QtCore.Qt.AspectRatioMode.IgnoreAspectRatio)
|
||||
|
||||
if propagate:
|
||||
for v in self.lockedViewports:
|
||||
@ -374,13 +373,13 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
if self.clickAccepted: ## Ignore event if an item in the scene has already claimed it.
|
||||
return
|
||||
|
||||
if ev.buttons() == QtCore.Qt.RightButton:
|
||||
if ev.buttons() == QtCore.Qt.MouseButton.RightButton:
|
||||
delta = Point(fn.clip_scalar(delta[0], -50, 50), fn.clip_scalar(-delta[1], -50, 50))
|
||||
scale = 1.01 ** delta
|
||||
self.scale(scale[0], scale[1], center=self.mapToScene(self.mousePressPos))
|
||||
self.sigDeviceRangeChanged.emit(self, self.range)
|
||||
|
||||
elif ev.buttons() in [QtCore.Qt.MiddleButton, QtCore.Qt.LeftButton]: ## Allow panning by left or mid button.
|
||||
elif ev.buttons() in [QtCore.Qt.MouseButton.MiddleButton, QtCore.Qt.MouseButton.LeftButton]: ## Allow panning by left or mid button.
|
||||
px = self.pixelSize()
|
||||
tr = -delta * px
|
||||
|
||||
|
@ -55,7 +55,7 @@ class GroupBox(QtGui.QGroupBox):
|
||||
|
||||
if c is True:
|
||||
self.collapseBtn.setPath(self.closePath)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred, closing=True)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Policy.Preferred, QtGui.QSizePolicy.Policy.Preferred, closing=True)
|
||||
elif c is False:
|
||||
self.collapseBtn.setPath(self.openPath)
|
||||
self.setSizePolicy(self._lastSizePolicy)
|
||||
|
@ -25,10 +25,10 @@ class HistogramLUTWidget(GraphicsView):
|
||||
|
||||
self.orientation = kargs.get('orientation', 'vertical')
|
||||
if self.orientation == 'vertical':
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Policy.Preferred, QtGui.QSizePolicy.Policy.Expanding)
|
||||
self.setMinimumWidth(95)
|
||||
else:
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Preferred)
|
||||
self.setMinimumHeight(95)
|
||||
|
||||
def sizeHint(self):
|
||||
|
@ -21,8 +21,8 @@ class MultiPlotWidget(GraphicsView):
|
||||
## Explicitly wrap methods from mPlotItem
|
||||
#for m in ['setData']:
|
||||
#setattr(self, m, getattr(self.mPlotItem, m))
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
||||
|
||||
def __getattr__(self, attr): ## implicitly wrap methods from plotItem
|
||||
if hasattr(self.mPlotItem, attr):
|
||||
|
@ -39,7 +39,7 @@ class PathButton(QtGui.QPushButton):
|
||||
scale = min(geom.width() / float(rect.width()), geom.height() / float(rect.height()))
|
||||
|
||||
p = QtGui.QPainter(self)
|
||||
p.setRenderHint(p.Antialiasing)
|
||||
p.setRenderHint(p.RenderHint.Antialiasing)
|
||||
p.translate(geom.center())
|
||||
p.scale(scale, scale)
|
||||
p.translate(-rect.center())
|
||||
|
@ -50,7 +50,7 @@ class PlotWidget(GraphicsView):
|
||||
and all others are passed
|
||||
to :func:`PlotItem.__init__() <pyqtgraph.PlotItem.__init__>`."""
|
||||
GraphicsView.__init__(self, parent, background=background)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)
|
||||
self.enableMouse(False)
|
||||
if plotItem is None:
|
||||
self.plotItem = PlotItem(**kargs)
|
||||
|
@ -73,7 +73,7 @@ class ProgressDialog(QtGui.QProgressDialog):
|
||||
else:
|
||||
self.setMinimumDuration(wait)
|
||||
|
||||
self.setWindowModality(QtCore.Qt.WindowModal)
|
||||
self.setWindowModality(QtCore.Qt.WindowType.WindowModality.WindowModal)
|
||||
self.setValue(self.minimum())
|
||||
if noCancel:
|
||||
self.setCancelButton(None)
|
||||
@ -82,7 +82,7 @@ class ProgressDialog(QtGui.QProgressDialog):
|
||||
if self.disabled:
|
||||
return self
|
||||
if self.busyCursor:
|
||||
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor))
|
||||
QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
|
||||
|
||||
if self.nested and len(ProgressDialog.allDialogs) > 0:
|
||||
topDialog = ProgressDialog.allDialogs[0]
|
||||
@ -206,7 +206,7 @@ class ProgressDialog(QtGui.QProgressDialog):
|
||||
|
||||
# Qt docs say this should happen automatically, but that doesn't seem
|
||||
# to be the case.
|
||||
if self.windowModality() == QtCore.Qt.WindowModal:
|
||||
if self.windowModality() == QtCore.Qt.WindowType.WindowModality.WindowModal:
|
||||
now = ptime.time()
|
||||
if self._lastProcessEvents is None or (now - self._lastProcessEvents) > 0.2:
|
||||
QtGui.QApplication.processEvents()
|
||||
@ -259,7 +259,7 @@ class ProgressWidget(QtGui.QWidget):
|
||||
self.layout.addWidget(bar)
|
||||
|
||||
def eventFilter(self, obj, ev):
|
||||
return ev.type() == QtCore.QEvent.Paint
|
||||
return ev.type() == QtCore.QEvent.Type.Paint
|
||||
|
||||
def hide(self):
|
||||
# hide label and bar, but continue occupying the same space in the layout
|
||||
|
@ -32,7 +32,7 @@ class RawImageWidget(QtGui.QWidget):
|
||||
This also greatly reduces the speed at which it will draw frames.
|
||||
"""
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding))
|
||||
self.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding))
|
||||
self.scaled = scaled
|
||||
self.opts = None
|
||||
self.image = None
|
||||
|
@ -42,8 +42,8 @@ class RemoteGraphicsView(QtGui.QWidget):
|
||||
self._view = rpgRemote.Renderer(*args, **remoteKwds)
|
||||
self._view._setProxyOptions(deferGetattr=True)
|
||||
|
||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
|
||||
self.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Expanding)
|
||||
self.setMouseTracking(True)
|
||||
self.shm = None
|
||||
shmFileName = self._view.shmFileName()
|
||||
|
@ -37,11 +37,11 @@ class ScatterPlotWidget(QtGui.QSplitter):
|
||||
sigScatterPlotHovered = QtCore.Signal(object, object, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QSplitter.__init__(self, QtCore.Qt.Horizontal)
|
||||
self.ctrlPanel = QtGui.QSplitter(QtCore.Qt.Vertical)
|
||||
QtGui.QSplitter.__init__(self, QtCore.Qt.Orientation.Horizontal)
|
||||
self.ctrlPanel = QtGui.QSplitter(QtCore.Qt.Orientation.Vertical)
|
||||
self.addWidget(self.ctrlPanel)
|
||||
self.fieldList = QtGui.QListWidget()
|
||||
self.fieldList.setSelectionMode(self.fieldList.ExtendedSelection)
|
||||
self.fieldList.setSelectionMode(self.fieldList.SelectionMode.ExtendedSelection)
|
||||
self.ptree = ptree.ParameterTree(showHeader=False)
|
||||
self.filter = DataFilterParameter()
|
||||
self.colorMap = ColorMapParameter()
|
||||
|
@ -66,7 +66,7 @@ class SpinBox(QtGui.QAbstractSpinBox):
|
||||
self.setMinimumWidth(0)
|
||||
self._lastFontHeight = None
|
||||
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Policy.Expanding, QtGui.QSizePolicy.Policy.Preferred)
|
||||
self.errorBox = ErrorBox(self.lineEdit())
|
||||
|
||||
self.opts = {
|
||||
@ -104,7 +104,7 @@ class SpinBox(QtGui.QAbstractSpinBox):
|
||||
self.val = D(asUnicode(value)) ## Value is precise decimal. Ordinary math not allowed.
|
||||
self.updateText()
|
||||
self.skipValidate = False
|
||||
self.setCorrectionMode(self.CorrectToPreviousValue)
|
||||
self.setCorrectionMode(self.CorrectionMode.CorrectToPreviousValue)
|
||||
self.setKeyboardTracking(False)
|
||||
self.proxy = SignalProxy(self.sigValueChanging, slot=self.delayedChange, delay=self.opts['delay'])
|
||||
self.setOpts(**kwargs)
|
||||
@ -394,7 +394,7 @@ class SpinBox(QtGui.QAbstractSpinBox):
|
||||
return QtCore.QSize(120, 0)
|
||||
|
||||
def stepEnabled(self):
|
||||
return self.StepUpEnabled | self.StepDownEnabled
|
||||
return self.StepEnabledFlag.StepUpEnabled | self.StepEnabledFlag.StepDownEnabled
|
||||
|
||||
def stepBy(self, n):
|
||||
if isinf(self.val) or isnan(self.val):
|
||||
@ -478,29 +478,29 @@ class SpinBox(QtGui.QAbstractSpinBox):
|
||||
|
||||
def validate(self, strn, pos):
|
||||
if self.skipValidate:
|
||||
ret = QtGui.QValidator.Acceptable
|
||||
ret = QtGui.QValidator.State.Acceptable
|
||||
else:
|
||||
try:
|
||||
val = self.interpret()
|
||||
if val is False:
|
||||
ret = QtGui.QValidator.Intermediate
|
||||
ret = QtGui.QValidator.State.Intermediate
|
||||
else:
|
||||
if self.valueInRange(val):
|
||||
if not self.opts['delayUntilEditFinished']:
|
||||
self.setValue(val, update=False)
|
||||
ret = QtGui.QValidator.Acceptable
|
||||
ret = QtGui.QValidator.State.Acceptable
|
||||
else:
|
||||
ret = QtGui.QValidator.Intermediate
|
||||
ret = QtGui.QValidator.State.Intermediate
|
||||
|
||||
except:
|
||||
import sys
|
||||
sys.excepthook(*sys.exc_info())
|
||||
ret = QtGui.QValidator.Intermediate
|
||||
ret = QtGui.QValidator.State.Intermediate
|
||||
|
||||
## draw / clear border
|
||||
if ret == QtGui.QValidator.Intermediate:
|
||||
if ret == QtGui.QValidator.State.Intermediate:
|
||||
self.textValid = False
|
||||
elif ret == QtGui.QValidator.Acceptable:
|
||||
elif ret == QtGui.QValidator.State.Acceptable:
|
||||
self.textValid = True
|
||||
## note: if text is invalid, we don't change the textValid flag
|
||||
## since the text will be forced to its previous state anyway
|
||||
@ -600,12 +600,12 @@ class ErrorBox(QtGui.QWidget):
|
||||
def __init__(self, parent):
|
||||
QtGui.QWidget.__init__(self, parent)
|
||||
parent.installEventFilter(self)
|
||||
self.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
|
||||
self.setAttribute(QtCore.Qt.WidgetAttribute.WA_TransparentForMouseEvents)
|
||||
self._resize()
|
||||
self.setVisible(False)
|
||||
|
||||
def eventFilter(self, obj, ev):
|
||||
if ev.type() == QtCore.QEvent.Resize:
|
||||
if ev.type() == QtCore.QEvent.Type.Resize:
|
||||
self._resize()
|
||||
return False
|
||||
|
||||
|
@ -54,9 +54,9 @@ class TableWidget(QtGui.QTableWidget):
|
||||
|
||||
self.itemClass = TableWidgetItem
|
||||
|
||||
self.setVerticalScrollMode(self.ScrollPerPixel)
|
||||
self.setSelectionMode(QtGui.QAbstractItemView.ContiguousSelection)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
|
||||
self.setVerticalScrollMode(self.ScrollMode.ScrollPerPixel)
|
||||
self.setSelectionMode(QtGui.QAbstractItemView.SelectionMode.ContiguousSelection)
|
||||
self.setSizePolicy(QtGui.QSizePolicy.Policy.Preferred, QtGui.QSizePolicy.Policy.Preferred)
|
||||
self.clear()
|
||||
|
||||
kwds.setdefault('sortable', True)
|
||||
@ -149,7 +149,7 @@ class TableWidget(QtGui.QTableWidget):
|
||||
|
||||
if (self._sorting and self.horizontalHeadersSet and
|
||||
self.horizontalHeader().sortIndicatorSection() >= self.columnCount()):
|
||||
self.sortByColumn(0, QtCore.Qt.AscendingOrder)
|
||||
self.sortByColumn(0, QtCore.Qt.SortOrder.AscendingOrder)
|
||||
|
||||
def setEditable(self, editable=True):
|
||||
self.editable = editable
|
||||
@ -368,7 +368,7 @@ class TableWidget(QtGui.QTableWidget):
|
||||
self.contextMenu.popup(ev.globalPos())
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.matches(QtGui.QKeySequence.Copy):
|
||||
if ev.matches(QtGui.QKeySequence.StandardKey.Copy):
|
||||
ev.accept()
|
||||
self.copySel()
|
||||
else:
|
||||
@ -386,7 +386,7 @@ class TableWidgetItem(QtGui.QTableWidgetItem):
|
||||
self._defaultFormat = '%0.3g'
|
||||
self.sortMode = 'value'
|
||||
self.index = index
|
||||
flags = QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled
|
||||
flags = QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled
|
||||
self.setFlags(flags)
|
||||
self.setValue(val)
|
||||
self.setFormat(format)
|
||||
@ -396,9 +396,9 @@ class TableWidgetItem(QtGui.QTableWidgetItem):
|
||||
Set whether this item is user-editable.
|
||||
"""
|
||||
if editable:
|
||||
self.setFlags(self.flags() | QtCore.Qt.ItemIsEditable)
|
||||
self.setFlags(self.flags() | QtCore.Qt.ItemFlag.ItemIsEditable)
|
||||
else:
|
||||
self.setFlags(self.flags() & ~QtCore.Qt.ItemIsEditable)
|
||||
self.setFlags(self.flags() & ~QtCore.Qt.ItemFlag.ItemIsEditable)
|
||||
|
||||
def setSortMode(self, mode):
|
||||
"""
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user