python类QPen()的实例源码

lab10.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = QGraphicsScene(0, 0, 711, 601)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(710, 600, QImage.Format_Alpha8)
        self.image.fill(black)
        self.pen = QPen(black)
        self.draw.clicked.connect(lambda: draw(self))
        self.dial_x.valueChanged.connect(lambda: draw(self))
        self.dial_y.valueChanged.connect(lambda: draw(self))
        self.dial_z.valueChanged.connect(lambda: draw(self))
        self.funcs.addItem("cos(x) * sin(z)")
        self.funcs.addItem("2 * cos(x * z)")
        self.funcs.addItem("exp(sin(sqrt(x^2 + z^2)))")
        self.funcs.addItem("x^2 / 20 + z^2 / 20")
        self.funcs.addItem("|sin(x) * sin(z)|")
QPlot2D.py 文件源码 项目:KerbalPie 作者: Vivero 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def updatePlot(self, plot_num, value_tuple):

        # check if we have an existing plot. if not, initialize list of plot
        # values.
        if not plot_num in self._plots.keys():
            self._plots[plot_num] = []

            # if no pen has been assigned to this plot, create default
            if not plot_num in self._plot_pens.keys():
                self._plot_pens[plot_num] = QPen(Qt.blue, 2.0)

            # if no draw method has been assigned to this plot, assign default
            if not plot_num in self._plot_draw_method.keys():
                self._plot_draw_method[plot_num] = 'scatter'

        # add value to plot points list
        self._plots[plot_num].append(value_tuple)

        self.update()
radar.py 文件源码 项目:echolocation 作者: hgross 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _add_crosshair(self):
        """
        Adds vertical, horizontal and diagonal crosshairs to the graphic scene
        """
        pen = QPen(self.crosshair_line_color)
        pen.setWidth(self.line_width)
        pen.setStyle(Qt.DotLine)
        width, height = self.width(), self.height()
        mx, my = self._get_middle()

        # horizontal
        self.scene.addLine(0, my, width, my, pen=pen)
        # vertical
        self.scene.addLine(mx, 0, mx, height, pen=pen)
        # 45°
        self.scene.addLine(0, 0, width, height, pen=pen)
        self.scene.addLine(width, 0, 0, height, pen=pen)
port.py 文件源码 项目:PyNoder 作者: johnroper100 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def mouseMoveEvent(self, event):
        self.unhighlight()
        scenePos = self.mapToScene(event.pos())

        # When clicking on an UI port label, it is ambigous which connection point should be activated.
        # We let the user drag the mouse in either direction to select the conneciton point to activate.
        delta = scenePos - self.__mousDownPos
        if delta.x() < 0:
            if self.__port.inCircle() is not None:
                self.__port.inCircle().mousePressEvent(event)
        else:
            if self.__port.outCircle() is not None:
                self.__port.outCircle().mousePressEvent(event)

    # def paint(self, painter, option, widget):
    #     super(PortLabel, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 255)))
    #     painter.drawRect(self.windowFrameRect())
port.py 文件源码 项目:PyNoder 作者: johnroper100 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):

        self.unhighlight()

        scenePos = self.mapToScene(event.pos())

        from .mouse_actions import MouseGrabber
        if self.isInConnectionPoint():
            MouseGrabber(self._graph, scenePos, self, 'Out')
        elif self.isOutConnectionPoint():
            MouseGrabber(self._graph, scenePos, self, 'In')

    # def paint(self, painter, option, widget):
    #     super(PortCircle, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 0)))
    #     painter.drawRect(self.windowFrameRect())
mouse_actions.py 文件源码 项目:PyNoder 作者: johnroper100 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def setMouseOverPortCircle(self, portCircle):
        if self.__mouseOverPortCircle != portCircle:
            if self.__mouseOverPortCircle is not None:
                self.__mouseOverPortCircle.unhighlight()
                self.__mouseOverPortCircle.getPort().labelItem().unhighlight()

            self.__mouseOverPortCircle = portCircle

            if self.__mouseOverPortCircle is not None:
                self.__mouseOverPortCircle.highlight()
                self.__mouseOverPortCircle.getPort().labelItem().highlight()

    # def paint(self, painter, option, widget):
    #     super(MouseGrabber, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(self.getColor()))
    #     painter.drawRect(self.windowFrameRect())
