python类black()的实例源码

radar.py 文件源码 项目:echolocation 作者: hgross 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def draw_radar(self):
        """
        Discards the current content and redraws all elements on the graphic scene.
        """

        # decide which color to use
        bg_color, line_color = Qt.black, Qt.green

        self.scene.clear()
        self.scene.addRect(0, 0, self.width(), self.height(), brush=QBrush(bg_color))
        self._add_crosshair()
        self._add_circles(self.circle_count, self.add_text_labels)

        # for each measurement, draw a line
        for measurement in self.measurements:
            assert isinstance(measurement, Measurement)
            added_time = self.added_time[measurement]
            self._add_measurement(measurement.distance, measurement.angle, added_time)

        # for the latest 2 measurements, draw an angle visualizer
        for measurement in self.measurements[-2:]:
            self._add_latest_input_line(measurement.angle)
lab10.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 23 收藏 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)|")
lab8.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 26 收藏 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)
lab9.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 22 收藏 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.poly.clicked.connect(lambda : set_pol(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.clip = []
        self.pol = []
        self.point_now_clip = None
        self.point_now_pol = None
        self.point_lock_pol = None
        self.point_lock_clip = None
        self.input_pol = False
        self.input_clip = False
        self.pen = QPen(black)
lab4.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 22 收藏 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))
videostyle.py 文件源码 项目:vidcutter 作者: ozmartian 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def __init__(self):
        super(VideoStyleDark, self).__init__()
        palette = qApp.palette()
        palette.setColor(QPalette.Window, QColor(27, 35, 38))
        palette.setColor(QPalette.WindowText, QColor(234, 234, 234))
        palette.setColor(QPalette.Base, QColor(27, 35, 38))
        palette.setColor(QPalette.AlternateBase, QColor(12, 15, 16))
        palette.setColor(QPalette.ToolTipBase, QColor(27, 35, 38))
        palette.setColor(QPalette.ToolTipText, Qt.white)
        palette.setColor(QPalette.Text, QColor(234, 234, 234))
        palette.setColor(QPalette.Button, QColor(27, 35, 38))
        palette.setColor(QPalette.ButtonText, Qt.white)
        palette.setColor(QPalette.BrightText, QColor(100, 215, 222))
        palette.setColor(QPalette.Link, QColor(126, 71, 130))
        palette.setColor(QPalette.Highlight, QColor(126, 71, 130))
        palette.setColor(QPalette.HighlightedText, Qt.white)
        palette.setColor(QPalette.Disabled, QPalette.Light, Qt.black)
        palette.setColor(QPalette.Disabled, QPalette.Shadow, QColor(12, 15, 16))
        qApp.setPalette(palette)
glyphCellFactory.py 文件源码 项目:defconQt 作者: trufont 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def drawCellGlyph(self, painter):
        if self.shouldDrawLayers:
            layers = self.font.layers
            for layerName in reversed(layers.layerOrder):
                layer = layers[layerName]
                if self.glyph.name not in layer:
                    continue
                layerColor = None
                if layer.color is not None:
                    layerColor = colorToQColor(layer.color)
                if layerColor is None:
                    layerColor = Qt.black
                glyph = layer[self.glyph.name]
                path = glyph.getRepresentation("defconQt.QPainterPath")
                painter.fillPath(path, layerColor)
        else:
            path = self.glyph.getRepresentation("defconQt.QPainterPath")
            painter.fillPath(path, Qt.black)
spreadsheetitem.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def data(self, role):
        if role in (Qt.EditRole, Qt.StatusTipRole):
            return self.formula()
        if role == Qt.DisplayRole:
            return self.display()
        t = str(self.display())
        try:
            number = int(t)
        except ValueError:
            number = None
        if role == Qt.TextColorRole:
            if number is None:
                return QColor(Qt.black)
            elif number < 0:
                return QColor(Qt.red)
            return QColor(Qt.blue)

        if role == Qt.TextAlignmentRole:
            if t and (t[0].isdigit() or t[0] == '-'):
                return Qt.AlignRight | Qt.AlignVCenter
        return super(SpreadSheetItem, self).data(role)
camera.py 文件源码 项目:Mac-Python-3.X 作者: L1nwatch 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def updateLockStatus(self, status, reason):
        indicationColor = Qt.black

        if status == QCamera.Searching:
            self.ui.statusbar.showMessage("Focusing...")
            self.ui.lockButton.setText("Focusing...")
            indicationColor = Qt.yellow
        elif status == QCamera.Locked:
            self.ui.lockButton.setText("Unlock")
            self.ui.statusbar.showMessage("Focused", 2000)
            indicationColor = Qt.darkGreen
        elif status == QCamera.Unlocked:
            self.ui.lockButton.setText("Focus")

            if reason == QCamera.LockFailed:
                self.ui.statusbar.showMessage("Focus Failed", 2000)
                indicationColor = Qt.red

        palette = self.ui.lockButton.palette()
        palette.setColor(QPalette.ButtonText, indicationColor)
        self.ui.lockButton.setPalette(palette)
