How to use the qtpy.QtGui.QColor function in QtPy

To help you get started, we’ve selected a few QtPy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kcjengr / qtpyvcp / qtpyvcp / widgets / base_widgets / led_widget.py View on Github external
diameter = Property(int, getDiameter, setDiameter)
    color = Property(QColor, getColor, setColor)
    alignment = Property(Qt.Alignment, getAlignment, setAlignment)
    state = Property(bool, getState, setState)
    flashing = Property(bool, isFlashing, setFlashing)
    flashRate = Property(int, getFlashRate, setFlashRate)

if __name__ == "__main__":

    import sys

    app = QApplication(sys.argv)
    led = LEDWidget()
    # led.setState(False)
    led.setColor(QColor('green'))
    led.setDiameter(16)
    led.show()
    sys.exit(app.exec_())
github mihtjel / nanovna-saver / NanoVNASaver / skins.py View on Github external
def dark(app, self, _STYLESHEET):
        QT_VERSION = tuple(int(v) for v in qtpy.QT_VERSION.split('.'))
        darkPalette = QPalette()
        # base
        darkPalette.setColor(QPalette.WindowText, QColor(180, 180, 180))
        darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
        darkPalette.setColor(QPalette.Light, QColor(180, 180, 180))
        darkPalette.setColor(QPalette.Midlight, QColor(90, 90, 90))
        darkPalette.setColor(QPalette.Dark, QColor(35, 35, 35))
        darkPalette.setColor(QPalette.Text, QColor(180, 180, 180))
        darkPalette.setColor(QPalette.BrightText, QColor(180, 180, 180))
        darkPalette.setColor(QPalette.ButtonText, QColor(180, 180, 180))
        darkPalette.setColor(QPalette.Base, QColor(42, 42, 42))
        darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
        darkPalette.setColor(QPalette.Shadow, QColor(20, 20, 20))
        darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
        darkPalette.setColor(QPalette.HighlightedText, QColor(180, 180, 180))
        darkPalette.setColor(QPalette.Link, QColor(56, 252, 196))
        darkPalette.setColor(QPalette.AlternateBase, QColor(66, 66, 66))
        darkPalette.setColor(QPalette.ToolTipBase, QColor(53, 53, 53))
        darkPalette.setColor(QPalette.ToolTipText, QColor(180, 180, 180))

        # disabled
        darkPalette.setColor(QPalette.Disabled, QPalette.WindowText,
                             QColor(127, 127, 127))
        darkPalette.setColor(QPalette.Disabled, QPalette.Text,
                             QColor(127, 127, 127))
        darkPalette.setColor(QPalette.Disabled, QPalette.ButtonText,
                             QColor(127, 127, 127))
github kcjengr / qtpyvcp / qtpyvcp / widgets / hal_widgets / hal_plot.py View on Github external
try:
            self.legend.scene().removeItem(self.legend)
        except:
            pass

        # remove all plot items
        self.plot.clear()

        # add the legend and plot itmes
        if self._legend:
            self.legend = self.plot.addLegend()

        if self._s1enable:
            self.p1 = pg.PlotCurveItem(name=self._s1name)
            self.plot.addItem(self.p1)
            self.p1.setPen(QColor(self._s1colour), width=self._s1width, style=self._s1style)

        if self._s2enable:
            self.p2 = pg.PlotCurveItem(name=self._s2name)
            self.plot.addItem(self.p2)
            self.p2.setPen(QColor(self._s2colour), width=self._s2width, style=self._s2style)

        if self._s3enable:
            self.p3 = pg.PlotCurveItem(name=self._s3name)
            self.plot.addItem(self.p3)
            self.p3.setPen(QColor(self._s3colour), width=self._s3width, style=self._s3style)

        if self._s4enable:
            self.p4 = pg.PlotCurveItem(name=self._s4name)
            self.plot.addItem(self.p4)
            self.p4.setPen(QColor(self._s4colour), width=self._s4width, style=self._s4style)
github spyder-ide / spyder / spyder / plugins / editor / utils / editor.py View on Github external
def drift_color(base_color, factor=110):
    """
    Return color that is lighter or darker than the base color.

    If base_color.lightness is higher than 128, the returned color is darker
    otherwise is is lighter.

    :param base_color: The base color to drift from
    ;:param factor: drift factor (%)
    :return A lighter or darker color.
    """
    base_color = QColor(base_color)
    if base_color.lightness() > 128:
        return base_color.darker(factor)
    else:
        if base_color == QColor('#000000'):
            return drift_color(QColor('#101010'), factor + 20)
        else:
            return base_color.lighter(factor + 10)
