call super() on virtual QWidget methods
This commit is contained in:
parent
0fa4557ad6
commit
607db15949
@ -152,7 +152,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
self._moveDistance = d
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
QtGui.QGraphicsScene.mousePressEvent(self, ev)
|
||||
super().mousePressEvent(ev)
|
||||
if self.mouseGrabberItem() is None: ## nobody claimed press; we are free to generate drag/click events
|
||||
if self.lastHoverEvent is not None:
|
||||
# If the mouse has moved since the last hover event, send a new one.
|
||||
@ -191,12 +191,12 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
self.sigMouseMoved.emit(ev.scenePos())
|
||||
|
||||
# First allow QGraphicsScene to eliver hoverEvent/Move/Exit Events
|
||||
QtGui.QGraphicsScene.mouseMoveEvent(self, ev)
|
||||
super().mouseMoveEvent(ev)
|
||||
# Next Deliver our own Hover Events
|
||||
self.sendHoverEvents(ev)
|
||||
if ev.buttons():
|
||||
# button is pressed' send mouseMoveEvents and mouseDragEvents
|
||||
QtGui.QGraphicsScene.mouseMoveEvent(self, ev)
|
||||
super().mouseMoveEvent(ev)
|
||||
if self.mouseGrabberItem() is None:
|
||||
now = ptime.time()
|
||||
init = False
|
||||
@ -219,7 +219,7 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
ev.accept()
|
||||
|
||||
else:
|
||||
QtGui.QGraphicsScene.mouseMoveEvent(self, ev)
|
||||
super().mouseMoveEvent(ev)
|
||||
# if you do not accept event (which is ignored) then cursor will disappear
|
||||
ev.accept()
|
||||
|
||||
@ -247,12 +247,12 @@ class GraphicsScene(QtGui.QGraphicsScene):
|
||||
self.dragButtons = []
|
||||
self.clickEvents = []
|
||||
self.lastDrag = None
|
||||
QtGui.QGraphicsScene.mouseReleaseEvent(self, ev)
|
||||
super().mouseReleaseEvent(ev)
|
||||
|
||||
self.sendHoverEvents(ev) ## let items prepare for next click/drag
|
||||
|
||||
def mouseDoubleClickEvent(self, ev):
|
||||
QtGui.QGraphicsScene.mouseDoubleClickEvent(self, ev)
|
||||
super().mouseDoubleClickEvent(ev)
|
||||
if self.mouseGrabberItem() is None: ## nobody claimed press; we are free to generate drag/click events
|
||||
self.clickEvents.append(MouseClickEvent(ev, double=True))
|
||||
|
||||
|
@ -140,4 +140,4 @@ class ExportDialog(QtGui.QWidget):
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.close()
|
||||
QtGui.QWidget.closeEvent(self, event)
|
||||
super().closeEvent(event)
|
||||
|
@ -107,7 +107,7 @@ class Canvas(QtGui.QWidget):
|
||||
|
||||
def resizeEvent(self, ev=None):
|
||||
if ev is not None:
|
||||
QtGui.QWidget.resizeEvent(self, ev)
|
||||
super().resizeEvent(ev)
|
||||
self.hideBtn.move(self.ui.view.size().width() - self.hideBtn.width(), 0)
|
||||
|
||||
if not self.sizeApplied:
|
||||
|
@ -24,7 +24,7 @@ class CmdInput(QtGui.QLineEdit):
|
||||
elif ev.key() == QtCore.Qt.Key_Return:
|
||||
self.execCmd()
|
||||
else:
|
||||
QtGui.QLineEdit.keyPressEvent(self, ev)
|
||||
super().keyPressEvent(ev)
|
||||
self.history[0] = asUnicode(self.text())
|
||||
|
||||
def execCmd(self):
|
||||
|
@ -382,4 +382,4 @@ class TempAreaWindow(QtGui.QWidget):
|
||||
dock.orig_area.addDock(dock, )
|
||||
# clear dock area, and close remaining docks
|
||||
self.dockarea.clear()
|
||||
QtGui.QWidget.closeEvent(self, *args)
|
||||
super().closeEvent(*args)
|
||||
|
@ -104,7 +104,7 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
||||
|
||||
def paint(self, p, *args):
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
QtGui.QGraphicsPathItem.paint(self, p, *args)
|
||||
super().paint(p, *args)
|
||||
|
||||
#p.setPen(fn.mkPen('r'))
|
||||
#p.setBrush(fn.mkBrush(None))
|
||||
|
@ -18,7 +18,7 @@ class GraphicsObject(GraphicsItem, QtGui.QGraphicsObject):
|
||||
GraphicsItem.__init__(self)
|
||||
|
||||
def itemChange(self, change, value):
|
||||
ret = QtGui.QGraphicsObject.itemChange(self, change, value)
|
||||
ret = super().itemChange(change, value)
|
||||
if change in [self.ItemParentHasChanged, self.ItemSceneHasChanged]:
|
||||
self.parentChanged()
|
||||
try:
|
||||
|
@ -450,7 +450,7 @@ class ImageView(QtGui.QWidget):
|
||||
self.keysPressed[ev.key()] = 1
|
||||
self.evalKeyState()
|
||||
else:
|
||||
QtGui.QWidget.keyPressEvent(self, ev)
|
||||
super().keyPressEvent(ev)
|
||||
|
||||
def keyReleaseEvent(self, ev):
|
||||
if ev.key() in [QtCore.Qt.Key_Space, QtCore.Qt.Key_Home, QtCore.Qt.Key_End]:
|
||||
@ -465,7 +465,7 @@ class ImageView(QtGui.QWidget):
|
||||
self.keysPressed = {}
|
||||
self.evalKeyState()
|
||||
else:
|
||||
QtGui.QWidget.keyReleaseEvent(self, ev)
|
||||
super().keyReleaseEvent(ev)
|
||||
|
||||
def evalKeyState(self):
|
||||
if len(self.keysPressed) == 1:
|
||||
|
@ -157,8 +157,8 @@ class ParameterTree(TreeWidget):
|
||||
self.lastSel = sel[0]
|
||||
if hasattr(sel[0], 'selected'):
|
||||
sel[0].selected(True)
|
||||
return TreeWidget.selectionChanged(self, *args)
|
||||
return super().selectionChanged(*args)
|
||||
|
||||
def wheelEvent(self, ev):
|
||||
self.clearSelection()
|
||||
return TreeWidget.wheelEvent(self, ev)
|
||||
return super().wheelEvent(ev)
|
||||
|
@ -35,7 +35,7 @@ class ColorButton(QtGui.QPushButton):
|
||||
self.setMinimumWidth(15)
|
||||
|
||||
def paintEvent(self, ev):
|
||||
QtGui.QPushButton.paintEvent(self, ev)
|
||||
super().paintEvent(ev)
|
||||
p = QtGui.QPainter(self)
|
||||
rect = self.rect().adjusted(6, 6, -6, -6)
|
||||
## draw white base, then texture for indicating transparency, then actual color
|
||||
|
@ -157,11 +157,11 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
|
||||
def paintEvent(self, ev):
|
||||
self.scene().prepareForPaint()
|
||||
return QtGui.QGraphicsView.paintEvent(self, ev)
|
||||
return super().paintEvent(ev)
|
||||
|
||||
def render(self, *args, **kwds):
|
||||
self.scene().prepareForPaint()
|
||||
return QtGui.QGraphicsView.render(self, *args, **kwds)
|
||||
return super().render(*args, **kwds)
|
||||
|
||||
|
||||
def close(self):
|
||||
@ -328,10 +328,9 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
GraphicsView.setRange(self, r1, padding=[0, padding], propagate=False)
|
||||
|
||||
def wheelEvent(self, ev):
|
||||
QtGui.QGraphicsView.wheelEvent(self, ev)
|
||||
super().wheelEvent(ev)
|
||||
if not self.mouseEnabled:
|
||||
return
|
||||
|
||||
delta = 0
|
||||
if QT_LIB in ['PyQt4', 'PySide']:
|
||||
delta = ev.delta()
|
||||
@ -352,7 +351,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
self.scene().leaveEvent(ev) ## inform scene when mouse leaves
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
QtGui.QGraphicsView.mousePressEvent(self, ev)
|
||||
super().mousePressEvent(ev)
|
||||
|
||||
|
||||
if not self.mouseEnabled:
|
||||
@ -365,7 +364,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
return ## Everything below disabled for now..
|
||||
|
||||
def mouseReleaseEvent(self, ev):
|
||||
QtGui.QGraphicsView.mouseReleaseEvent(self, ev)
|
||||
super().mouseReleaseEvent(ev)
|
||||
if not self.mouseEnabled:
|
||||
return
|
||||
self.sigMouseReleased.emit(ev)
|
||||
@ -378,7 +377,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
||||
delta = Point(ev.pos() - self.lastMousePos.toQPoint())
|
||||
self.lastMousePos = Point(ev.pos())
|
||||
|
||||
QtGui.QGraphicsView.mouseMoveEvent(self, ev)
|
||||
super().mouseMoveEvent(ev)
|
||||
if not self.mouseEnabled:
|
||||
return
|
||||
self.sigSceneMouseMoved.emit(self.mapToScene(ev.pos()))
|
||||
|
@ -64,14 +64,14 @@ class JoystickButton(QtGui.QPushButton):
|
||||
self.sigStateChanged.emit(self, self.state)
|
||||
|
||||
def paintEvent(self, ev):
|
||||
QtGui.QPushButton.paintEvent(self, ev)
|
||||
super().paintEvent(ev)
|
||||
p = QtGui.QPainter(self)
|
||||
p.setBrush(QtGui.QBrush(QtGui.QColor(0,0,0)))
|
||||
p.drawEllipse(self.spotPos.x()-3,self.spotPos.y()-3,6,6)
|
||||
|
||||
def resizeEvent(self, ev):
|
||||
self.setState(*self.state)
|
||||
QtGui.QPushButton.resizeEvent(self, ev)
|
||||
super().resizeEvent(ev)
|
||||
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ class PathButton(QtGui.QPushButton):
|
||||
self.update()
|
||||
|
||||
def paintEvent(self, ev):
|
||||
QtGui.QPushButton.paintEvent(self, ev)
|
||||
super().paintEvent(ev)
|
||||
margin = self.margin
|
||||
geom = QtCore.QRectF(0, 0, self.width(), self.height()).adjusted(margin, margin, -margin, -margin)
|
||||
rect = self.path.boundingRect()
|
||||
|
@ -195,7 +195,7 @@ class ProgressDialog(QtGui.QProgressDialog):
|
||||
if self._nestingReady:
|
||||
# don't let progress dialog manage widgets anymore.
|
||||
return
|
||||
return QtGui.QProgressDialog.resizeEvent(self, ev)
|
||||
return super().resizeEvent(ev)
|
||||
|
||||
## wrap all other functions to make sure they aren't being called from non-gui threads
|
||||
|
||||
|
@ -114,7 +114,7 @@ class SpinBox(QtGui.QAbstractSpinBox):
|
||||
self.editingFinished.connect(self.editingFinishedEvent)
|
||||
|
||||
def event(self, ev):
|
||||
ret = QtGui.QAbstractSpinBox.event(self, ev)
|
||||
ret = super().event(ev)
|
||||
if ev.type() == QtCore.QEvent.KeyPress and ev.key() == QtCore.Qt.Key_Return:
|
||||
ret = True ## For some reason, spinbox pretends to ignore return key press
|
||||
return ret
|
||||
@ -596,7 +596,7 @@ class SpinBox(QtGui.QAbstractSpinBox):
|
||||
|
||||
def paintEvent(self, ev):
|
||||
self._updateHeight()
|
||||
QtGui.QAbstractSpinBox.paintEvent(self, ev)
|
||||
super().paintEvent(ev)
|
||||
|
||||
|
||||
class ErrorBox(QtGui.QWidget):
|
||||
|
@ -366,7 +366,7 @@ class TableWidget(QtGui.QTableWidget):
|
||||
ev.accept()
|
||||
self.copySel()
|
||||
else:
|
||||
QtGui.QTableWidget.keyPressEvent(self, ev)
|
||||
super().keyPressEvent(ev)
|
||||
|
||||
def handleItemChanged(self, item):
|
||||
item.itemChanged()
|
||||
|
@ -144,7 +144,7 @@ class TreeWidget(QtGui.QTreeWidget):
|
||||
return items
|
||||
|
||||
def dropEvent(self, ev):
|
||||
QtGui.QTreeWidget.dropEvent(self, ev)
|
||||
super().dropEvent(ev)
|
||||
self.updateDropFlags()
|
||||
|
||||
def updateDropFlags(self):
|
||||
|
@ -58,7 +58,7 @@ class ValueLabel(QtGui.QLabel):
|
||||
|
||||
def paintEvent(self, ev):
|
||||
self.setText(self.generateText())
|
||||
return QtGui.QLabel.paintEvent(self, ev)
|
||||
return super().paintEvent(ev)
|
||||
|
||||
def generateText(self):
|
||||
if len(self.values) == 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user