Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def mouseMoveEvent(self, event):
dx = event.x() - self.lastPos.x()
dy = event.y() - self.lastPos.y()
if event.buttons() & QtCore.Qt.LeftButton:
# move the scene
self.setMovement((dx,dy))
elif event.buttons() & QtCore.Qt.MiddleButton:
self.setRotation((dx,dy))
self.lastPos = event.pos()
self.gridLayout.addWidget(self.dial, 2, 1, 1, 1)
self.label_25 = QtGui.QLabel(self.dockWidgetContents)
self.label_25.setMinimumSize(QtCore.QSize(0, 0))
self.label_25.setMaximumSize(QtCore.QSize(16777215, 16777215))
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_25.setFont(font)
self.label_25.setObjectName(_fromUtf8("label_25"))
self.gridLayout.addWidget(self.label_25, 7, 0, 1, 1)
self.horizontalScrollBarDis = QtGui.QScrollBar(self.dockWidgetContents)
self.horizontalScrollBarDis.setEnabled(False)
self.horizontalScrollBarDis.setMinimumSize(QtCore.QSize(0, 0))
self.horizontalScrollBarDis.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.horizontalScrollBarDis.setProperty("value", 50)
self.horizontalScrollBarDis.setOrientation(QtCore.Qt.Horizontal)
self.horizontalScrollBarDis.setObjectName(_fromUtf8("horizontalScrollBarDis"))
self.gridLayout.addWidget(self.horizontalScrollBarDis, 3, 2, 1, 1)
self.verticalSlider = QtGui.QSlider(self.dockWidgetContents)
self.verticalSlider.setMinimumSize(QtCore.QSize(0, 70))
self.verticalSlider.setMaximumSize(QtCore.QSize(16777215, 70))
self.verticalSlider.setProperty("value", 50)
self.verticalSlider.setOrientation(QtCore.Qt.Vertical)
self.verticalSlider.setObjectName(_fromUtf8("verticalSlider"))
self.gridLayout.addWidget(self.verticalSlider, 7, 1, 1, 1)
self.label_24 = QtGui.QLabel(self.dockWidgetContents)
self.label_24.setMinimumSize(QtCore.QSize(0, 0))
self.label_24.setMaximumSize(QtCore.QSize(16777215, 16777215))
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.label_24.setFont(font)
#strings = self.tickStrings(values, self.scale, spacing)
# Determine exactly where tick text should be drawn
for j in range(len(strings)):
vstr = strings[j]
if vstr is None: ## this tick was ignored because it is out of bounds
continue
vstr = asUnicode(vstr)
x = tickPositions[i][j]
#textRect = p.boundingRect(QtCore.QRectF(0, 0, 100, 100), QtCore.Qt.AlignCenter, vstr)
textRect = rects[j]
height = textRect.height()
width = textRect.width()
#self.textHeight = height
offset = max(0,self.style['tickLength']) + textOffset
if self.orientation == 'left':
textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter
rect = QtCore.QRectF(tickStop-offset-width, x-(height/2), width, height)
elif self.orientation == 'right':
textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter
rect = QtCore.QRectF(tickStop+offset, x-(height/2), width, height)
elif self.orientation == 'top':
textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignCenter|QtCore.Qt.AlignBottom
rect = QtCore.QRectF(x-width/2., tickStop-offset-height, width, height)
elif self.orientation == 'bottom':
textFlags = QtCore.Qt.TextDontClip|QtCore.Qt.AlignCenter|QtCore.Qt.AlignTop
rect = QtCore.QRectF(x-width/2., tickStop+offset, width, height)
#p.setPen(self.pen())
#p.drawText(rect, textFlags, vstr)
textSpecs.append((rect, textFlags, vstr))
profiler('compute text')
def keyPressEvent(self, ev):
if not self.isSelected():
ev.ignore()
return
if ev.key() == QtCore.Qt.Key_Delete or ev.key() == QtCore.Qt.Key_Backspace:
self.source.disconnect(self.target)
ev.accept()
else:
ev.ignore()
def makeLayout(self, title):
layout = QtGui.QGridLayout()
#labels
title = QtGui.QLabel(title)
title.setFont(QtGui.QFont('MS Shell Dlg 2',pointSize=16))
title.setAlignment(QtCore.Qt.AlignCenter)
freqlabel = QtGui.QLabel('Frequency (Hz)')
voltagelabel = QtGui.QLabel('VPP (V)')
layout.addWidget(freqlabel,1, 0, 1, 1)
layout.addWidget(voltagelabel,1, 1, 1, 1)
#editable fields
self.spinFreq = QtGui.QDoubleSpinBox()
self.spinFreq.setFont(QtGui.QFont('MS Shell Dlg 2',pointSize=16))
self.spinFreq.setDecimals(3)
self.spinFreq.setSingleStep(0.1)
self.spinFreq.setRange(10.0,250.0)
self.spinFreq.setKeyboardTracking(False)
self.spinVoltage = QtGui.QDoubleSpinBox()
self.spinVoltage.setFont(QtGui.QFont('MS Shell Dlg 2',pointSize=16))
self.spinVoltage.setDecimals(2)
self.spinVoltage.setSingleStep(0.1)
self.spinVoltage.setRange(-145.0, 30.0)
def keyPressEvent(self, ev):
if ev.key() == QtCore.Qt.Key_Delete or ev.key() == QtCore.Qt.Key_Backspace:
ev.accept()
if not self.node._allowRemove:
return
self.node.close()
else:
ev.ignore()
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout_2.addWidget(self.label, 2, 0, 1, 1)
self.alphaGroup = QtGui.QGroupBox(Form)
self.alphaGroup.setGeometry(QtCore.QRect(10, 390, 234, 60))
self.alphaGroup.setCheckable(True)
self.alphaGroup.setObjectName(_fromUtf8("alphaGroup"))
self.horizontalLayout = QtGui.QHBoxLayout(self.alphaGroup)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.autoAlphaCheck = QtGui.QCheckBox(self.alphaGroup)
self.autoAlphaCheck.setChecked(False)
self.autoAlphaCheck.setObjectName(_fromUtf8("autoAlphaCheck"))
self.horizontalLayout.addWidget(self.autoAlphaCheck)
self.alphaSlider = QtGui.QSlider(self.alphaGroup)
self.alphaSlider.setMaximum(1000)
self.alphaSlider.setProperty("value", 1000)
self.alphaSlider.setOrientation(QtCore.Qt.Horizontal)
self.alphaSlider.setObjectName(_fromUtf8("alphaSlider"))
self.horizontalLayout.addWidget(self.alphaSlider)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupPen(self):
pscode = self.opts.pppara.pickstyles[0]
if pscode == '-':
pstyle = QtCore.Qt.SolidLine
elif pscode == '--':
pstyle = QtCore.Qt.DashLine
elif pscode == ':':
pstyle = QtCore.Qt.DotLine
self.opts.pickpens = [pg.mkPen(c, width=2, style=pstyle) for c in self.opts.pickcolors]
self.opts.cursorpen = pg.mkPen(width=1, style=QtCore.Qt.DashLine)
self.opts.picknames = ['T'+str(i) for i in range(self.opts.pppara.npick)]
self.opts.picknones = [None,] * self.opts.pppara.npick
self.opts.oripen = pg.mkPen(width=2, style=QtCore.Qt.SolidLine, color=self.opts.colorwavedel[:3])
self.opts.mempen = pg.mkPen(width=2, style=QtCore.Qt.SolidLine, color=self.opts.colorwave[:3])
self.picklist = list(range(self.opts.pppara.npick))
self.opts.colorwaves = [ self.opts.colorwavedel, self.opts.colorwave ]
def hoverEvent(self, ev):
ev.acceptDrags(QtCore.Qt.LeftButton)