spreadsheetitem.py 文件源码 项目:examples 作者: pyqt 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def data(self, role):
        if role in (Qt.EditRole, Qt.StatusTipRole):
            return self.formula()
        if role == Qt.DisplayRole:
            return self.display()
        t = str(self.display())
        try:
            number = int(t)
        except ValueError:
            number = None
        if role == Qt.TextColorRole:
            if number is None:
                return QColor(Qt.black)
            elif number < 0:
                return QColor(Qt.red)
            return QColor(Qt.blue)

        if role == Qt.TextAlignmentRole:
            if t and (t[0].isdigit() or t[0] == '-'):
                return Qt.AlignRight | Qt.AlignVCenter
        return super(SpreadSheetItem, self).data(role)
camera.py 文件源码 项目:examples 作者: pyqt 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def updateLockStatus(self, status, reason):
        indicationColor = Qt.black

        if status == QCamera.Searching:
            self.ui.statusbar.showMessage("Focusing...")
            self.ui.lockButton.setText("Focusing...")
            indicationColor = Qt.yellow
        elif status == QCamera.Locked:
            self.ui.lockButton.setText("Unlock")
            self.ui.statusbar.showMessage("Focused", 2000)
            indicationColor = Qt.darkGreen
        elif status == QCamera.Unlocked:
            self.ui.lockButton.setText("Focus")

            if reason == QCamera.LockFailed:
                self.ui.statusbar.showMessage("Focus Failed", 2000)
                indicationColor = Qt.red

        palette = self.ui.lockButton.palette()
        palette.setColor(QPalette.ButtonText, indicationColor)
        self.ui.lockButton.setPalette(palette)
spreadsheetitem.py 文件源码 项目:pyqt5-example 作者: guinslym 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def data(self, role):
        if role in (Qt.EditRole, Qt.StatusTipRole):
            return self.formula()
        if role == Qt.DisplayRole:
            return self.display()
        t = str(self.display())
        try:
            number = int(t)
        except ValueError:
            number = None
        if role == Qt.TextColorRole:
            if number is None:
                return QColor(Qt.black)
            elif number < 0:
                return QColor(Qt.red)
            return QColor(Qt.blue)

        if role == Qt.TextAlignmentRole:
            if t and (t[0].isdigit() or t[0] == '-'):
                return Qt.AlignRight | Qt.AlignVCenter
        return super(SpreadSheetItem, self).data(role)
samplebuffers.py 文件源码 项目:pyqt5-example 作者: guinslym 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def paintGL(self):
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)

        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glPushMatrix()
        GL.glEnable(GLWidget.GL_MULTISAMPLE)
        GL.glTranslatef( -0.25, -0.10, 0.0)
        GL.glScalef(0.75, 1.15, 0.0)
        GL.glRotatef(GLWidget.rot, 0.0, 0.0, 1.0)
        GL.glCallList(self.list_)
        GL.glPopMatrix()

        GL.glPushMatrix()
        GL.glDisable(GLWidget.GL_MULTISAMPLE)
        GL.glTranslatef(0.25, -0.10, 0.0)
        GL.glScalef(0.75, 1.15, 0.0)
        GL.glRotatef(GLWidget.rot, 0.0, 0.0, 1.0)
        GL.glCallList(self.list_)
        GL.glPopMatrix()

        GLWidget.rot += 0.2

        self.qglColor(Qt.black)
        self.renderText(-0.35, 0.4, 0.0, "Multisampling enabled")
        self.renderText(0.15, 0.4, 0.0, "Multisampling disabled")
GUI.py 文件源码 项目:coliform-project 作者: uprm-research-resto 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def initUI(self):

        # QToolTip.setFont(QFont('SansSerif', 9))

        self.cwidget = GUICenterWidget()
        self.setCentralWidget(self.cwidget)

        # self.setToolTip('This is a <b>QWidget</b> widget')

        self.statusBar().showMessage('Ready')

        self.center()
        self.setWindowTitle('Coliform Control GUI')

        self.onewiretimer = QTimer(self)
        self.onewiretimer.timeout.connect(self.cwidget.onewireOn)
        self.onewiretimer.start(1000)

        # self.p = QPalette(self.palette())
        # self.p.setColor(QPalette.Window, QColor(53, 53, 53))
        # self.p.setColor(QPalette.WindowText, Qt.white)
        # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ToolTipBase, Qt.white)
        # self.p.setColor(QPalette.ToolTipText, Qt.white)
        # self.p.setColor(QPalette.Button, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ButtonText, Qt.white)
        # self.p.setColor(QPalette.BrightText, Qt.red)
        # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter())
        # self.p.setColor(QPalette.HighlightedText, Qt.black)
        # self.setPalette(self.p)

        self.show()
