Python PyQt4.QtGui.QPainter() Examples
The following are 30
code examples of PyQt4.QtGui.QPainter().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt4.QtGui
, or try the search function
.
Example #1
Source File: cityscapesViewer.py From rec-attend-public with MIT License | 6 votes |
def drawDisp( self , qp ): if not self.dispOverlay: return # Save QPainter settings to stack qp.save() # Define transparency qp.setOpacity(self.transp) # Draw the overlay image qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ),self.dispOverlay) # Restore settings qp.restore() return self.dispOverlay ############################# ## Mouse/keyboard events ############################# # Mouse moved # Need to save the mouse position # Need to drag a polygon point # Need to update the mouse selected object
Example #2
Source File: cityscapesViewer.py From fcn8s_tensorflow with GNU General Public License v3.0 | 6 votes |
def getHighlightedObject(self, qp): # This variable we want to fill self.highlightObj = None # Without labels we cannot do so if not self.annotation: return # If available its the selected object highlightObjId = -1 # If not available but the polygon is empty or closed, its the mouse object if highlightObjId < 0 and not self.mouseOutsideImage: highlightObjId = self.mouseObj # Get the actual object that is highlighted if highlightObjId >= 0: self.highlightObj = self.annotation.objects[highlightObjId] self.highlightObjLabel = self.annotation.objects[highlightObjId].label # Draw the image in the given QPainter qp
Example #3
Source File: cityscapesViewer.py From fcn8s_tensorflow with GNU General Public License v3.0 | 6 votes |
def drawDisp( self , qp ): if not self.dispOverlay: return # Save QPainter settings to stack qp.save() # Define transparency qp.setOpacity(self.transp) # Draw the overlay image qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ),self.dispOverlay) # Restore settings qp.restore() return self.dispOverlay ############################# ## Mouse/keyboard events ############################# # Mouse moved # Need to save the mouse position # Need to drag a polygon point # Need to update the mouse selected object
Example #4
Source File: pressure.py From wacom-gui with GNU General Public License v3.0 | 6 votes |
def paintEvent(self, event): painter = QtGui.QPainter(self) painter.setRenderHints(QtGui.QPainter.Antialiasing) painter.fillRect(QtCore.QRectF(50, 50, 200, 200), QtGui.QBrush(QtGui.QColor(QtGui.QColor(110, 110, 110)))) painter.fillRect(QtCore.QRectF(50, 50, 200, 200), QtGui.QBrush(QtCore.Qt.CrossPattern)) painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.lightGray), 2, QtCore.Qt.SolidLine)) path = QtGui.QPainterPath() path.moveTo(50, 250) path.cubicTo(self.points[0][0], self.points[0][1], self.points[1][0], self.points[1][1], 250, 50) painter.drawPath(path) painter.setBrush(QtGui.QBrush(QtGui.QColor(QtCore.Qt.darkCyan))) painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.lightGray), 1)) #for x, y in pts: painter.drawEllipse(QtCore.QRectF(self.points[0][0] - 4, self.points[0][1] - 4, 8, 8)) painter.drawEllipse(QtCore.QRectF(self.points[1][0] - 4, self.points[1][1] - 4, 8, 8)) painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.white), 1)) label1 = "("+ str((self.points[0][0] - 50)/2) + "," + str(100 - ((self.points[0][1] -50)/2)) + ")" painter.drawText(self.points[0][0] -25, self.points[0][1] + 18, QtCore.QString(label1)) label2 = "("+ str((self.points[1][0] - 50)/2) + "," + str(100 - ((self.points[1][1] -50)/2)) + ")" painter.drawText(self.points[1][0] -25, self.points[1][1] + 18, QtCore.QString(label2))
Example #5
Source File: cityscapesLabelTool.py From Detectron-PYTORCH with Apache License 2.0 | 6 votes |
def getHighlightedObject(self, qp): # These variables we want to fill self.highlightObjs = [] self.highlightObjLabel = None # Without labels we cannot do so if not self.annotation: return # If available set the selected objects highlightObjIds = self.selObjs # If not available but the polygon is empty or closed, its the mouse object if not highlightObjIds and (self.drawPoly.isEmpty() or self.drawPolyClosed) and self.mouseObj>=0 and not self.mouseOutsideImage: highlightObjIds = [self.mouseObj] # Get the actual object that is highlighted if highlightObjIds: self.highlightObjs = [ self.annotation.objects[i] for i in highlightObjIds ] # Set the highlight object label if appropriate if self.config.highlight: self.highlightObjLabel = self.config.highlightLabelSelection elif len(highlightObjIds) == 1 and self.config.correctionMode: self.highlightObjLabel = self.annotation.objects[highlightObjIds[-1]].label # Draw the image in the given QPainter qp
Example #6
Source File: uiBasicWidget.py From InplusTrader_Linux with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='r', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #7
Source File: cityscapesLabelTool.py From fcn8s_tensorflow with GNU General Public License v3.0 | 6 votes |
def getHighlightedObject(self, qp): # These variables we want to fill self.highlightObjs = [] self.highlightObjLabel = None # Without labels we cannot do so if not self.annotation: return # If available set the selected objects highlightObjIds = self.selObjs # If not available but the polygon is empty or closed, its the mouse object if not highlightObjIds and (self.drawPoly.isEmpty() or self.drawPolyClosed) and self.mouseObj>=0 and not self.mouseOutsideImage: highlightObjIds = [self.mouseObj] # Get the actual object that is highlighted if highlightObjIds: self.highlightObjs = [ self.annotation.objects[i] for i in highlightObjIds ] # Set the highlight object label if appropriate if self.config.highlight: self.highlightObjLabel = self.config.highlightLabelSelection elif len(highlightObjIds) == 1 and self.config.correctionMode: self.highlightObjLabel = self.annotation.objects[highlightObjIds[-1]].label # Draw the image in the given QPainter qp
Example #8
Source File: uiBasicWidget.py From InplusTrader_Linux with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='r', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #9
Source File: cityscapesViewer.py From rec-attend-public with MIT License | 6 votes |
def getHighlightedObject(self, qp): # This variable we want to fill self.highlightObj = None # Without labels we cannot do so if not self.annotation: return # If available its the selected object highlightObjId = -1 # If not available but the polygon is empty or closed, its the mouse object if highlightObjId < 0 and not self.mouseOutsideImage: highlightObjId = self.mouseObj # Get the actual object that is highlighted if highlightObjId >= 0: self.highlightObj = self.annotation.objects[highlightObjId] self.highlightObjLabel = self.annotation.objects[highlightObjId].label # Draw the image in the given QPainter qp
Example #10
Source File: Widget.py From pihud with GNU Lesser General Public License v2.1 | 6 votes |
def mouseMoveEvent(self, e): if e.buttons() == QtCore.Qt.LeftButton: mimeData = QtCore.QMimeData() mimeData.setText('%d,%d' % (e.x(), e.y())) # show the ghost image while dragging pixmap = QtGui.QPixmap.grabWidget(self) painter = QtGui.QPainter(pixmap) painter.fillRect(pixmap.rect(), QtGui.QColor(0, 0, 0, 127)) painter.end() drag = QtGui.QDrag(self) drag.setMimeData(mimeData) drag.setPixmap(pixmap) drag.setHotSpot(e.pos()) drag.exec_(QtCore.Qt.MoveAction)
Example #11
Source File: cityscapesLabelTool.py From LightNet with MIT License | 6 votes |
def getHighlightedObject(self, qp): # These variables we want to fill self.highlightObjs = [] self.highlightObjLabel = None # Without labels we cannot do so if not self.annotation: return # If available set the selected objects highlightObjIds = self.selObjs # If not available but the polygon is empty or closed, its the mouse object if not highlightObjIds and (self.drawPoly.isEmpty() or self.drawPolyClosed) and self.mouseObj>=0 and not self.mouseOutsideImage: highlightObjIds = [self.mouseObj] # Get the actual object that is highlighted if highlightObjIds: self.highlightObjs = [ self.annotation.objects[i] for i in highlightObjIds ] # Set the highlight object label if appropriate if self.config.highlight: self.highlightObjLabel = self.config.highlightLabelSelection elif len(highlightObjIds) == 1 and self.config.correctionMode: self.highlightObjLabel = self.annotation.objects[highlightObjIds[-1]].label # Draw the image in the given QPainter qp
Example #12
Source File: uiBasicWidget修改.py From chanlun with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='w', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #13
Source File: demoUi.py From chanlun with MIT License | 6 votes |
def generatePicture(self): ## pre-computing a QPicture object allows paint() to run much more quickly, ## rather than re-drawing the shapes every time. self.picture = QtGui.QPicture() p = QtGui.QPainter(self.picture) p.setPen(pg.mkPen(color='w', width=0.4)) # 0.4 means w*2 # w = (self.data[1][0] - self.data[0][0]) / 3. w = 0.2 for (t, open, close, min, max) in self.data: p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max)) if open > close: p.setBrush(pg.mkBrush('g')) else: p.setBrush(pg.mkBrush('r')) p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open)) p.end()
Example #14
Source File: cityscapesViewer.py From LightNet with MIT License | 6 votes |
def getHighlightedObject(self, qp): # This variable we want to fill self.highlightObj = None # Without labels we cannot do so if not self.annotation: return # If available its the selected object highlightObjId = -1 # If not available but the polygon is empty or closed, its the mouse object if highlightObjId < 0 and not self.mouseOutsideImage: highlightObjId = self.mouseObj # Get the actual object that is highlighted if highlightObjId >= 0: self.highlightObj = self.annotation.objects[highlightObjId] self.highlightObjLabel = self.annotation.objects[highlightObjId].label # Draw the image in the given QPainter qp
Example #15
Source File: PlotWindow.py From qkit with GNU General Public License v2.0 | 6 votes |
def registerCmap(self): """ Add matplotlib cmaps to the GradientEditors context menu""" self.gradientEditorItem.menu.addSeparator() savedLength = self.gradientEditorItem.length self.gradientEditorItem.length = 100 for name in self.mplColorMaps: px = QPixmap(100, 15) p = QPainter(px) self.gradientEditorItem.restoreState(self.mplColorMaps[name]) grad = self.gradientEditorItem.getGradient() brush = QBrush(grad) p.fillRect(QtCore.QRect(0, 0, 100, 15), brush) p.end() label = QLabel() label.setPixmap(px) label.setContentsMargins(1, 1, 1, 1) act =QWidgetAction(self.gradientEditorItem) act.setDefaultWidget(label) act.triggered.connect(self.cmapClicked) act.name = name self.gradientEditorItem.menu.addAction(act) self.gradientEditorItem.length = savedLength
Example #16
Source File: cityscapesViewer.py From LightNet with MIT License | 6 votes |
def drawDisp( self , qp ): if not self.dispOverlay: return # Save QPainter settings to stack qp.save() # Define transparency qp.setOpacity(self.transp) # Draw the overlay image qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ),self.dispOverlay) # Restore settings qp.restore() return self.dispOverlay ############################# ## Mouse/keyboard events ############################# # Mouse moved # Need to save the mouse position # Need to drag a polygon point # Need to update the mouse selected object
Example #17
Source File: cityscapesViewer.py From TFSegmentation with Apache License 2.0 | 6 votes |
def drawDisp( self , qp ): if not self.dispOverlay: return # Save QPainter settings to stack qp.save() # Define transparency qp.setOpacity(self.transp) # Draw the overlay image qp.drawImage(QtCore.QRect( self.xoff, self.yoff, self.w, self.h ),self.dispOverlay) # Restore settings qp.restore() return self.dispOverlay ############################# ## Mouse/keyboard events ############################# # Mouse moved # Need to save the mouse position # Need to drag a polygon point # Need to update the mouse selected object
Example #18
Source File: cityscapesLabelTool.py From TFSegmentation with Apache License 2.0 | 6 votes |
def getHighlightedObject(self, qp): # These variables we want to fill self.highlightObjs = [] self.highlightObjLabel = None # Without labels we cannot do so if not self.annotation: return # If available set the selected objects highlightObjIds = self.selObjs # If not available but the polygon is empty or closed, its the mouse object if not highlightObjIds and (self.drawPoly.isEmpty() or self.drawPolyClosed) and self.mouseObj>=0 and not self.mouseOutsideImage: highlightObjIds = [self.mouseObj] # Get the actual object that is highlighted if highlightObjIds: self.highlightObjs = [ self.annotation.objects[i] for i in highlightObjIds ] # Set the highlight object label if appropriate if self.config.highlight: self.highlightObjLabel = self.config.highlightLabelSelection elif len(highlightObjIds) == 1 and self.config.correctionMode: self.highlightObjLabel = self.annotation.objects[highlightObjIds[-1]].label # Draw the image in the given QPainter qp
Example #19
Source File: cityscapesViewer.py From TFSegmentation with Apache License 2.0 | 6 votes |
def getHighlightedObject(self, qp): # This variable we want to fill self.highlightObj = None # Without labels we cannot do so if not self.annotation: return # If available its the selected object highlightObjId = -1 # If not available but the polygon is empty or closed, its the mouse object if highlightObjId < 0 and not self.mouseOutsideImage: highlightObjId = self.mouseObj # Get the actual object that is highlighted if highlightObjId >= 0: self.highlightObj = self.annotation.objects[highlightObjId] self.highlightObjLabel = self.annotation.objects[highlightObjId].label # Draw the image in the given QPainter qp
Example #20
Source File: LNTextEdit_v3.2.py From universal_tool_template.py with MIT License | 5 votes |
def numberbarPaint(self, number_bar, event): font_metrics = self.fontMetrics() current_line = self.document().findBlock(self.textCursor().position()).blockNumber() + 1 block = self.firstVisibleBlock() line_count = block.blockNumber() painter = QtGui.QPainter(number_bar) painter.fillRect(event.rect(), self.palette().base()) # Iterate over all visible text blocks in the document. while block.isValid(): line_count += 1 block_top = self.blockBoundingGeometry(block).translated(self.contentOffset()).top() # Check if the position of the block is out side of the visible # area. if not block.isVisible() or block_top >= event.rect().bottom(): break # We want the line number for the selected line to be bold. if line_count == current_line: font = painter.font() font.setBold(True) painter.setFont(font) else: font = painter.font() font.setBold(False) painter.setFont(font) # Draw the line number right justified at the position of the line. paint_rect = QtCore.QRect(0, block_top, number_bar.width(), font_metrics.height()) painter.drawText(paint_rect, QtCore.Qt.AlignRight, unicode(line_count)) block = block.next() painter.end()
Example #21
Source File: LNTextEdit.py From universal_tool_template.py with MIT License | 5 votes |
def numberbarPaint(self, number_bar, event): font_metrics = self.fontMetrics() current_line = self.document().findBlock(self.textCursor().position()).blockNumber() + 1 block = self.firstVisibleBlock() line_count = block.blockNumber() painter = QtGui.QPainter(number_bar) painter.fillRect(event.rect(), self.palette().base()) # Iterate over all visible text blocks in the document. while block.isValid(): line_count += 1 block_top = self.blockBoundingGeometry(block).translated(self.contentOffset()).top() # Check if the position of the block is out side of the visible # area. if not block.isVisible() or block_top >= event.rect().bottom(): break # We want the line number for the selected line to be bold. if line_count == current_line: font = painter.font() font.setBold(True) painter.setFont(font) else: font = painter.font() font.setBold(False) painter.setFont(font) # Draw the line number right justified at the position of the line. paint_rect = QtCore.QRect(0, block_top, number_bar.width(), font_metrics.height()) painter.drawText(paint_rect, QtCore.Qt.AlignRight, unicode(line_count)) block = block.next() painter.end()
Example #22
Source File: test_active_contour.py From CrisisMappingToolkit with Apache License 2.0 | 5 votes |
def paintEvent(self, event): imageqt = ImageQt.ImageQt(self.display_image) p = QtGui.QPainter() p.begin(self) p.setRenderHint(QtGui.QPainter.Antialiasing, True); scale = self.height() / float(imageqt.height() + 10) p.scale(scale, scale) p.translate((self.width() / 2 / scale - imageqt.width() / 2), (self.height() / 2 / scale - imageqt.height() / 2)) p.fillRect(0, 0, imageqt.width(), imageqt.height(), QtGui.QColor(0, 0, 0)) p.drawImage(0, 0, imageqt) NODE_RADIUS = 4 # draw nodes for loop in self.snake.loops: for i in range(len(loop.nodes)): p.setPen(QtGui.QColor(255, 0, 0)) p.setBrush(QtGui.QBrush(QtGui.QColor(255, 0, 0))) p.drawEllipse(loop.nodes[i][1] - NODE_RADIUS / 2.0, loop.nodes[i][0] - NODE_RADIUS / 2.0, NODE_RADIUS, NODE_RADIUS) # draw lines between nodes for loop in self.snake.loops: for i in range(len(loop.nodes)): if len(loop.nodes) > 1: n = i+1 if n == len(loop.nodes): n = 0 p.setPen(QtGui.QColor(0, 255, 0)) p.drawLine(loop.nodes[i][1], loop.nodes[i][0], loop.nodes[n][1], loop.nodes[n][0]) p.end()
Example #23
Source File: RoundWindow.py From openQPA with GNU General Public License v3.0 | 5 votes |
def round(self): bmp = QBitmap(self.size()) p = QPainter() p.begin(bmp) p.fillRect(bmp.rect(), Qt.white) p.setBrush(QColor(0,0,0)) p.drawRoundedRect(bmp.rect(), 5, 5) p.setPen(QColor(255,255,255,255)) p.drawPoints(QPointF(self.width()-2,self.height()-1), QPointF(self.width()-1,self.height()-2)) p.setPen(QColor(0,0,0)) p.drawPoints(QPointF(0,2),QPointF(3,0),QPointF(2,0),QPointF(1,1)) p.end() self.setMask(bmp)
Example #24
Source File: RoundWindow.py From openQPA with GNU General Public License v3.0 | 5 votes |
def paintEvent(self,event): p = QPainter(self) p.setBrush(QColor(0xf9f9f9)) p.setPen(QColor(0x49585f)) p.drawRoundedRect(0, 0, self.width()-1, self.height()-1, 3, 3)
Example #25
Source File: show_submission.py From TPN with MIT License | 5 votes |
def draw_predictions(file_path, predictions, class_index, score_low, score_high): img = QtGui.QImage(file_path) painter = QtGui.QPainter(img) for i, pred in enumerate(predictions): if class_index > 0 and pred.class_index != class_index: continue if pred.score < score_low or pred.score > score_high: continue class_name = CLASS_NAMES[pred.class_index] x1, y1, x2, y2 = map(int, pred.bbox) # bbox painter.setPen(QtGui.QPen(PRESET_COLORS[pred.class_index], 10.0)) # painter.setPen(QtGui.QPen(QtGui.QColor(0, 116, 217), 10.0)) painter.setBrush(QtGui.QBrush()) painter.drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1) # label background rect painter.setPen(QtGui.QPen(PRESET_COLORS[pred.class_index], 2.0)) painter.setBrush(QtGui.QBrush(PRESET_COLORS[pred.class_index])) # painter.setPen(QtGui.QPen(QtGui.QColor(0, 116, 217), 2.0)) # painter.setBrush(QtGui.QBrush(QtGui.QColor(0, 116, 217))) if class_index > 0: painter.drawRect(x1, y1, min(x2 - x1 + 1, 100), 30) else: painter.drawRect(x1, y1, min(x2 - x1 + 1, 200), 30) # label text painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255))) painter.setBrush(QtGui.QBrush()) painter.setFont(QtGui.QFont('Arial', 20, QtGui.QFont.Bold)) if class_index > 0: painter.drawText(x1 + 4, y1 + 24, '{:.2f}'.format(pred.score)) else: painter.drawText(x1 + 4, y1 + 24, '{} {:.2f}'.format(class_name, pred.score)) return img
Example #26
Source File: image_widget.py From EasyStorj with MIT License | 5 votes |
def paintEvent(self, event): painter = QtGui.QPainter(self) painter.drawPixmap(3, 3, self.picture)
Example #27
Source File: cityscapesLabelTool.py From fcn8s_tensorflow with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, event): # Create a QPainter that can perform draw actions within a widget or image qp = QtGui.QPainter() # Begin drawing in the application widget qp.begin(self) # Update scale self.updateScale(qp) # Determine the object ID to highlight self.getHighlightedObject(qp) # Draw the image first self.drawImage(qp) # Draw the labels on top overlay = self.drawLabels(qp) # Draw the user drawn polygon self.drawDrawPoly(qp) self.drawDrawRect(qp) # Draw the label name next to the mouse self.drawLabelAtMouse(qp) # Draw the zoom # self.drawZoom(qp, overlay) self.drawZoom(qp,None) # Thats all drawing qp.end() # Forward the paint event QtGui.QMainWindow.paintEvent(self,event) # Update the scaling
Example #28
Source File: cityscapesViewer.py From TFSegmentation with Apache License 2.0 | 5 votes |
def getPolygon(self, obj): poly = QtGui.QPolygonF() for pt in obj.polygon: point = QtCore.QPointF(pt.x,pt.y) poly.append( point ) return poly # Draw the labels in the given QPainter qp # optionally provide a list of labels to ignore
Example #29
Source File: pressure.py From wacom-gui with GNU General Public License v3.0 | 5 votes |
def tabletEvent(self, event): senId = "" if self.sensor == "stylus" : senId = QtGui.QTabletEvent.Pen elif self.sensor == "eraser": senId = QtGui.QTabletEvent.Eraser elif self.sensor == "cursor": senId = QtGui.QTabletEvent.Cursor if event.pointerType() == senId: curpressure = event.pressure() if curpressure < 0: curpressure += 1 amp = int(curpressure * 50) color = (1 - amp/50.0) * 255 pen = QtGui.QPen(QtGui.QColor(color,color,color,0)) radial = QtGui.QRadialGradient(QtCore.QPointF(event.x(),event.y()),amp,QtCore.QPointF(event.xTilt() * amp/50 ,event.yTilt() * amp)) radial.setColorAt(0,QtGui.QColor(color,color,color,255)) radial.setColorAt(1,QtGui.QColor(color,color,color,0)) brush = QtGui.QBrush(radial) if(amp >= 1): if len(self.scene.items()) >= 50: render = QtGui.QPixmap(250,250) painter = QtGui.QPainter(render) rect = QtCore.QRectF(0,0,250,250) self.scene.render(painter,rect,rect,QtCore.Qt.KeepAspectRatio) self.scene.clear() self.scene.addPixmap(render) painter.end() self.scene.addEllipse(event.x() - amp, event.y() -amp, amp, amp, pen, brush) self.info.updateInfo(event.xTilt(),event.yTilt(),amp)
Example #30
Source File: FrameLayout.py From pyqt-collapsible-widget with MIT License | 5 votes |
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) painter.setBrush(QtGui.QColor(192, 192, 192)) painter.setPen(QtGui.QColor(64, 64, 64)) painter.drawPolygon(*self._arrow) painter.end()