state.py 文件源码 项目:transpyler 作者: Transpyler 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        kwargs.setdefault('width', 2)
        avatar = kwargs.setdefault('avatar', 'tuga')
        self.size = kwargs.pop('size', 45)
        self.validate_avatar(avatar)
        self.graphics_item = cursor = QtSvg.QGraphicsSvgItem()

        # Loads from turtleart.svg
        cursor.setSharedRenderer(svg_renderer)
        cursor.setElementId(avatar)

        # Define local transforms
        rect = cursor.sceneBoundingRect()
        curr_width, curr_height = rect.width(), rect.height()
        cursor.setTransform(QtGui.QTransform(
            1.00, 0.00,
            0.00, 1.00,
            -curr_width / 2, -curr_height / 2)
        )
        cursor.setTransformOriginPoint(0.5 * curr_width, 0.5 * curr_height)
        cursor.setScale(self.size / curr_width)
        cursor.setZValue(1.0)
        self.pen = QtGui.QPen(QtGui.QColor(0, 0, 0))
        self.brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
        super().__init__(*args, **kwargs)
lab8.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = Scene(0, 0, 561, 581)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
        self.image.fill(Qt.white)
        self.bars.clicked.connect(lambda : set_bars(self))
        self.erase.clicked.connect(lambda: clean_all(self))
        self.paint.clicked.connect(lambda: clipping(self))
        self.rect.clicked.connect(lambda: set_rect(self))
        self.ect.clicked.connect(lambda: add_bars(self))
        self.lock.clicked.connect(lambda: lock(self))
        self.lines = []
        self.edges = []
        self.clip = None
        self.point_now_rect = None
        self.point_now_bars = None
        self.point_lock = None
        self.input_bars = False
        self.input_rect = False
        self.pen = QPen(black)
lab5.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = myScene(0, 0, 561, 581)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
        self.image.fill(col_zero)
        self.lock.clicked.connect(lambda: lock(self))
        self.erase.clicked.connect(lambda: clean_all(self))
        self.paint.clicked.connect(lambda: fill_xor(self))
        self.addpoint.clicked.connect(lambda: add_point_by_btn(self))
        self.edges = []
        self.point_now = None
        self.point_lock = None
        self.pen = QPen(col_one)
        self.delay.setChecked(False)
lab4.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511)
        self.mainview.setScene(self.scene)
        self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied)
        self.pen = QPen()
        self.color_line = QColor(Qt.black)
        self.color_bground = QColor(Qt.white)
        self.draw_once.clicked.connect(lambda: draw_once(self))
        self.clean_all.clicked.connect(lambda: clear_all(self))
        self.btn_bground.clicked.connect(lambda: get_color_bground(self))
        self.btn_line.clicked.connect(lambda: get_color_line(self))
        self.draw_centr.clicked.connect(lambda: draw_centr(self))
        layout = QtWidgets.QHBoxLayout()
        layout.addWidget(self.what)
        layout.addWidget(self.other)
        self.setLayout(layout)
        self.circle.setChecked(True)
        self.canon.setChecked(True)
        #self.circle.toggled.connect(lambda : change_text(self))
lab6.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = myScene(0, 0, 561, 581)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
        self.image.fill(col_zero)
        self.lock.clicked.connect(lambda: lock(self))
        self.erase.clicked.connect(lambda: clean_all(self))
        self.paint.clicked.connect(lambda: fill_with_seed(self))
        self.addpoint.clicked.connect(lambda: add_point_by_btn(self))
        self.pixel.clicked.connect(lambda: set_flag_zat(self))
        self.addcircle.clicked.connect(lambda: set_flag_cir(self))
        self.edges = []
        self.point_now = None
        self.point_lock = None

        self.pen = QPen(col_one)
        self.delay.setChecked(False)