GUI.py 文件源码 项目:coliform-project 作者: uprm-research-resto 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def initUI(self):

        # QToolTip.setFont(QFont('SansSerif', 9))

        self.cwidget = CameraCenterWidget()
        self.setCentralWidget(self.cwidget)

        # self.setToolTip('This is a <b>QWidget</b> widget')

        self.center()
        self.setWindowTitle('Camera Control GUI')

        self.statusBarTimer = QTimer(self)
        self.statusBarTimer.timeout.connect(self.statusUpdate)
        self.statusBarTimer.start(100)

        # self.p = QPalette(self.palette())
        # self.p.setColor(QPalette.Window, QColor(53, 53, 53))
        # self.p.setColor(QPalette.WindowText, Qt.white)
        # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ToolTipBase, Qt.white)
        # self.p.setColor(QPalette.ToolTipText, Qt.white)
        # self.p.setColor(QPalette.Button, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ButtonText, Qt.white)
        # self.p.setColor(QPalette.BrightText, Qt.red)
        # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter())
        # self.p.setColor(QPalette.HighlightedText, Qt.black)
        # self.setPalette(self.p)

        self.show()
GUI.py 文件源码 项目:coliform-project 作者: uprm-research-resto 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def initUI(self):

        # QToolTip.setFont(QFont('SansSerif', 9))

        self.cwidget = RGBCenterWidget()
        self.setCentralWidget(self.cwidget)

        # self.setToolTip('This is a <b>QWidget</b> widget')

        self.center()
        self.setWindowTitle('RGB Sensor GUI')

        self.statusBarTimer = QTimer(self)
        self.statusBarTimer.timeout.connect(self.statusUpdate)
        self.statusBarTimer.start(100)

        # self.p = QPalette(self.palette())
        # self.p.setColor(QPalette.Window, QColor(53, 53, 53))
        # self.p.setColor(QPalette.WindowText, Qt.white)
        # self.p.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ToolTipBase, Qt.white)
        # self.p.setColor(QPalette.ToolTipText, Qt.white)
        # self.p.setColor(QPalette.Button, QColor(53, 53, 53))
        # self.p.setColor(QPalette.ButtonText, Qt.white)
        # self.p.setColor(QPalette.BrightText, Qt.red)
        # self.p.setColor(QPalette.Highlight, QColor(142, 45, 197).lighter())
        # self.p.setColor(QPalette.HighlightedText, Qt.black)
        # self.setPalette(self.p)

        self.show()
map.py 文件源码 项目:satellite-tracker 作者: lofaldli 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def pen(self, color=Qt.black, style=Qt.SolidLine):
        pen = QPen(color)
        pen.setStyle(style)
        return pen
lab10.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def draw(win):
    win.scene.clear()
    win.image.fill(black)
    tx = win.dial_x.value()
    ty = win.dial_y.value()
    tz = win.dial_z.value()

    if win.funcs.currentText() == "cos(x) * sin(z)":
        f = f1

    if win.funcs.currentText() == "2 * cos(x * z)":
        f = f2

    if win.funcs.currentText() == "exp(sin(sqrt(x^2 + z^2)))":
        f = f3

    if win.funcs.currentText() == "x^2 / 20 + z^2 / 20":
        f = f4

    if win.funcs.currentText() == "|sin(x) * sin(z)|":
        f = f5

    win.image = float_horizon(win.scene.width(), win.scene.height(), win.x_min.value(), win.x_max.value(), win.dx.value(),
            win.z_min.value(), win.z_max.value(), win.dz.value(), tx, ty, tz, f, win.image)

    pix = QPixmap()
    pix.convertFromImage(win.image)
    win.scene.addPixmap(pix)