github busimus / cutelog / cutelog / log_levels.py View on Github external
fgDark=None, bgDark=None, styles=set(), stylesDark=None, load=None):
        if load:
            self.loads(load)
            return

        self.levelname = levelname

        self.enabled = enabled
        self.styles = styles
        if not stylesDark:
            self.stylesDark = deepcopy(styles)
        else:
            self.stylesDark = stylesDark

        if not fg:
            self.fg = QColor(0, 0, 0)
        else:
            self.fg = fg
        if not bg:
            self.bg = QColor(255, 255, 255)
        else:
            self.bg = bg

        if not fgDark:
            self.fgDark = QColor(255, 255, 255)
        else:
            self.fgDark = fgDark
        if not bgDark:
            self.bgDark = QColor(0, 0, 0)
        else:
            self.bgDark = bgDark
github busimus / cutelog / cutelog / log_levels.py View on Github external
def loads(self, string):
        self.__dict__ = json.loads(string)
        self.styles = set(self.styles)
        self.stylesDark = set(self.stylesDark)
        self.fg, self.fgDark = QColor(self.fg), QColor(self.fgDark)
        self.bg, self.bgDark = QColor(self.bg), QColor(self.bgDark)
        return self
github spyder-ide / spyder / spyder / plugins / editor / panels / codefolding.py View on Github external
"""
        Add fold decorations (boxes arround a folded block in the editor
        widget).
        """
        start_line = block.blockNumber()
        text = self.editor.get_text_region(start_line + 1, end_line)
        draw_order = DRAW_ORDERS.get('codefolding')
        deco = TextDecoration(block, draw_order=draw_order)
        deco.signals.clicked.connect(self._on_fold_deco_clicked)
        deco.tooltip = text
        deco.block = block
        deco.select_line()
        deco.set_outline(drift_color(
            self._get_scope_highlight_color(), 110))
        deco.set_background(self._get_scope_highlight_color())
        deco.set_foreground(QColor('#808080'))
        self._block_decos.append(deco)
        self.editor.decorations.add(deco)
github avalentino / gsdview / gsdview / gdalbackend / widgets.py View on Github external
def _gray2qcolor(gray):
        qcolor = QtGui.QColor()
        qcolor.setRgb(gray, gray, gray)
        return qcolor
github spyder-ide / spyder / spyder / plugins / variableexplorer / widgets / collectionseditor.py View on Github external
def get_bgcolor(self, index):
        """Background color depending on value"""
        if index.column() == 0:
            color = QColor(Qt.lightGray)
            color.setAlphaF(.05)
        elif index.column() < 3:
            color = QColor(Qt.lightGray)
            color.setAlphaF(.2)
        else:
            color = QColor(Qt.lightGray)
            color.setAlphaF(.3)
        return color
github lneuhaus / pyrpl / pyrpl / widgets / module_widgets / scope_widget.py View on Github external
self.button_layout.addWidget(aws["curve_name"])


        #self.setLayout(self.main_layout)
        self.setWindowTitle("Scope")
        self.win = pg.GraphicsWindow(title="Scope")
        self.plot_item = self.win.addPlot(title="Scope")
        self.plot_item.showGrid(y=True, alpha=1.)


        #self.button_single = QtWidgets.QPushButton("Run single")
        #self.button_continuous = QtWidgets.QPushButton("Run continuous")
        #self.button_save = QtWidgets.QPushButton("Save curve")

        self.curves = [self.plot_item.plot(pen=(QtGui.QColor(color).red(),
                                                QtGui.QColor(color).green(),
                                                QtGui.QColor(color).blue()
                                                ))
                                                #,trans)) \
                       for color, trans in zip(self.ch_color,
                                               self.ch_transparency)]
        self.main_layout.addWidget(self.win, stretch=10)


        #self.button_layout.addWidget(self.button_single)
        #self.button_layout.addWidget(self.button_continuous)
        #self.button_layout.addWidget(self.button_save)
        #self.button_layout.addWidget(aws['curve_name'])
        #aws['curve_name'].setMaximumWidth(250)
        self.main_layout.addLayout(self.button_layout)

        #self.button_single.clicked.connect(self.run_single_clicked)