asamacizimi.py 文件源码 项目:Milis-Yukleyici 作者: sonakinci41 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def asama_ciz(asama,tum_asama):
    #Amac?m?z pencerenin üzerinde gözüken ad?m k?sm? için gerekli resmi olu?turmak
    resim = QImage(950,10,QImage.Format_RGB32)
    boyayici = QPainter()
    boyayici.begin(resim)
    mavi_kalem = QPen(QColor("#00bbf2"))
    mavi_firca = QBrush(QColor("#00bbf2"))
    beyaz_kalem = QPen(QColor("#ffffff"))
    beyaz_firca = QBrush(QColor("#ffffff"))
    boyayici.setPen(beyaz_kalem)
    boyayici.setBrush(beyaz_firca)
    boyayici.drawRect(0,0,950,10)
    boyayici.setPen(mavi_kalem)
    boyayici.setBrush(mavi_firca)
    en_hesabi = (asama/tum_asama)*950
    boyayici.drawRect(0,0,int(en_hesabi),10)
    boyayici.end()
    return resim
delegates.py 文件源码 项目:plexdesktop 作者: coryo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def draw_unwatched_indicator(plex_item, pixmap, size=0.20):
    """draw a triangle on the top right of pixmap"""
    if not hasattr(plex_item, 'watched') and not hasattr(plex_item, 'in_progress'):
        return
    if plex_item.watched or plex_item.in_progress:
        return
    p = QtGui.QPainter(pixmap)
    rect = p.window()
    top_right = rect.topRight()
    size = pixmap.height() * size
    color = QtGui.QColor(204, 123, 25)
    triangle = QtGui.QPolygon([top_right, top_right - QtCore.QPoint(size, 0),
                               top_right + QtCore.QPoint(0, size)])
    p.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(0, 0, 0, 120)), 6))
    p.drawLine(triangle.point(1), triangle.point(2))
    p.setBrush(QtGui.QBrush(color))
    p.setPen(color)
    p.drawPolygon(triangle)
experiencebar.py 文件源码 项目:thegame 作者: afg984 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def paint(
            self,
            painter: QPainter,
            option: QStyleOptionGraphicsItem,
            widget: QWidget):
        pen = QPen()
        pen.setWidth(3)
        painter.setRenderHint(QPainter.Antialiasing)
        pen.setColor(QColor(61, 61, 61, 255))
        painter.setPen(pen)
        painter.setBrush(QBrush(QColor(61, 61, 61, 255), Qt.SolidPattern))
        painter.drawRect(
            QRectF(-self.maxWidth / 2, -10, self.maxWidth, 20))
        painter.setBrush(QBrush(QColor(240, 217, 108, 255), Qt.SolidPattern))
        painter.drawRect(
            QRectF(-self.maxWidth / 2, -10, self.displayWidth, 20))
        path = QPainterPath()

        path.addText(-self.maxWidth / 2, 35, QFont('monospace', 18, QFont.Bold), f'{self.name}  Lv.{self.level}  Exp. {self.actualExperience:{len(str(self.maxExperience))}}/{self.maxExperience}')

        # pen.setColor(Qt.white)
        pen.setWidth(2)
        painter.setPen(pen)
        painter.setBrush(QBrush(QColor(0, 0, 0, 61), Qt.SolidPattern))
        painter.drawPath(path)
message.py 文件源码 项目:thegame 作者: afg984 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def paint(
            self,
            painter: QPainter,
            option: QStyleOptionGraphicsItem,
            widget: QWidget):
        pen = QPen()
        pen.setWidth(1)
        painter.setRenderHint(QPainter.Antialiasing)
        pen.setColor(QColor(81, 81, 81, 255))
        painter.setPen(pen)
        painter.setBrush(QBrush(QColor(81, 81, 81, 255), Qt.SolidPattern))
        path = QPainterPath()
        path.addText(
            -self.width,
            self.height,
            QFont('monospace', 13, QFont.PreferNoHinting),
            self.text)
        painter.drawPath(path)
scoreboard.py 文件源码 项目:thegame 作者: afg984 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def paint(
            self,
            painter: QPainter,
            option: QStyleOptionGraphicsItem,
            widget: QWidget):
        pen = QPen()
        pen.setWidth(1)
        painter.setRenderHint(QPainter.Antialiasing)
        pen.setColor(QColor(81, 81, 81, 255))
        painter.setPen(pen)
        painter.setBrush(QBrush(QColor(81, 81, 81, 255), Qt.SolidPattern))
        for i, score in enumerate(self.scores):
            path = QPainterPath()
            path.addText(
                -self.width,
                14 + i * 16,
                QFont('monospace', 13, QFont.PreferNoHinting),
                f'{score.score:6}[{score.level:2}]  {score.hero_name}')
            painter.drawPath(path)
