class TrendCurve(SeriesCurve): """ TrendCurve(parent) -> displays trend bars """ penWith = 2 pens = { -1 : qt.QPen(qt.Qt.darkBlue, penWith), 0 : qt.QPen(qt.Qt.darkGray, penWith, qt.Qt.NoPen), +1 : qt.QPen(qt.Qt.darkGreen, penWith) } def draw(self, painter, xMap, yMap, start, stop): """ draw(...) -> called to draw the curve """ pens = self.pens for i in range(self.dataSize()): v = self.y(i) if v: painter.setPen(pens[abs(v) / v]) else: painter.setPen(pens[0]) xpos = self.x(i) xpos1 = xMap.transform(xpos) xpos2 = xMap.transform(xpos+1) ypos = yMap.transform(v) painter.drawLine(xpos1, ypos, xpos2, ypos)
def make(): # create a plot with a white canvas demo = Qwt.QwtPlot(Qwt.QwtText("Errorbar Demonstation")) demo.setCanvasBackground(qt.Qt.white) demo.plotLayout().setAlignCanvasToScales(True) grid = Qwt.QwtPlotGrid() grid.attach(demo) grid.setPen(qt.QPen(qt.Qt.black, 0, qt.Qt.DotLine)) # calculate data and errors for a curve with error bars x = arange(0, 10.1, 0.5, Float) y = sin(x) dy = 0.2 * abs(y) # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars dx = 0.2 # all error bars the same size errorOnTop = False # uncomment to draw the curve on top of the error bars # errorOnTop = True # uncomment to draw the error bars on top of the curve curve = ErrorBarPlotCurve( x=x, y=y, dx=dx, dy=dy, curvePen=qt.QPen(qt.Qt.black, 2), curveSymbol=Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, qt.QBrush(qt.Qt.red), qt.QPen(qt.Qt.black, 2), qt.QSize(9, 9)), errorPen=qt.QPen(qt.Qt.blue, 2), errorCap=10, errorOnTop=errorOnTop, ) curve.attach(demo) demo.resize(400, 300) demo.show() return demo
def run(self): key = {} self.emit(qt.PYSIGNAL("getView"), (key, )) try: self.__view = key["view"] self.__drawing = key["drawing"] except KeyError: logging.getLogger().error( "%s : You have to connect this brick to the CameraBrick", self.name()) return self.__toggleButton = QubToggleAction( label="Show profile", name="histogram", place="toolbar", group="Camera", autoConnect=True, ) qt.QObject.connect(self.__toggleButton, qt.PYSIGNAL("StateChanged"), self.__showCBK) self.__view.addAction([self.__toggleButton]) self.__line, _, _ = QubAddDrawing(self.__drawing, QubPointDrawingMgr, QubCanvasHLine, QubCanvasVLine) self.__line.setEndDrawCallBack(self.__clickedPoint) graphV = _graphPoint(self.__drawing.canvas()) graphV.setPen(qt.QPen(qt.Qt.red, 2)) graphH = _graphPoint(self.__drawing.canvas()) graphH.setPen(qt.QPen(qt.Qt.green, 2)) graphH.setZ(5) self.__graphs = (graphH, graphV)
def setView(self, view): self.alignementProcessState.setView(view) ####### CENTER DRAWING ####### self.__centerRotation = QubPointDrawingMgr(view.canvas(), view.matrix()) self.__centerRotation.setCanBeModify(False) target = QubCanvasTarget(view.canvas()) self.__centerRotation.addDrawingObject(target) view.addDrawingMgr(self.__centerRotation) self.__centerRotation.setColor(qt.QColor("red")) ####### Help lines ####### self.__helpLines = [] for i in range(3): dMgr = QubPointDrawingMgr(view.canvas(), view.matrix()) view.addDrawingMgr(dMgr) if self.alignementProcessState.verticalPhi(): line = QubCanvasVLine(view.canvas()) else: line = QubCanvasHLine(view.canvas()) dMgr.addDrawingObject(line) if not i: dMgr.setCanBeModify(False) dMgr.setPen(qt.QPen(qt.Qt.red, 1, qt.Qt.DashLine)) else: dMgr.setPen(qt.QPen(qt.Qt.red, 2)) dMgr.setEndDrawCallBack(self.__helpLineMoved) self.__helpLines.append(dMgr)
def __init__(self, *args): qt.QMainWindow.__init__(self, *args) self.plot = Qwt.QwtPlot(self) self.plot.setTitle("A Simple Map Demonstration") self.plot.setCanvasBackground(qt.Qt.white) self.plot.setAxisTitle(Qwt.QwtPlot.xBottom, "x") self.plot.setAxisTitle(Qwt.QwtPlot.yLeft, "y") self.plot.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, 1.0) self.plot.setAxisScale(Qwt.QwtPlot.yLeft, 0.0, 1.0) self.setCentralWidget(self.plot) # Initialize map data self.count = self.i = 1000 self.xs = zeros(self.count, Float) self.ys = zeros(self.count, Float) self.kappa = 0.2 self.curve = Qwt.QwtPlotCurve("Map") self.curve.attach(self.plot) self.curve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, qt.QBrush(qt.Qt.red), qt.QPen(qt.Qt.blue), qt.QSize(5, 5))) self.curve.setPen(qt.QPen(qt.Qt.cyan)) toolBar = qt.QToolBar(self) qt.QLabel("Count:", toolBar) sizeCounter = Qwt.QwtCounter(toolBar) toolBar.addSeparator() sizeCounter.setRange(0, 1000000, 100) sizeCounter.setValue(self.count) sizeCounter.setNumButtons(3) self.connect( sizeCounter, qt.SIGNAL('valueChanged(double)'), self.setCount) qt.QLabel("Ticks (ms):", toolBar) tickCounter = Qwt.QwtCounter(toolBar) toolBar.addSeparator() # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz) self.ticks = 10 tickCounter.setRange(0, 1000, 1) tickCounter.setValue(self.ticks) tickCounter.setNumButtons(3) self.connect( tickCounter, qt.SIGNAL('valueChanged(double)'), self.setTicks) self.tid = self.startTimer(self.ticks) self.timer_tic = None self.user_tic = None self.system_tic = None self.plot.replot()
def __init__(self, canvas, xAxis=xBottom, yAxis=yLeft, selectionFlags=qwt.QwtPicker.DragSelection, cursorLabelMode=qwt.QwtPicker.ActiveOnly, name='foo'): qwt.QwtPlotZoomer.__init__(self, xAxis, yAxis, selectionFlags, cursorLabelMode, canvas, name) self.setCursorLabelPen(qt.QPen(qt.Qt.white)) ## not quite, but this does adjust the color self.setRubberBandPen(qt.QPen(qt.Qt.white))
def __showHelpLines(self, aFlag): for i, line in enumerate(self.__helpLines): if aFlag: line.show() if not i: line.setPen(qt.QPen(qt.Qt.red, 1, qt.Qt.DashLine)) else: line.setPen(qt.QPen(qt.Qt.red, 2)) else: line.hide()
def main(args): app = qt.QApplication(args) demo = make() app.setMainWidget(demo) zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.DragSelection, Qwt.QwtPicker.AlwaysOff, demo.canvas()) zoomer.setRubberBandPen(qt.QPen(qt.Qt.green)) picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.NoSelection, Qwt.QwtPlotPicker.CrossRubberBand, Qwt.QwtPicker.AlwaysOn, demo.canvas()) picker.setTrackerPen(qt.QPen(qt.Qt.red)) sys.exit(app.exec_loop())
def __init__( self, x=[], y=[], dx=None, dy=None, curvePen=qt.QPen(qt.Qt.NoPen), curveStyle=Qwt.QwtPlotCurve.Lines, curveSymbol=Qwt.QwtSymbol(), errorPen=qt.QPen(qt.Qt.NoPen), errorCap=0, errorOnTop=False, ): """A curve of x versus y data with error bars in dx and dy. Horizontal error bars are plotted if dx is not None. Vertical error bars are plotted if dy is not None. x and y must be sequences with a shape (N,) and dx and dy must be sequences (if not None) with a shape (), (N,), or (2, N): - if dx or dy has a shape () or (N,), the error bars are given by (x-dx, x+dx) or (y-dy, y+dy), - if dx or dy has a shape (2, N), the error bars are given by (x-dx[0], x+dx[1]) or (y-dy[0], y+dy[1]). curvePen is the pen used to plot the curve curveStyle is the style used to plot the curve curveSymbol is the symbol used to plot the symbols errorPen is the pen used to plot the error bars errorCap is the size of the error bar caps errorOnTop is a boolean: - if True, plot the error bars on top of the curve, - if False, plot the curve on top of the error bars. """ Qwt.QwtPlotCurve.__init__(self) self.setData(x, y, dx, dy) self.setPen(curvePen) self.setStyle(curveStyle) self.setSymbol(curveSymbol) self.errorPen = errorPen self.errorCap = errorCap self.errorOnTop = errorOnTop
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) # make a QwtPlot widget self.setTitle('SimpleDemo.py') self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend) # a variation on the C++ example self.plotLayout().setAlignCanvasToScales(True) grid = Qwt.QwtPlotGrid() grid.attach(self) grid.setPen(qt.QPen(qt.Qt.black, 0, qt.Qt.DotLine)) # set axis titles self.setAxisTitle(Qwt.QwtPlot.xBottom, 'x -->') self.setAxisTitle(Qwt.QwtPlot.yLeft, 'y -->') # insert a few curves cSin = Qwt.QwtPlotCurve('y = sin(x)') cSin.setPen(qt.QPen(qt.Qt.red)) cSin.attach(self) cCos = Qwt.QwtPlotCurve('y = cos(x)') cCos.setPen(qt.QPen(qt.Qt.blue)) cCos.attach(self) # initialize the data cSin.setData(SimpleData(math.sin, 100)) cCos.setData(SimpleData(math.cos, 100)) # insert a horizontal marker at y = 0 mY = Qwt.QwtPlotMarker() mY.setLabel(Qwt.QwtText('y = 0')) mY.setLabelAlignment(qt.Qt.AlignRight | qt.Qt.AlignTop) mY.setLineStyle(Qwt.QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) # insert a vertical marker at x = 2 pi mX = Qwt.QwtPlotMarker() mX.setLabel(Qwt.QwtText('x = 2 pi')) mX.setLabelAlignment(qt.Qt.AlignRight | qt.Qt.AlignTop) mX.setLineStyle(Qwt.QwtPlotMarker.VLine) mX.setXValue(2 * math.pi) mX.attach(self) # replot self.replot()
def drawContents(self, painter): x0 = 10 x1 = 218 y0 = 109 y1 = 109 + painter.fontMetrics().height() pxsize = 14 painter.font().setPixelSize(pxsize) painter.setPen(qt.QPen(qt.Qt.white)) painter.drawText( qt.QRect(qt.QPoint(x0, y0), qt.QPoint(x1, y1)), qt.Qt.AlignLeft | qt.Qt.AlignTop, "Loading", ) painter.font().setPixelSize(pxsize * 2.5) y0 = y1 y1 += 3 + painter.fontMetrics().height() painter.drawText( qt.QRect(qt.QPoint(x0, y0), qt.QPoint(x1, y1)), qt.Qt.AlignCenter, self.guiName, ) painter.font().setPixelSize(pxsize) y0 = y1 y1 += 3 + painter.fontMetrics().height() painter.drawText( qt.QRect(qt.QPoint(x0, y0), qt.QPoint(x1, y1)), qt.Qt.AlignLeft | qt.Qt.AlignBottom, "Please wait...", )
def draw(self, painter, xMap, yMap, start, stop): """ draw(...) -> called to draw the curve """ plot = self.parentPlot() records = [record[0:4] for record in self.series.history] for xpos, ypos, sig, rev in records: if (not sig) and (not rev): continue marker = qwt.QwtPlotMarker(plot) markerid = plot.insertMarker(marker) self.markers.append(marker) plot.setMarkerPos(markerid, xpos, ypos) sigsym = qwt.QwtSymbol(*self.signalRes[(sig, rev)]) plot.setMarkerSymbol(markerid, sigsym) # brain dead and/or broken if 0: gridmarkerpen = qt.QPen( qt.QColor(BasePlot.majorGrid[0]), 0, qt.Qt.SolidLine) ## horizontal line symyline = plot.insertLineMarker("", qwt.QwtPlot.yLeft) plot.setMarkerPen(symyline, gridmarkerpen) plot.setMarkerYPos(symyline, ypos) self.markers.append(plot.marker(symyline)) ## vertical line symxline = plot.insertLineMarker("", qwt.QwtPlot.xTop) plot.setMarkerPen(symxline, gridmarkerpen) plot.setMarkerXPos(symxline, xpos) self.markers.append(plot.marker(symxline))
def setCurveColor(self, key, color): """ setCurveColor(key, color) -> handle a series color change """ curve = self.curves[str(key)] curve.setPen(qt.QPen(color)) curve.parentPlot().replot()
def __init__(self, parent=None): self.nameSize = 24 self.CrosshairNode = None self.CrosshairNodeObserverTag = None self.frame = qt.QFrame(parent) self.frame.setLayout(qt.QVBoxLayout()) modulePath = slicer.modules.dataprobe.path.replace("DataProbe.py","") self.iconsDIR = modulePath + '/Resources/Icons' self.showImage = False # Used in _createMagnifiedPixmap() self.imageCrop = vtk.vtkExtractVOI() self.painter = qt.QPainter() self.pen = qt.QPen() self._createSmall() #Helper class to calculate and display tensor scalars self.calculateTensorScalars = CalculateTensorScalars() # Observe the crosshair node to get the current cursor position self.CrosshairNode = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLCrosshairNode') if self.CrosshairNode: self.CrosshairNodeObserverTag = self.CrosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, self.processEvent)
def __init__(self, *args): qt.QWidget.__init__(self, *args) layout = qt.QGridLayout(self) # try to create a plot for SciPy arrays try: # import does_not_exist import numpy # make a curve and copy the data numpy_curve = Qwt.QwtPlotCurve('y = lorentzian(x)') x = numpy.arange(0.0, 10.0, 0.01) y = lorentzian(x) numpy_curve.setData(x, y) # here, we know we can plot NumPy arrays numpy_plot = Qwt.QwtPlot(self) numpy_plot.setTitle('numpy array') numpy_plot.setCanvasBackground(qt.Qt.white) numpy_plot.plotLayout().setCanvasMargin(0) numpy_plot.plotLayout().setAlignCanvasToScales(True) # insert a curve and make it red numpy_curve.attach(numpy_plot) numpy_curve.setPen(qt.QPen(qt.Qt.red)) layout.addWidget(numpy_plot, 0, 0) numpy_plot.replot() except ImportError, message: print "%s: %s" % (ImportError, message) print "Install NumPy to plot NumPy arrays"
def __init__(self, parent=None): qt.QMainWindow.__init__(self, parent) # Initialize a QwPlot central widget self.plot = Qwt.QwtPlot(self) self.plot.setTitle('left-click & drag to zoom') self.plot.setCanvasBackground(qt.Qt.white) self.plot.plotLayout().setCanvasMargin(0) self.plot.plotLayout().setAlignCanvasToScales(True) self.setCentralWidget(self.plot) grid = Qwt.QwtPlotGrid() pen = qt.QPen(qt.Qt.DotLine) pen.setColor(qt.Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self.plot) self.__initTracking() self.__initZooming() self.__initToolBar() # Finalize self.counter.setValue(10) self.go(self.counter.value())
def initAxes(self): """ initAxes() -> initialize the axes and a y axis marker """ BasePlot.initAxes(self) self.yMarker = ymarker = self.insertLineMarker('', yLeft) self.setMarkerPen(ymarker, qt.QPen(qt.QColor(self.yMarkerColor))) self.setMarkerYPos(ymarker, self.yMarkerPos)
def getPenStyle(style): """ getPenStyle(style) -> returns a pen based on the style """ color = qt.QColor(style.color) width = style.width linestyle = lineStyleMap.get(style.line_style, qt.Qt.SolidLine) return qt.QPen(color, width, linestyle)
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) # make a QwtPlot widget self.setTitle('ReallySimpleDemo.py') self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend) # set axis titles self.setAxisTitle(Qwt.QwtPlot.xBottom, 'x -->') self.setAxisTitle(Qwt.QwtPlot.yLeft, 'y -->') # insert a few curves cSin = Qwt.QwtPlotCurve('y = sin(x)') cSin.setPen(qt.QPen(qt.Qt.red)) cSin.attach(self) cCos = Qwt.QwtPlotCurve('y = cos(x)') cCos.setPen(qt.QPen(qt.Qt.blue)) cCos.attach(self) # make a Numeric array for the horizontal data x = arange(0.0, 10.0, 0.1) # initialize the data cSin.setData(x, sin(x)) cCos.setData(x, cos(x)) # insert a horizontal marker at y = 0 mY = Qwt.QwtPlotMarker() mY.setLabel(Qwt.QwtText('y = 0')) mY.setLabelAlignment(qt.Qt.AlignRight | qt.Qt.AlignTop) mY.setLineStyle(Qwt.QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) # insert a vertical marker at x = 2 pi mX = Qwt.QwtPlotMarker() mX.setLabel(Qwt.QwtText('x = 2 pi')) mX.setLabelAlignment(qt.Qt.AlignRight | qt.Qt.AlignTop) mX.setLineStyle(Qwt.QwtPlotMarker.VLine) mX.setXValue(2 * pi) mX.attach(self) # replot self.replot()
def highlight(self): try: highlighted_pen = qt.QPen(self.qub_line._drawingObjects[0].pen()) highlighted_pen.setWidth(3) highlighted_pen.setColor(SELECTED_COLOR) self.qub_line.setPen(highlighted_pen) except BaseException: logging.getLogger("HWR").exception("Could not higlight line") traceback.print_exc()
def __initZooming(self): """Initialize zooming """ self.zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.DragSelection, Qwt.QwtPicker.AlwaysOff, self.plot.canvas()) self.zoomer.setRubberBandPen(qt.QPen(qt.Qt.black))
def unhighlight(self): try: normal_pen = qt.QPen(self.qub_point._drawingObjects[0].pen()) normal_pen.setWidth(1) normal_pen.setColor(NORMAL_COLOR) self.qub_point.setPen(normal_pen) except BaseException: logging.getLogger("HWR").exception("Could not un-higlight point") traceback.print_exc()
def unhighlight(self): try: normal_pen = qt.QPen(self.qub_line.\ _drawingObjects[0].pen()) normal_pen.setWidth(1) normal_pen.setColor(NORMAL_COLOR) self.qub_line.setPen(normal_pen) except: logging.getLogger('HWR').exception('Could not un-higlight line') traceback.print_exc()
def highlight(self): try: highlighted_pen = qt.QPen(self.qub_point.\ _drawingObjects[0].pen()) highlighted_pen.setWidth(2) highlighted_pen.setColor(SELECTED_COLOR) self.qub_point.setPen(highlighted_pen) except: logging.getLogger('HWR').exception('Could not higlight point') traceback.print_exc()
def colorPlot(self, key, color): try: curveidx = self.plotFrame.curves[key] except (IndexError, ): pass else: curve = self.plotFrame.curve(curveidx) curve.setPen(qt.QPen(color)) item = self.accountView.findItem(key, 0) self.refreshPlot((item, ))
def _createMagnifiedPixmap(self, xyz, inputImageDataConnection, outputSize, crosshairColor, imageZoom=10): # Use existing instance of objects to avoid instantiating one at each event. imageCrop = self.imageCrop painter = self.painter pen = self.pen def _roundInt(value): try: return int(round(value)) except ValueError: return 0 imageCrop.SetInputConnection(inputImageDataConnection) xyzInt = [0, 0, 0] xyzInt = [_roundInt(value) for value in xyz] producer = inputImageDataConnection.GetProducer() dims = producer.GetOutput().GetDimensions() minDim = min(dims[0], dims[1]) imageSize = _roundInt(minDim / imageZoom / 2.0) imin = max(0, xyzInt[0] - imageSize) imax = min(dims[0] - 1, xyzInt[0] + imageSize) jmin = max(0, xyzInt[1] - imageSize) jmax = min(dims[1] - 1, xyzInt[1] + imageSize) if (imin <= imax) and (jmin <= jmax): imageCrop.SetVOI(imin, imax, jmin, jmax, 0, 0) imageCrop.Update() vtkImage = imageCrop.GetOutput() if vtkImage: qImage = qt.QImage() slicer.qMRMLUtils().vtkImageDataToQImage(vtkImage, qImage) imagePixmap = qt.QPixmap.fromImage(qImage) imagePixmap = imagePixmap.scaled(outputSize, qt.Qt.KeepAspectRatio, qt.Qt.FastTransformation) # draw crosshair painter.begin(imagePixmap) pen = qt.QPen() pen.setColor(crosshairColor) painter.setPen(pen) painter.drawLine(0, int(imagePixmap.height() / 2), imagePixmap.width(), int(imagePixmap.height() / 2)) painter.drawLine(int(imagePixmap.width() / 2), 0, int(imagePixmap.width() / 2), imagePixmap.height()) painter.end() return imagePixmap return None
def sizeHint(self): sz1 = self.knob.sizeHint() sz2 = self.label.sizeHint() w = max(sz1.width(), sz2.width()) h = sz1.height() + sz2.height() off = self.knob.scaleDraw().extent(qt.QPen(), self.knob.font()) off -= 10 # spacing return qt.QSize(w, h - off)
def resizeEvent(self, event): sz = event.size() h = self.label.sizeHint().height() self.label.setGeometry(0, sz.height() - h, sz.width(), h) h = self.knob.sizeHint().height() off = self.knob.scaleDraw().extent(qt.QPen(), self.knob.font()) off -= 10 # spacing self.knob.setGeometry(0, self.label.pos().y() - h + off, sz.width(), h)
def timeimage(self, request=''): """ For timing and debugging - return an image with the current time rendered as text down to the hundredth of a second :param color: hex encoded RGB of dashed border (default 333 for dark gray) :return: png image """ # check arguments p = urllib.parse.urlparse(request.decode()) q = urllib.parse.parse_qs(p.query) try: color = "#" + q['color'][0].strip().lower() except KeyError: color = "#330" # # make a generally transparent image, # imageWidth = 128 imageHeight = 32 timeImage = qt.QImage(imageWidth, imageHeight, qt.QImage().Format_ARGB32) timeImage.fill(0) # a painter to use for various jobs painter = qt.QPainter() # draw a border around the pixmap painter.begin(timeImage) pen = qt.QPen() color = qt.QColor(color) color.setAlphaF(0.8) pen.setColor(color) pen.setWidth(5) pen.setStyle(3) # dotted line (Qt::DotLine) painter.setPen(pen) rect = qt.QRect(1, 1, imageWidth - 2, imageHeight - 2) painter.drawRect(rect) color = qt.QColor("#333") pen.setColor(color) painter.setPen(pen) position = qt.QPoint(10, 20) text = str(time.time()) # text to draw painter.drawText(position, text) painter.end() # convert the image to vtk, then to png from there vtkTimeImage = vtk.vtkImageData() slicer.qMRMLUtils().qImageToVtkImageData(timeImage, vtkTimeImage) pngData = self.vtkImageDataToPNG(vtkTimeImage) return pngData, b'image/png'
def initGrids(self): """ initGrids() -> initialize the plot grids """ griddefs = ( (self.majorGrid, self.setGridMajPen), (self.minorGrid, self.setGridMinPen), ) for (color, width, line), func in griddefs: func(qt.QPen(qt.QColor(color), width, line)) for func in (self.enableGridXMin, self.enableGridYMin): func()