lab8.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def add_point(point):
    global w
    if w.input_rect:
        w.pen.setColor(black)
        if w.point_now_rect is None:
            w.point_now_rect = point
            w.point_lock = point
            add_row(w.table_rect)
            i = w.table_rect.rowCount() - 1
            item_x = QTableWidgetItem("{0}".format(point.x()))
            item_y = QTableWidgetItem("{0}".format(point.y()))
            w.table_rect.setItem(i, 0, item_x)
            w.table_rect.setItem(i, 1, item_y)
        else:
            w.edges.append(point)
            w.point_now_rect = point
            add_row(w.table_rect)
            i = w.table_rect.rowCount() - 1
            item_x = QTableWidgetItem("{0}".format(point.x()))
            item_y = QTableWidgetItem("{0}".format(point.y()))
            w.table_rect.setItem(i, 0, item_x)
            w.table_rect.setItem(i, 1, item_y)
            item_x = w.table_rect.item(i-1, 0)
            item_y = w.table_rect.item(i-1, 1)
            w.scene.addLine(point.x(), point.y(), float(item_x.text()), float(item_y.text()), w.pen)
    if w.input_bars:
        w.pen.setColor(red)
        if w.point_now_bars is None:
            w.point_now_bars = point
        else:
            w.lines.append([[w.point_now_bars.x(), w.point_now_bars.y()],
                            [point.x(), point.y()]])

            add_row(w.table_bars)
            i = w.table_bars.rowCount() - 1
            item_b = QTableWidgetItem("[{0}, {1}]".format(w.point_now_bars.x(), w.point_now_bars.y()))
            item_e = QTableWidgetItem("[{0}, {1}]".format(point.x(), point.y()))
            w.table_bars.setItem(i, 0, item_b)
            w.table_bars.setItem(i, 1, item_e)
            w.scene.addLine(w.point_now_bars.x(), w.point_now_bars.y(), point.x(), point.y(), w.pen)
            w.point_now_bars = None
lab3.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 26 收藏 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_line.clicked.connect(lambda: draw_line(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_sun.clicked.connect(lambda: draw_sun(self))
        self.cda.setChecked(True)
lab3.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_color_line(win):
    color = QtWidgets.QColorDialog.getColor(initial=Qt.black, title='???? ?????',
                                            options=QtWidgets.QColorDialog.DontUseNativeDialog)
    if color.isValid():
        win.color_line = color
        win.pen.setColor(color)
        s = QtWidgets.QGraphicsScene(0, 0, 10, 10)
        s.setBackgroundBrush(color)
        win.line_color.setScene(s)
lab4.py 文件源码 项目:Computer-graphics 作者: Panda-Lewandowski 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_color_line(win):
    color = QtWidgets.QColorDialog.getColor(initial=Qt.black, title='???? ?????',
                                            options=QtWidgets.QColorDialog.DontUseNativeDialog)
    if color.isValid():
        win.color_line = color
        win.pen.setColor(color)
        s = QtWidgets.QGraphicsScene(0, 0, 10, 10)
        s.setBackgroundBrush(color)
        win.line_color.setScene(s)
baseModule.py 文件源码 项目:pyree-old 作者: DrLuke 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def selectedChanged(self, state):
        if state:
            self.mainRect.setPen(QPen(Qt.red))
        else:
            self.mainRect.setPen(QPen(Qt.black))
mpvQC.py 文件源码 项目:mpvQC 作者: Frechdachs 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, parent=None):
        super(MpvWidget, self).__init__(parent)
        # Make the frame black, so that the video frame
        # is distinguishable from the rest when no
        # video is loaded yet
        self.setStyleSheet("background-color:black;")
        self.setMouseTracking(True)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.contextMenu)
        self.cursortimer = QTimer(self)
        self.cursortimer.setSingleShot(True)
        self.cursortimer.timeout.connect(hideCursor)
paint.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def paintEvent(self, event):
      qp = QPainter(self)

      qp.setPen(Qt.black)
      size = self.size()

      for i in range(1024):
          x = random.randint(1, size.width()-1)
          y = random.randint(1, size.height()-1)
          qp.drawPoint(x, y)
colors.py 文件源码 项目:VIRTUAL-PHONE 作者: SumanKanrar-IEM 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def paintEvent(self, event):
      qp = QPainter(self)

      qp.setPen(Qt.black)
      size = self.size()

      # Colored rectangles
      qp.setBrush(QColor(200, 0, 0))
      qp.drawRect(0, 0, 100, 100)

      qp.setBrush(QColor(0, 200, 0))
      qp.drawRect(100, 0, 100, 100)

      qp.setBrush(QColor(0, 0, 200))
      qp.drawRect(200, 0, 100, 100)

      # Color Effect
      for i in range(0,100):
          qp.setBrush(QColor(i*10, 0, 0))
          qp.drawRect(10*i, 100, 10, 32)

          qp.setBrush(QColor(i*10, i*10, 0))
          qp.drawRect(10*i, 100+32, 10, 32)

          qp.setBrush(QColor(i*2, i*10, i*1))
          qp.drawRect(10*i, 100+64, 10, 32)