arrow.py 文件源码 项目:dxf2gcode 作者: cnc-club 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, startp=Point(), endp=None,
                 length=60.0, angle=50.0,
                 color=QtCore.Qt.red, pencolor=QtCore.Qt.green,
                 startarrow=True):
        """
        Initialisation of the class.
        """
        self.sc = None
        super(Arrow, self).__init__()

        self.startp = QtCore.QPointF(startp.x, -startp.y)
        self.endp = endp

        self.length = length
        self.angle = angle
        self.startarrow = startarrow
        self.allwaysshow = False

        self.arrowHead = QPolygonF()
        self.setFlag(QGraphicsItem.ItemIsSelectable, False)
        self.myColor = color
        self.pen = QPen(pencolor, 1, QtCore.Qt.SolidLine)
        self.pen.setCosmetic(True)
        self.arrowSize = 8.0
routetext.py 文件源码 项目:dxf2gcode 作者: cnc-club 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, text='S', startp=Point(x=0.0, y=0.0),):
        """
        Initialisation of the class.
        """
        QGraphicsItem.__init__(self)

        self.setFlag(QGraphicsItem.ItemIsSelectable, False)

        self.text = text
        self.sc = 1.0
        self.startp = QtCore.QPointF(startp.x, -startp.y)

        pencolor = QColor(0, 200, 255)
        self.brush = QColor(0, 100, 255)

        self.pen = QPen(pencolor, 1, QtCore.Qt.SolidLine)
        self.pen.setCosmetic(True)

        self.path = QPainterPath()
        self.path.addText(QtCore.QPointF(0, 0),
                          QFont("Arial", 10/self.sc),
                          self.text)
qgraphtree.py 文件源码 项目:vivisect-py3 作者: bat-serjo 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def drawLinesTo(self, colnode):
        """
        Draw lines to our nodes from the specified one
        (used when we are on the right...)
        """
        scene = self.scene()
        colpos = colnode.scenePos()
        colrect = colnode.boundingRect()

        ecolor = self._v_vg.getMeta('edgecolor', '#000')
        pen = QtGui.QPen(QtGui.QColor(ecolor))

        for item in self.childItems():
            itpos = item.scenePos()
            itrect = item.boundingRect()

            x1 = colpos.x() + colrect.width()
            y1 = colpos.y() + (colrect.height() / 2)

            x2 = itpos.x()
            y2 = itpos.y() + (itrect.height() / 2)

            lineitem = scene.addLine(x1, y1, x2, y2, pen=pen)
            self._v_lines.append(lineitem)
            # lineitem.setParentItem(self)
qgraphtree.py 文件源码 项目:vivisect-py3 作者: bat-serjo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def drawLinesFrom(self, colnode):
        """
        Draw lines from our nodes to the specified one
        (used when we are on the left...)
        """
        scene = self.scene()
        colpos = colnode.scenePos()
        colrect = colnode.boundingRect()

        ecolor = self._v_vg.getMeta('edgecolor', '#000')
        pen = QtGui.QPen(QtGui.QColor(ecolor))

        for item in self.childItems():
            itpos = item.scenePos()
            itrect = item.boundingRect()

            x1 = itpos.x() + itrect.width()
            y1 = itpos.y() + (itrect.height() / 2)

            x2 = colpos.x()
            y2 = colpos.y() + (colrect.height() / 2)

            lineitem = scene.addLine(x1, y1, x2, y2, pen=pen)
            self._v_lines.append(lineitem)
            # lineitem.setParentItem(self)
qtrend.py 文件源码 项目:vivisect-py3 作者: bat-serjo 项目源码 文件源码 阅读 47 收藏 0 点赞 0 评论 0
def renderEdge(self, eid, einfo, points):
        scene = self.scene()

        # If we have been drawn already, get rid of it.
        gproxy = einfo.get('gproxy')
        if gproxy:
            scene.removeItem(gproxy)

        qpoints = [QtCore.QPointF(x, y) for (x, y) in points]
        qpoly = QtGui.QPolygonF(qpoints)

        ecolor = self._vg_graph.getMeta('edgecolor', '#000')
        ecolor = einfo.get('color', ecolor)

        pen = QtGui.QPen(QtGui.QColor(ecolor))
        gproxy = self.scene().addPolygon(qpoly, pen=pen)
        gproxy.setZValue(-1.0)

        einfo['gproxy'] = gproxy
