Python PyQt5.QtCore.Qt.NoPen() Examples
The following are 30
code examples of PyQt5.QtCore.Qt.NoPen().
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
PyQt5.QtCore.Qt
, or try the search function
.
Example #1
Source File: pkcharts.py From pkmeter with BSD 3-Clause "New" or "Revised" License | 6 votes |
def paintEvent(self, event): QtWidgets.QFrame.paintEvent(self, event) painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setPen(Qt.NoPen) # Draw the Pie rwidth = int(min([self.width(), self.height()]) - 2) x = int((self.width() / 2) - (rwidth / 2)) y = int((self.height() / 2) - (rwidth / 2)) rect = QtCore.QRect(x, y, rwidth, rwidth) angle1 = 0 for i in range(len(self.data)): angle2 = angle1 + (3.6 * self.data[i]) painter.setBrush(QtGui.QBrush(self.colors[i % len(self.colors)])) painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16) angle1 = angle2 # Draw the remainer (background) angle2 = 360 painter.setBrush(QtGui.QBrush(self.bgcolor)) painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16) painter.end()
Example #2
Source File: pkcharts.py From pkmeter with BSD 3-Clause "New" or "Revised" License | 6 votes |
def paintEvent(self, event): if not self.data: return QtWidgets.QFrame.paintEvent(self, event) painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) # Draw background painter.setBrush(QtGui.QBrush(self.bgcolor)) painter.setPen(Qt.NoPen) painter.drawRoundedRect(self.contentsRect(), 2, 2) # Draw the bars barwidth = (self.width() - 4) / len(self.data) for i in range(len(self.data)): barheight = int(self.height() * (self.data[i] / 100)) baroffset = i * barwidth + 2 painter.setBrush(QtGui.QBrush(self.colors[i % len(self.colors)])) painter.drawRoundedRect(baroffset, self.height()-barheight, barwidth, barheight, 1, 1) painter.end()
Example #3
Source File: waiting_animation.py From malss with MIT License | 6 votes |
def paintEvent(self, event): painter = QPainter() painter.begin(self) painter.setRenderHint(QPainter.Antialiasing) painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 200))) painter.setPen(QPen(Qt.NoPen)) if self.lists is not None: path = os.path.abspath(os.path.dirname(__file__)) + '/static/' path += self.lists[self.list_index] + '.png' self.list_index += 1 if self.list_index >= len(self.lists): self.list_index = 0 image = QImage(path) rect_image = image.rect() rect_painter = event.rect() dx = (rect_painter.width() - rect_image.width()) / 2.0 dy = (rect_painter.height() - rect_image.height()) / 2.0 painter.drawImage(dx, dy, image) painter.end()
Example #4
Source File: CColorItems.py From CustomWidgets with GNU General Public License v3.0 | 6 votes |
def paint(self, painter, option, index): if option.state & QStyle.State_HasFocus: # 取消虚线框 option.state = option.state ^ QStyle.State_HasFocus # 取出颜色 item = index.model().itemFromIndex(index) color = item.data() # 绘制矩形区域 rect = option.rect # 是否鼠标悬停 _in = option.state & QStyle.State_MouseOver painter.save() painter.setPen(color.darker(150) if _in else Qt.NoPen) painter.setBrush(color) rect = rect if _in else rect.adjusted(1, 1, -1, -1) painter.drawRoundedRect(rect, 2, 2) painter.restore()
Example #5
Source File: RoundProgressBar.py From PyQt with GNU General Public License v3.0 | 6 votes |
def paintEvent(self, event): super(CircleProgressBar, self).paintEvent(event) painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.translate(self.width() / 2, self.height() / 2) side = min(self.width(), self.height()) painter.scale(side / 100.0, side / 100.0) painter.rotate(self.angle) painter.save() painter.setPen(Qt.NoPen) color = self.Color.toRgb() for i in range(11): color.setAlphaF(1.0 * i / 10) painter.setBrush(color) painter.drawEllipse(30, -10, 20, 20) painter.rotate(36) painter.restore() self.angle += self.Delta if self.Clockwise else -self.Delta self.angle %= 360
Example #6
Source File: botonCircular.py From PyQt5 with MIT License | 6 votes |
def paintEvent(self, event): ancho, altura = self.width(), self.height() icono = self.icono.scaled(ancho, altura, Qt.KeepAspectRatio, Qt.SmoothTransformation) pintor = QPainter() pintor.begin(self) pintor.setRenderHint(QPainter.Antialiasing, True) pintor.setPen(Qt.NoPen) pintor.drawPixmap(0, 0, icono, 0, 0, 0, 0) pintor.setPen(Qt.white) pintor.drawText(event.rect(), Qt.AlignCenter, self.etiqueta) pintor.setPen(Qt.NoPen) pintor.setBrush(self.opacidad) pintor.drawEllipse(0, 0, ancho, altura) pintor.end() self.setMask(icono.mask())
Example #7
Source File: overview.py From wonambi with GNU General Public License v3.0 | 6 votes |
def mark_poi(self, times=None): """Mark selected signal, from list of start and end times. Parameters ---------- times : list of tuple of float start and end times, in sec form rec start """ y_pos = BARS['quality']['pos0'] height = 5 for rect in self.idx_poi: self.scene.removeItem(rect) self.idx_poi = [] if not times: return for beg, end in times: rect = QGraphicsRectItem(beg, y_pos, end - beg, height) rect.setPen(NoPen) rect.setBrush(Qt.darkRed) self.scene.addItem(rect) self.idx_poi.append(rect)
Example #8
Source File: PercentProgressBar.py From PyQt with GNU General Public License v3.0 | 5 votes |
def _drawCircle(self, painter: QPainter, radius: int): # 绘制中心园 radius = radius - self.BorderWidth painter.save() painter.setPen(Qt.NoPen) painter.setBrush(self.BackgroundColor) painter.drawEllipse(QRectF(-radius, -radius, radius * 2, radius * 2)) painter.restore()
Example #9
Source File: CColorSlider.py From CustomWidgets with GNU General Public License v3.0 | 5 votes |
def gradientCirclePixmap(self): """白色带阴影 """ xy = self.height() / 2 radius = self.height() * 0.8 # 绘制普通状态下圆形的滑块 circleColor = QRadialGradient(xy, xy, radius, xy, xy) circleColor.setColorAt(0.5, QColor(254, 254, 254)) circleColor.setColorAt(0.7, QColor(0, 0, 0, 60)) circleColor.setColorAt(0.7, QColor(0, 0, 0, 30)) circleColor.setColorAt(0.9, QColor(0, 0, 0, 0)) self._imageCircle = QImage( self.height(), self.height(), QImage.Format_ARGB32) self._imageCircle.fill(Qt.transparent) painter = QPainter() painter.begin(self._imageCircle) painter.setRenderHint(QPainter.Antialiasing, True) painter.setRenderHint(QPainter.SmoothPixmapTransform, True) painter.setPen(Qt.NoPen) painter.setBrush(circleColor) painter.drawRoundedRect(0, 0, self.height(), self.height(), xy, xy) painter.end() # 绘制悬停状态下圆形的滑块 circleColorHover = QRadialGradient(xy, xy, radius, xy, xy) circleColorHover.setColorAt(0.5, QColor(245, 245, 245)) circleColorHover.setColorAt(0.7, QColor(0, 0, 0, 30)) circleColorHover.setColorAt(0.9, QColor(0, 0, 0, 0)) self._imageCircleHover = QImage( self.height(), self.height(), QImage.Format_ARGB32) self._imageCircleHover.fill(Qt.transparent) painter = QPainter() painter.begin(self._imageCircleHover) painter.setRenderHint(QPainter.Antialiasing, True) painter.setRenderHint(QPainter.SmoothPixmapTransform, True) painter.setPen(Qt.NoPen) painter.setBrush(circleColorHover) painter.drawRoundedRect(0, 0, self.height(), self.height(), xy, xy) painter.end()
Example #10
Source File: CColorControl.py From CustomWidgets with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, event): super(CColorControl, self).paintEvent(event) painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing, True) painter.setRenderHint(QPainter.SmoothPixmapTransform, True) painter.setPen(Qt.NoPen) # 变换圆心 painter.translate(self.rect().center()) # 画背景方格图 painter.save() # 保证方格在前景圆内部 diameter = min(self.width(), self.height()) - 8 radius = diameter / 2 path = QPainterPath() path.addRoundedRect(-radius, -radius, diameter, diameter, radius, radius) painter.setClipPath(path) pixSize = 5 for x in range(int(self.width() / pixSize)): for y in range(int(self.height() / pixSize)): _x, _y = x * pixSize, y * pixSize painter.fillRect(_x - radius, _y - radius, pixSize, pixSize, Qt.white if x % 2 != y % 2 else Qt.darkGray) painter.restore() # 画前景颜色 diameter = min(self.width(), self.height()) - 4 radius = diameter / 2 path = QPainterPath() path.addRoundedRect(-radius, -radius, diameter, diameter, radius, radius) painter.setClipPath(path) painter.setBrush(self._color) painter.drawRoundedRect(-radius, -radius, diameter, diameter, radius, radius)
Example #11
Source File: CColorPanel.py From CustomWidgets with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, event): super(CColorPanel, self).paintEvent(event) if self._image: painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing, True) painter.setRenderHint(QPainter.SmoothPixmapTransform, True) painter.drawImage(self.rect(), self._image) painter.setPen(QColor(240, 240, 240)) painter.drawRect(self.rect()) if self._pointerPos: painter.setPen(Qt.NoPen) painter.drawImage(self._pointerPos, self._imagePointer)
Example #12
Source File: overview.py From wonambi with GNU General Public License v3.0 | 5 votes |
def mark_stages(self, start_time, length, stage_name): """Mark stages, only add the new ones. Parameters ---------- start_time : int start time in s of the epoch being scored. length : int duration in s of the epoch being scored. stage_name : str one of the stages defined in global stages. """ y_pos = BARS['stage']['pos0'] current_stage = STAGES.get(stage_name, STAGES['Unknown']) # the -1 is really important, otherwise we stay on the edge of the rect old_score = self.scene.itemAt(start_time + length / 2, y_pos + current_stage['pos0'] + current_stage['pos1'] - 1, self.transform()) # check we are not removing the black border if old_score is not None and old_score.pen() == NoPen: lg.debug('Removing old score at {}'.format(start_time)) self.scene.removeItem(old_score) self.idx_annot.remove(old_score) rect = QGraphicsRectItem(start_time, y_pos + current_stage['pos0'], length, current_stage['pos1']) rect.setPen(NoPen) rect.setBrush(current_stage['color']) self.scene.addItem(rect) self.idx_annot.append(rect)
Example #13
Source File: overview.py From wonambi with GNU General Public License v3.0 | 5 votes |
def mark_quality(self, start_time, length, qual_name): """Mark signal quality, only add the new ones. Parameters ---------- start_time : int start time in s of the epoch being scored. length : int duration in s of the epoch being scored. qual_name : str one of the stages defined in global stages. """ y_pos = BARS['quality']['pos0'] height = 10 # the -1 is really important, otherwise we stay on the edge of the rect old_score = self.scene.itemAt(start_time + length / 2, y_pos + height - 1, self.transform()) # check we are not removing the black border if old_score is not None and old_score.pen() == NoPen: lg.debug('Removing old score at {}'.format(start_time)) self.scene.removeItem(old_score) self.idx_annot.remove(old_score) if qual_name == 'Poor': rect = QGraphicsRectItem(start_time, y_pos, length, height) rect.setPen(NoPen) rect.setBrush(Qt.black) self.scene.addItem(rect) self.idx_annot.append(rect)
Example #14
Source File: CColorSlider.py From CustomWidgets with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, event): if not (self._imageRainbow or self._imageAlpha): return super(CColorSlider, self).paintEvent(event) option = QStyleOptionSlider() self.initStyleOption(option) # 背景Rect groove = self.style().subControlRect( QStyle.CC_Slider, option, QStyle.SC_SliderGroove, self) groove.adjust(3, 5, -3, -5) # 滑块Rect handle = self.style().subControlRect( QStyle.CC_Slider, option, QStyle.SC_SliderHandle, self) handle.setX(max(min(handle.x(), self.width() - self.height()), 0)) handle.setWidth(self.height()) handle.setHeight(self.height()) radius = self.height() / 2 painter = QPainter(self) painter.setPen(Qt.NoPen) painter.drawImage( groove, self._imageRainbow if self._imageRainbow else self._imageAlpha) if not self._imageCircle or not self._imageCircleHover: painter.setBrush(QColor(245, 245, 245) if option.state & QStyle.State_MouseOver else QColor(254, 254, 254)) painter.drawRoundedRect(handle, radius, radius) else: painter.drawImage(handle, self._imageCircleHover if option.state & QStyle.State_MouseOver else self._imageCircle)
Example #15
Source File: HotPlaylist.py From PyQt with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, event): super(CoverLabel, self).paintEvent(event) if hasattr(self, "cover_title") and self.cover_title != "": # 底部绘制文字 painter = QPainter(self) rect = self.rect() # 粗略字体高度 painter.save() fheight = self.fontMetrics().height() # 底部矩形框背景渐变颜色 bottomRectColor = QLinearGradient( rect.width() / 2, rect.height() - 24 - fheight, rect.width() / 2, rect.height()) bottomRectColor.setSpread(QGradient.PadSpread) bottomRectColor.setColorAt(0, QColor(255, 255, 255, 70)) bottomRectColor.setColorAt(1, QColor(0, 0, 0, 50)) # 画半透明渐变矩形框 painter.setPen(Qt.NoPen) painter.setBrush(QBrush(bottomRectColor)) painter.drawRect(rect.x(), rect.height() - 24 - fheight, rect.width(), 24 + fheight) painter.restore() # 距离底部一定高度画文字 font = self.font() or QFont() font.setPointSize(8) painter.setFont(font) painter.setPen(Qt.white) rect.setHeight(rect.height() - 12) # 底部减去一定高度 painter.drawText(rect, Qt.AlignHCenter | Qt.AlignBottom, self.cover_title)
Example #16
Source File: HotPlaylist.py From PyQt with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, event): super(CoverLabel, self).paintEvent(event) if hasattr(self, "cover_title") and self.cover_title != "": # 底部绘制文字 painter = QPainter(self) rect = self.rect() # 粗略字体高度 painter.save() fheight = self.fontMetrics().height() # 底部矩形框背景渐变颜色 bottomRectColor = QLinearGradient( rect.width() / 2, rect.height() - 24 - fheight, rect.width() / 2, rect.height()) bottomRectColor.setSpread(QGradient.PadSpread) bottomRectColor.setColorAt(0, QColor(255, 255, 255, 70)) bottomRectColor.setColorAt(1, QColor(0, 0, 0, 50)) # 画半透明渐变矩形框 painter.setPen(Qt.NoPen) painter.setBrush(QBrush(bottomRectColor)) painter.drawRect(rect.x(), rect.height() - 24 - fheight, rect.width(), 24 + fheight) painter.restore() # 距离底部一定高度画文字 font = self.font() or QFont() font.setPointSize(8) painter.setFont(font) painter.setPen(Qt.white) rect.setHeight(rect.height() - 12) # 底部减去一定高度 painter.drawText(rect, Qt.AlignHCenter | Qt.AlignBottom, self.cover_title)
Example #17
Source File: HotPlaylist.py From PyQt with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, event): super(CoverLabel, self).paintEvent(event) if hasattr(self, "cover_title") and self.cover_title != "": # 底部绘制文字 painter = QPainter(self) rect = self.rect() # 粗略字体高度 painter.save() fheight = self.fontMetrics().height() # 底部矩形框背景渐变颜色 bottomRectColor = QLinearGradient( rect.width() / 2, rect.height() - 24 - fheight, rect.width() / 2, rect.height()) bottomRectColor.setSpread(QGradient.PadSpread) bottomRectColor.setColorAt(0, QColor(255, 255, 255, 70)) bottomRectColor.setColorAt(1, QColor(0, 0, 0, 50)) # 画半透明渐变矩形框 painter.setPen(Qt.NoPen) painter.setBrush(QBrush(bottomRectColor)) painter.drawRect(rect.x(), rect.height() - 24 - fheight, rect.width(), 24 + fheight) painter.restore() # 距离底部一定高度画文字 font = self.font() or QFont() font.setPointSize(8) painter.setFont(font) painter.setPen(Qt.white) rect.setHeight(rect.height() - 12) # 底部减去一定高度 painter.drawText(rect, Qt.AlignHCenter | Qt.AlignBottom, self.cover_title)
Example #18
Source File: swipe.py From guiscrcpy with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, event): qp = QtGui.QPainter() qp.begin(self) qp.setRenderHint(QtGui.QPainter.Antialiasing) qp.setPen(Qt.NoPen) qp.setBrush(QtGui.QColor(0, 0, 0, 127)) qp.drawEllipse(0, 0, 70, 70) qp.end()
Example #19
Source File: meta.py From FeelUOwn with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, e): """ draw pixmap with border radius We found two way to draw pixmap with border radius, one is as follow, the other way is using bitmap mask, but in our practice, the mask way has poor render effects """ if self._pixmap is None: return radius = 3 painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.setRenderHint(QPainter.SmoothPixmapTransform) scaled_pixmap = self._pixmap.scaledToWidth( self.width(), mode=Qt.SmoothTransformation ) size = scaled_pixmap.size() brush = QBrush(scaled_pixmap) painter.setBrush(brush) painter.setPen(Qt.NoPen) y = (size.height() - self.height()) // 2 painter.save() painter.translate(0, -y) rect = QRect(0, y, self.width(), self.height()) painter.drawRoundedRect(rect, radius, radius) painter.restore() painter.end()
Example #20
Source File: pkcharts.py From pkmeter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def paintEvent(self, event): if not self.data: return QtWidgets.QFrame.paintEvent(self, event) painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) # Draw background painter.setBrush(QtGui.QBrush(self.bgcolor)) painter.setPen(Qt.NoPen) painter.drawRoundedRect(self.contentsRect(), 2, 2) # Draw the Lines for i in range(len(self.data[0])): path = None pen = QtGui.QPen(self.colors[i % len(self.colors)]) for j in range(len(self.data)): value = self.data[j][i] prevvalue = self.data[j-1][i] if value == -1 or prevvalue == -1: continue if not self.showzero and value <= 0 and prevvalue <= 0: continue x1 = (self.pxperpt * (j - 0.5) + self.pxperpt / 4) - self.offset x2 = (self.pxperpt * j + self.pxperpt / 4) - self.offset y1 = self.height() - int((self.height() - 1) * (prevvalue / self.maxvalue)) y2 = self.height() - int((self.height() - 1) * (value / self.maxvalue)) path = path or QtGui.QPainterPath(QtCore.QPointF(x1,y1)) path.cubicTo(x1, y1, x1, y2, x2, y2) if path: painter.strokePath(path, pen) painter.end()
Example #21
Source File: visual.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint(self, p, w, h): p.setPen(Qt.NoPen) p.setBrush(QBrush(QColor(*self.color))) # Use chosen color self.clip(p, w, h) p.drawRect(QRect(-1, -1, w + 2, h + 2)) # draw full field rectangle
Example #22
Source File: visual.py From stytra with GNU General Public License v3.0 | 5 votes |
def draw_block(self, p, point, w, h): """ Function for drawing the gratings programmatically. """ p.setPen(Qt.NoPen) p.setRenderHint(QPainter.Antialiasing) p.setBrush(QBrush(QColor(*self.color))) p.drawRect( point.x(), point.y(), int( self.grating_period / (2 * max(self._experiment.calibrator.mm_px, 0.0001)) ), self.barheight, )
Example #23
Source File: visual.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint(self, p, w, h): p.setPen(Qt.NoPen) p.setBrush(QBrush(QColor(*self.color))) p.setRenderHint(QPainter.Antialiasing) p.setBrush(QBrush(QColor(255, 255, 255))) p.drawEllipse(self.x, self.y, 3, 3) p.setPen(QPen(QColor(*self.color))) l = 20 p.drawLine( self.x, self.y, self.x + np.cos(self.theta) * l, self.y + np.sin(self.theta) * l, )
Example #24
Source File: visual.py From stytra with GNU General Public License v3.0 | 5 votes |
def draw_block(self, p, point, w, h): # Painting settings: p.setPen(Qt.NoPen) p.setRenderHint(QPainter.Antialiasing) # Here for changing black with another color (to be debugged) # p.setBrush(QBrush(QColor(*self.color_2))) # # p.drawRect(QRect(-1, -1, (w + 2)*1.5, (h + 2)*1.5)) p.setBrush(QBrush(QColor(*self.color))) # To draw a windmill, a set of consecutive triangles will be painted: mid_x = int(w / 2) # calculate image center mid_y = int(h / 2) # calculate angles for each triangle: angles = np.arange(0, np.pi * 2, (np.pi * 2) / self.n_arms) angles += np.pi / 2 + np.pi / (2 * self.n_arms) # angular width of the white arms, by default equal to dark ones size = np.pi / self.n_arms # radius of triangles (much larger than frame) rad = (w ** 2 + h ** 2) ** (1 / 2) # loop over angles and draw consecutive triangles for deg in np.array(angles): polyg_points = [ QPoint(mid_x, mid_y), QPoint(int(mid_x + rad * np.cos(deg)), int(mid_y + rad * np.sin(deg))), QPoint( int(mid_x + rad * np.cos(deg + size)), int(mid_y + rad * np.sin(deg + size)), ), ] polygon = QPolygon(polyg_points) p.drawPolygon(polygon)
Example #25
Source File: kinematograms.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint(self, p, w, h): # draw background p.resetTransform() p.setPen(Qt.NoPen) p.setBrush(QBrush(QColor(*self.color_bg))) self.clip(p, w, h) p.drawRect(QRect(-1, -1, w + 2, h + 2)) p.setTransform(self.get_rot_transform(w, h)) self.paint_dots(p, w, h)
Example #26
Source File: kinematograms.py From stytra with GNU General Public License v3.0 | 5 votes |
def paint(self, p, w, h): # draw background p.resetTransform() p.setPen(Qt.NoPen) p.setBrush(QBrush(QColor(*self.color_bg))) self.clip(p, w, h) p.drawRect(QRect(-1, -1, w + 2, h + 2)) self.paint_dots(p, w, h)
Example #27
Source File: lyric.py From FeelUOwn with GNU General Public License v3.0 | 5 votes |
def paintEvent(self, e): painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.setPen(Qt.NoPen) painter.setBrush(self.palette().color(QPalette.Window)) painter.drawRoundedRect(self.rect(), self._border_radius, self._border_radius) painter.save() painter.setPen(QColor('white')) option = QTextOption() option.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) rect = QRect(self.mapToParent(self._size_grip.pos()), self._size_grip.size()) painter.drawText(QRectF(rect), '●', option) painter.restore()
Example #28
Source File: pkwidgets.py From pkmeter with BSD 3-Clause "New" or "Revised" License | 5 votes |
def paintEvent(self, event): QtWidgets.QFrame.paintEvent(self, event) painter = QtGui.QPainter() painter.begin(self) painter.setRenderHint(QtGui.QPainter.Antialiasing) painter.setPen(Qt.NoPen) if self.enabled: self.paint_slider_on(painter) else: self.paint_slider_off(painter) painter.end()
Example #29
Source File: overview.py From wonambi with GNU General Public License v3.0 | 4 votes |
def mark_cycles(self, start_time, length, end=False): """Mark cycle bound, only add the new one. Parameters ---------- start_time: int start time in s of the bounding epoch length : int duration in s of the epoch being scored. end: bool If True, marker will be a cycle end marker; otherwise, it's start. """ y_pos = STAGES['cycle']['pos0'] height = STAGES['cycle']['pos1'] color = STAGES['cycle']['color'] # the -1 is really important, otherwise we stay on the edge of the rect old_rect = self.scene.itemAt(start_time + length / 2, y_pos + height - 1, self.transform()) # check we are not removing the black border if old_rect is not None and old_rect.pen() == NoPen: lg.debug('Removing old score at {}'.format(start_time)) self.scene.removeItem(old_rect) self.idx_annot.remove(old_rect) rect = QGraphicsRectItem(start_time, y_pos, 30, height) rect.setPen(NoPen) rect.setBrush(color) self.scene.addItem(rect) self.idx_annot.append(rect) if end: start_time -= 120 kink_hi = QGraphicsRectItem(start_time, y_pos, 150, 1) kink_hi.setPen(NoPen) kink_hi.setBrush(color) self.scene.addItem(kink_hi) self.idx_annot.append(kink_hi) kink_lo = QGraphicsRectItem(start_time, y_pos + height, 150, 1) kink_lo.setPen(NoPen) kink_lo.setBrush(color) self.scene.addItem(kink_lo) self.idx_annot.append(kink_lo)
Example #30
Source File: videolist.py From vidcutter with GNU General Public License v3.0 | 4 votes |
def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex) -> None: r = option.rect pencolor = Qt.white if self.theme == 'dark' else Qt.black if self.parent.isEnabled(): if option.state & QStyle.State_Selected: painter.setBrush(QColor(150, 190, 78, 150)) elif option.state & QStyle.State_MouseOver: painter.setBrush(QColor(227, 212, 232)) pencolor = Qt.black else: brushcolor = QColor(79, 85, 87, 175) if self.theme == 'dark' else QColor('#EFF0F1') painter.setBrush(Qt.transparent if index.row() % 2 == 0 else brushcolor) painter.setPen(Qt.NoPen) painter.drawRect(r) thumbicon = QIcon(index.data(Qt.DecorationRole + 1)) starttime = index.data(Qt.DisplayRole + 1) endtime = index.data(Qt.UserRole + 1) externalPath = index.data(Qt.UserRole + 2) chapterName = index.data(Qt.UserRole + 3) painter.setPen(QPen(pencolor, 1, Qt.SolidLine)) if len(chapterName): offset = 20 r = option.rect.adjusted(5, 5, 0, 0) cfont = QFont('Futura LT', -1, QFont.Medium) cfont.setPointSizeF(12.25 if sys.platform == 'darwin' else 10.25) painter.setFont(cfont) painter.drawText(r, Qt.AlignLeft, self.clipText(chapterName, painter, True)) r = option.rect.adjusted(5, offset, 0, 0) else: offset = 0 r = option.rect.adjusted(5, 0, 0, 0) thumbicon.paint(painter, r, Qt.AlignVCenter | Qt.AlignLeft) r = option.rect.adjusted(110, 10 + offset, 0, 0) painter.setFont(QFont('Noto Sans', 11 if sys.platform == 'darwin' else 9, QFont.Bold)) painter.drawText(r, Qt.AlignLeft, 'FILENAME' if len(externalPath) else 'START') r = option.rect.adjusted(110, 23 + offset, 0, 0) painter.setFont(QFont('Noto Sans', 11 if sys.platform == 'darwin' else 9, QFont.Normal)) if len(externalPath): painter.drawText(r, Qt.AlignLeft, self.clipText(os.path.basename(externalPath), painter)) else: painter.drawText(r, Qt.AlignLeft, starttime) if len(endtime) > 0: r = option.rect.adjusted(110, 48 + offset, 0, 0) painter.setFont(QFont('Noto Sans', 11 if sys.platform == 'darwin' else 9, QFont.Bold)) painter.drawText(r, Qt.AlignLeft, 'RUNTIME' if len(externalPath) else 'END') r = option.rect.adjusted(110, 60 + offset, 0, 0) painter.setFont(QFont('Noto Sans', 11 if sys.platform == 'darwin' else 9, QFont.Normal)) painter.drawText(r, Qt.AlignLeft, endtime)