graphicseffects.py 文件源码 项目:vidcutter 作者: ozmartian 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def draw(self, painter: QPainter) -> None:
        if self.sourceIsPixmap():
            pixmap, offset = self.sourcePixmap(Qt.LogicalCoordinates, QGraphicsEffect.PadToEffectiveBoundingRect)
        else:
            pixmap, offset = self.sourcePixmap(Qt.DeviceCoordinates, QGraphicsEffect.PadToEffectiveBoundingRect)
            painter.setWorldTransform(QTransform())
        painter.setBrush(Qt.black)
        painter.drawRect(pixmap.rect())
        painter.setOpacity(self.opacity)
        painter.drawPixmap(offset, pixmap)
videolist.py 文件源码 项目:vidcutter 作者: ozmartian 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
        thumb = QIcon(index.data(Qt.DecorationRole + 1))
        starttime = index.data(Qt.DisplayRole + 1)
        endtime = index.data(Qt.UserRole + 1)
        externalPath = index.data(Qt.UserRole + 2)
        r = option.rect.adjusted(5, 0, 0, 0)
        thumb.paint(painter, r, Qt.AlignVCenter | Qt.AlignLeft)
        painter.setPen(QPen(pencolor, 1, Qt.SolidLine))
        r = option.rect.adjusted(110, 8, 0, 0)
        painter.setFont(QFont('Noto Sans UI', 10 if sys.platform == 'darwin' else 8, QFont.Bold))
        painter.drawText(r, Qt.AlignLeft, 'FILENAME' if len(externalPath) else 'START')
        r = option.rect.adjusted(110, 20, 0, 0)
        painter.setFont(QFont('Noto Sans UI', 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, 45, 0, 0)
            painter.setFont(QFont('Noto Sans UI', 10 if sys.platform == 'darwin' else 8, QFont.Bold))
            painter.drawText(r, Qt.AlignLeft, 'RUNTIME' if len(externalPath) else 'END')
            r = option.rect.adjusted(110, 60, 0, 0)
            painter.setFont(QFont('Noto Sans UI', 11 if sys.platform == 'darwin' else 9, QFont.Normal))
            painter.drawText(r, Qt.AlignLeft, endtime)
        if self.parent.verticalScrollBar().isVisible():
            self.parent.setFixedWidth(210)
        else:
            self.parent.setFixedWidth(190)
UIDockerfileEditor.py 文件源码 项目:BiocImageBuilder 作者: Bioconductor-notebooks 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _text_format(self, foreground=Qt.black, weight=QFont.Normal):
        fmt = QTextCharFormat()
        fmt.setForeground(QBrush(foreground))
        fmt.setFontWeight(weight)
        return fmt
funcgraph.py 文件源码 项目:vivisect-py3 作者: bat-serjo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def paint(self, painter, option, widget):
        if not self.source or not self.dest:
            return

        # Draw the line itself.
        line = QLineF(self.sourcePoint, self.destPoint)

        if line.length() == 0.0:
            return

        painter.setPen(QPen(Qt.black, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawLine(line)

        # Draw the arrows if there's enough room.
        angle = math.acos(line.dx() / line.length())
        if line.dy() >= 0:
            angle = VGraphEdge.TwoPi - angle

        sourceArrowP1 = self.sourcePoint + QPointF(math.sin(angle + VGraphEdge.Pi / 3) * self.arrowSize,
                                                          math.cos(angle + VGraphEdge.Pi / 3) * self.arrowSize)
        sourceArrowP2 = self.sourcePoint + QPointF(math.sin(angle + VGraphEdge.Pi - VGraphEdge.Pi / 3) * self.arrowSize,
                                                          math.cos(angle + VGraphEdge.Pi - VGraphEdge.Pi / 3) * self.arrowSize);
        destArrowP1 = self.destPoint + QPointF(math.sin(angle - VGraphEdge.Pi / 3) * self.arrowSize,
                                                      math.cos(angle - VGraphEdge.Pi / 3) * self.arrowSize)
        destArrowP2 = self.destPoint + QPointF(math.sin(angle - VGraphEdge.Pi + VGraphEdge.Pi / 3) * self.arrowSize,
                                                      math.cos(angle - VGraphEdge.Pi + VGraphEdge.Pi / 3) * self.arrowSize)

        painter.setBrush(Qt.black)
        painter.drawPolygon(QPolygonF([line.p1(), sourceArrowP1, sourceArrowP2]))
        painter.drawPolygon(QPolygonF([line.p2(), destArrowP1, destArrowP2]))


问题


面经


文章

微信
公众号

扫码关注公众号