menu.py 文件源码 项目:HearthPacks 作者: Arzaroth 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(event.rect(), QBrush(QColor(127, 127, 127, 127)))
        painter.setPen(QPen(Qt.NoPen))

        for i in range(6):
            if int(self.counter / 10) % 6 == i:
                factor = self.counter % 10
                if factor >= 5:
                    factor = 5 - (self.counter % 5)
                painter.setBrush(QBrush(QColor(95 + factor * 32, 127, 127)))
            else:
                painter.setBrush(QBrush(QColor(127, 127, 127)))
            painter.drawEllipse(
                self.width() / 2 + 30 * math.cos(2 * math.pi * i / 6.0) - 10,
                self.height() / 2 + 30 * math.sin(2 * math.pi * i / 6.0) - 10,
                20, 20)

        painter.end()
gtkswitch.py 文件源码 项目:gpvdm 作者: roderickmackenzie 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def drawWidget(self, qp):
        font = QFont('Sans', 11, QFont.Normal)
        qp.setFont(font)

        pen = QPen(QColor(20, 20, 20), 1, Qt.SolidLine)

        qp.setPen(pen)
        qp.setBrush(Qt.NoBrush)

        if self.value==True:
            qp.setBrush(QColor(95,163,235))
            qp.drawRoundedRect(0, 0.0, 80.0,22.0,5.0,5.0)
            qp.setBrush(QColor(230,230,230))
            qp.drawRoundedRect(40, 2, 38,18.0,5.0,5.0)

            qp.drawText(8, 17, _("ON"))
        else:
            qp.setBrush(QColor(180,180,180))
            qp.drawRoundedRect(0, 0.0, 80.0,22.0,5.0,5.0)           
            qp.setBrush(QColor(230,230,230))
            qp.drawRoundedRect(2, 2, 38,18.0,5.0,5.0)
            qp.drawText(44, 17, _("OFF"))
pen_interface.py 文件源码 项目:brown 作者: ajyoon 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, brown_object, color, thickness, pattern,
                 join_style, cap_style):
        """
        Args:
            brown_object (Pen): The object this interface belongs to.
            color (Color):
            thickness (Unit):
            pattern (PenPattern):
            join_style (PenJoinStyle):
            cap_style (PenCapStyle):
        """
        super().__init__(brown_object)
        self.qt_object = QtGui.QPen()
        self.thickness = thickness
        self.color = color
        self.pattern = pattern
        self.join_style = join_style
        self.cap_style = cap_style

    ######## PUBLIC PROPERTIES ########
concentriccircles.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, self.antialiased)
        painter.translate(self.width() / 2, self.height() / 2)

        for diameter in range(0, 256, 9):
            delta = abs((self.frameNo % 128) - diameter / 2)
            alpha = 255 - (delta * delta) / 4 - diameter
            if alpha > 0:
                painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3))

                if self.floatBased:
                    painter.drawEllipse(QRectF(-diameter / 2.0,
                            -diameter / 2.0, diameter, diameter))
                else:
                    painter.drawEllipse(QRect(-diameter / 2,
                            -diameter / 2, diameter, diameter))
bubbleswidget.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, parent=None):

        super(BubblesWidget, self).__init__(parent)

        self.pen = QPen(QColor("#cccccc"))
        self.bubbles = []
        self.backgroundColor1 = self.randomColor()
        self.backgroundColor2 = self.randomColor().darker(150)
        self.newBubble = None

        random.seed()

        self.animation_timer = QTimer(self)
        self.animation_timer.setSingleShot(False)
        self.animation_timer.timeout.connect(self.animate)
        self.animation_timer.start(25)

        self.bubbleTimer = QTimer()
        self.bubbleTimer.setSingleShot(False)
        self.bubbleTimer.timeout.connect(self.expandBubble)

        self.setMouseTracking(True)
        self.setMinimumSize(QSize(200, 200))
        self.setWindowTitle("Bubble Maker")
concentriccircles.py 文件源码 项目:examples 作者: pyqt 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def paintEvent(self, event):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, self.antialiased)
        painter.translate(self.width() / 2, self.height() / 2)

        for diameter in range(0, 256, 9):
            delta = abs((self.frameNo % 128) - diameter / 2)
            alpha = 255 - (delta * delta) / 4 - diameter
            if alpha > 0:
                painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3))

                if self.floatBased:
                    painter.drawEllipse(QRectF(-diameter / 2.0,
                            -diameter / 2.0, diameter, diameter))
                else:
                    painter.drawEllipse(QRect(-diameter / 2,
                            -diameter / 2, diameter, diameter))
bubbleswidget.py 文件源码 项目:examples 作者: pyqt 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, parent=None):

        super(BubblesWidget, self).__init__(parent)

        self.pen = QPen(QColor("#cccccc"))
        self.bubbles = []
        self.backgroundColor1 = self.randomColor()
        self.backgroundColor2 = self.randomColor().darker(150)
        self.newBubble = None

        random.seed()

        self.animation_timer = QTimer(self)
        self.animation_timer.setSingleShot(False)
        self.animation_timer.timeout.connect(self.animate)
        self.animation_timer.start(25)

        self.bubbleTimer = QTimer()
        self.bubbleTimer.setSingleShot(False)
        self.bubbleTimer.timeout.connect(self.expandBubble)

        self.setMouseTracking(True)
        self.setMinimumSize(QSize(200, 200))
        self.setWindowTitle("Bubble Maker")
cursor.py 文件源码 项目:Laborejo 作者: hilbrichtsoftware 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, parentScoreScene):
        super().__init__(0, 0,  0, 0)        # (x1, y1, x2, y2)
        self.parentScoreScene = parentScoreScene
        p = QtGui.QPen()
        p.setColor(QtGui.QColor("red"))
        p.setCosmetic(True)
        self.setPen(p)
        self.setAcceptHoverEvents(True)
        api.getCallbacksDatabase().setPlaybackTicks.append(self.setCursorPosition)
        api.getCallbacksDatabase().tracksChanged.append(self.setLineToWindowHeigth) #for new tracks
        api.getCallbacksDatabase().updateTempoTrack.append(self.setLineToWindowHeigth)
        self.setFlags(QtWidgets.QGraphicsItem.ItemIsMovable)
        self.setAcceptedMouseButtons(QtCore.Qt.LeftButton)
        self.setZValue(90)
        #self.parentScoreScene.parentView.verticalScrollBar().valueChanged.connect(self.setLineToWindowHeigth)
        #self.hide()
        #self.maxHeight = QtWidgets.QDesktopWidget().geometry().height() #we really hope the screen resolution does not change during the session.
graphs.py 文件源码 项目:Laborejo 作者: hilbrichtsoftware 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, parentGuiTrack, parentDataTrackId):
        super().__init__(0, 0, 0, 0)
        self.setAcceptHoverEvents(True)
        #self.setFlags(QtWidgets.QGraphicsItem.ItemIsMovable|QtWidgets.QGraphicsItem.ItemSendsGeometryChanges|QtWidgets.QGraphicsItem.ItemIsFocusable|QtWidgets.QGraphicsItem.ItemIgnoresParentOpacity)
        self.setFlags(QtWidgets.QGraphicsItem.ItemIsFocusable|QtWidgets.QGraphicsItem.ItemIgnoresParentOpacity)
        #self.setBrush(QtCore.Qt.red) #debug
        self.setPen(QtGui.QPen(QtCore.Qt.transparent))

        self.parentDataTrackId = parentDataTrackId
        self.parentGuiTrack = parentGuiTrack
        self.userItems = []
        self.interpolatedItems = []
        self.other = []
        self.blockListCache = [] #backend dictExport items. updated through self.updateGraphBlockTrack
        self.blockdictCache = {} #blockId:guiBlock  updated through self.updateGraphBlockTrack
        self.transparentBlockHandles = [] #transparentBlockHandles in correct order. updated through self.updateGraphBlockTrack


问题


面经


文章

微信
公众号

扫码关注公众号