Python PyQt5.QtGui.QColor() Examples

The following are code examples for showing how to use PyQt5.QtGui.QColor(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: JI-Live-Danmu-Client   Author: SJTU-UMJI-Tech   File: Marquee.py    MIT License 6 votes vote down vote up
def changeColor(self):
        if self.changeIdx < self.CHANGE_TIMES:
            pa = QPalette()
            pa.setColor(
                QPalette.Foreground,
                QColor(
                    self.RAINBOW_RGB_LIST[self.clrIdx][0] +
                    self.changeRGB[0] / self.CHANGE_TIMES * self.changeIdx,
                    self.RAINBOW_RGB_LIST[self.clrIdx][1] +
                    self.changeRGB[1] / self.CHANGE_TIMES * self.changeIdx,
                    self.RAINBOW_RGB_LIST[self.clrIdx][2] +
                    self.changeRGB[2] / self.CHANGE_TIMES * self.changeIdx))
            self.label.setPalette(pa)
            self.changeIdx += 1
            self.show()
        else:
            self.changeIdx = 0
            self.clrIdx = 0 if self.clrIdx == 6 else self.clrIdx + 1
            self.setChangeRGB(self.RAINBOW_RGB_LIST[self.clrIdx],
                              self.RAINBOW_RGB_LIST[(self.clrIdx + 1) % 7]) 
Example 2
Project: JI-Live-Danmu-Client   Author: SJTU-UMJI-Tech   File: DanmuManager.py    MIT License 6 votes vote down vote up
def parseText(self, text):
        textColor = QColor(240, 240, 240)
        style = 'fly'
        matchObject = re.search(
            r'\#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})', text)
        if matchObject:
            textColor = QColor(
                int(matchObject.group(1), 16), int(matchObject.group(2), 16),
                int(matchObject.group(3), 16))
            text = re.sub(r'\#[0-9a-fA-F]{6}', '', text)
        if re.search(r'\#top', text, re.I):
            style = 'top'
            text = re.sub(r'\#top', '', text, re.I)
        elif re.search(r'\#btm', text, re.I):
            style = 'btm'
            text = re.sub(r'\#btm', '', text, re.I)
        return text, textColor, style 
Example 3
Project: JI-Live-Danmu-Client   Author: SJTU-UMJI-Tech   File: Danmu.py    MIT License 6 votes vote down vote up
def __init__(self, text, color, top, window):
        super(Danmu, self).__init__(window)
        # clean invalid characters
        text = re.sub(r'/Emoji\d+|/表情|^ | $', '',
                      text.replace('\n', ' '))[0:MAX_STR_LEN]
        self.top = top
        self.setTextFormat(Qt.PlainText)
        self.setText(text)
        # self.setWindowFlags(Qt.FramelessWindowHint)
        # self.setAttribute(Qt.WA_TranslucentBackground)
        self.setAttribute(Qt.WA_TransparentForMouseEvents, True)
        self.setFont(QFont('SimHei', FONT_SIZE, 100))
        # set size of label
        myRect = self.fontMetrics().boundingRect(text)
        self.setFixedSize(myRect.width() + 20, myRect.height() + 10)
        self.setColor(color)
        self.setShadow(QColor('#060606'), 5, 1.5)
        # self.setStyleSheet("border:1px solid red;") 
Example 4
Project: dcc   Author: amimo   File: DisasmViewMode.py    Apache License 2.0 6 votes vote down vote up
def drawCursor(self, qp):
        cursorX, cursorY = self.cursor.getPosition()

        log.debug("%s / %s", cursorX, cursorY)

        xstart = cursorX

        if cursorY not in self.OPCODES:
            log.warning("Impossible to find instruction at cursor %d, %d" % (cursorY, len(self.OPCODES)))
            return

        asm = self.OPCODES[cursorY]
        width = asm.getSelectionWidth(xstart)

        qp.setBrush(QtGui.QColor(255, 255, 0))

        qp.setOpacity(0.5)
        qp.drawRect(xstart * self.fontWidth,
                    cursorY * self.fontHeight,
                    width * self.fontWidth,
                    self.fontHeight + 2)
        qp.setOpacity(1) 
Example 5
Project: dcc   Author: amimo   File: HexViewMode.py    Apache License 2.0 6 votes vote down vote up
def drawAdditionals(self):
        self.newPix = self._getNewPixmap(self.width, self.height + self.SPACER)
        qp = QtGui.QPainter()
        qp.begin(self.newPix)
        qp.drawPixmap(0, 0, self.qpix)

        # self.transformationEngine.decorateText()

        # highlight selected text
        self.selector.highlightText()

        # draw other selections
        self.selector.drawSelections(qp)

        # draw our cursor
        self.drawCursor(qp)

        # draw dword lines
        for i in range(self.COLUMNS // 4)[1:]:
            xw = i * 4 * 3 * self.fontWidth - 4
            qp.setPen(QtGui.QColor(0, 255, 0))
            qp.drawLine(xw, 0, xw, self.ROWS * self.fontHeight)

        qp.end() 
Example 6
Project: dcc   Author: amimo   File: BinViewMode.py    Apache License 2.0 6 votes vote down vote up
def handleEditMode(self, modifiers, key, event):
        if key in range(0, 256):
            offs = self.getCursorOffsetInPage()

            self.dataModel.setData_b(self.dataModel.getOffset() + offs, str(event.text()))

            z = self.dataModel.getOffset() + offs
            # TODO: sa nu se repete, tre original_transformengine
            self.transformationEngine = RangePen(self.original_textdecorator, z, z + 0,
                                                 QtGui.QPen(QtGui.QColor(218, 94, 242), 0, QtCore.Qt.SolidLine),
                                                 ignoreHighlights=True)

            self.moveCursor(Directions.Right)

            x, y = self.cursor.getPosition()

            self.draw(refresh=True, row=y, howMany=1) 
Example 7
Project: raster-vision-qgis   Author: azavea   File: label_loader.py    GNU General Public License v3.0 6 votes vote down vote up
def _make_vector_renderer(layer, class_field, class_map):
        category_map = {}

        colors = ['Blue', 'Red', 'Green', 'Yellow']

        for i, class_item in enumerate(class_map.get_items()):
            name = class_item.name
            color = class_item.color
            if color is None:
                color = colors[i % len(colors)]
            category_map[name] = (color, name)

        categories = []
        for name, (color, label) in category_map.items():
            symbol = QgsSymbol.defaultSymbol(layer.geometryType())
            symbol_layer = QgsSimpleLineSymbolLayer()
            symbol_layer.setWidth(0.5)
            symbol.changeSymbolLayer(0, symbol_layer)
            symbol.setColor(QColor(color))

            category = QgsRendererCategory(label, symbol, name)
            categories.append(category)

        renderer = QgsCategorizedSymbolRenderer(class_field, categories)
        return renderer 
Example 8
Project: Python-GUI   Author: arpitj07   File: Project.py    MIT License 6 votes vote down vote up
def boxclose(self):
        teamname = self.open_screen.OpenTheTeam.text()
        myteam= sqlite3.connect('TEAM.db')
        curser= myteam.cursor()
        curser.execute("SELECT PLAYERS from team WHERE NAMES= '"+teamname+"';")
        hu= curser.fetchall()
        self.listWidget.clear()
        for i in range(len(hu)):
            item= QtWidgets.QListWidgetItem(hu[i][0])
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            item.setFont(font)
            item.setBackground(QtGui.QColor('sea green'))
            self.listWidget.addItem(item)
            
        self.openDialog.close() 
Example 9
Project: cct   Author: awacha   File: backgroundsubtractionmodel.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def data(self, index: QtCore.QModelIndex, role: int = ...):
        if role == QtCore.Qt.TextColorRole:
            if (self._samples[index.row()][index.column()] is None) and (index.column() < 2):
                return QtGui.QColor('gray')
            else:
                return None
        elif role in [QtCore.Qt.DisplayRole, QtCore.Qt.EditRole]:
            if index.column() < 2:
                if self._samples[index.row()][index.column()] is None:
                    if role == QtCore.Qt.DisplayRole:
                        return 'Select sample...'
                    else:
                        return ''
            return self._samples[index.row()][index.column()]
        elif role == QtCore.Qt.CheckStateRole:
            if index.column() == 0:
                return [QtCore.Qt.Unchecked, QtCore.Qt.Checked][self._samples[index.row()][3]]
            else:
                return None
        return None 
Example 10
Project: cct   Author: awacha   File: motorconfig.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def resetEntryBackgrounds(self):
        for widget in [self.driveRMSCurrentDoubleSpinBox,
                       self.standbyRMSCurrentDoubleSpinBox,
                       self.freewheelingDelayDoubleSpinBox,
                       self.pulseDivisorSpinBox,
                       self.rampDivisorSpinBox,
                       self.microstepExponentSpinBox,
                       self.rawMaxSpeedSpinBox,
                       self.rawMaxAccelSpinBox,
                       self.leftSwitchEnabledCheckBox,
                       self.rightSwitchEnabledCheckBox,
                       self.leftLimitDoubleSpinBox,
                       self.rightLimitDoubleSpinBox]:
            pal = widget.palette()
            pal.setColor(pal.Base, QtGui.QColor('white'))
            widget.setPalette(pal) 
Example 11
Project: cct   Author: awacha   File: circulator.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def setFlagBackground(self, flag: QtWidgets.QLabel, state: bool, label: Optional[str] = None):
        palette = flag.palette()
        assert isinstance(palette, QtGui.QPalette)
        if state is None:
            palette.setColor(QtGui.QPalette.Window, QtGui.QColor('gray'))
            palette.setColor(QtGui.QPalette.Foreground, QtGui.QColor('black'))
        elif state:
            palette.setColor(QtGui.QPalette.Window, QtGui.QColor('lightgreen'))
            palette.setColor(QtGui.QPalette.Foreground, QtGui.QColor('black'))
        else:
            palette.setColor(QtGui.QPalette.Window, QtGui.QColor('red'))
            palette.setColor(QtGui.QPalette.Foreground, QtGui.QColor('white'))
        flag.setPalette(palette)
        flag.setAutoFillBackground(True)
        if label is not None:
            flag.setText(label) 
Example 12
Project: musaic   Author: al165   File: sliders.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.valueChanged.connect(self.repaint)

        self.setObjectName("QBoxSlider")

        self.setSizePolicy(
            QtWidgets.QSizePolicy.MinimumExpanding,
            QtWidgets.QSizePolicy.MinimumExpanding
        )

        self.setMinimumHeight(10)
        self.setMinimumWidth(30)

        self._forground_color = QtGui.QColor('#5A5A5A')
        self._text_color = None

        self._minimum = 0
        self._maximum = 100

        self._value = 0

        self._show_text = True 
Example 13
Project: musaic   Author: al165   File: sliders.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, minimum=0, maximum=128, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.setObjectName("QBoxRangeSlider")

        self.setSizePolicy(
            QtWidgets.QSizePolicy.MinimumExpanding,
            QtWidgets.QSizePolicy.MinimumExpanding
        )

        self.setMinimumHeight(10)
        self.setMinimumWidth(30)

        self._forground_color = QtGui.QColor('#5A5A5A')
        self._text_color = None

        self._minimum = minimum
        self._maximum = maximum

        self._left = minimum
        self._right = maximum

        self._show_text = True

        self.rangeChanged.connect(self.repaint) 
Example 14
Project: musaic   Author: al165   File: sliders.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, minimum=0, maximum=10, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self._sensitivity = 200

        self._emit = True

        self._value = minimum
        self.valueChanged.connect(self.repaint)

        self._minimum = minimum
        self._maximum = maximum

        self.minimum = minimum
        self.maximum = maximum
        self.value = minimum

        self._color = QtGui.QColor('#5A5A5A') 
Example 15
Project: musaic   Author: al165   File: sliders.py    GNU General Public License v3.0 6 votes vote down vote up
def paintEvent(self, e):
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        rect = painter.device().rect()

        radius = min(rect.width(), rect.height())/2

        pc = (self.value - self.minimum) / (self.maximum - self.minimum)

        a = 4.18879 - pc*5.23599
        x = math.cos(a) * (radius-1) + radius
        y = -math.sin(a) * (radius-1) + radius

        pen = QtGui.QPen()
        pen.setWidth(2)
        pen.setColor(self._color)
        painter.setPen(pen)
        painter.drawArc(1, 1, 2*radius-1, 2*radius-1, -120*16, -300*16)
        pen.setColor(QtGui.QColor('#DDDDDD'))
        painter.setPen(pen)
        painter.drawLine(radius, radius, x, y) 
Example 16
Project: SpriteMator   Author: rafaelvasco   File: draggable_list_base_widget.py    Apache License 2.0 6 votes vote down vote up
def __init__(self, parent, label):

        self._top = 0
        self._index = 0
        self._list = parent
        self._height = parent.item_height
        self._hovered = False
        self._selected = False
        self._dragging = False
        self._label = label
        self._hit = False
        self._backColor = QColor(51, 57, 64)
        self._borderColor = QColor(132, 148, 165)
        self._backColorSelected = QColor(47, 74, 96)
        self._borderColorSelected = QColor(101, 172, 227)

    #------------------------------------------------------------------------------- 
Example 17
Project: SpriteMator   Author: rafaelvasco   File: options_bar_widget.py    Apache License 2.0 6 votes vote down vote up
def __init__(self, canvas):
        super(OptionsBar, self).__init__()

        self._layout = QHBoxLayout()
        self._layout.setContentsMargins(0, 0, 0, 0)
        self.setContentsMargins(0, 0, 0, 0)
        self._layout.setAlignment(Qt.AlignLeft)
        self._backgroundColor = QColor(10, 10, 10)

        self._toggleGridButton = QPushButton()
        self._toggleOnionSkinButton = QPushButton()
        self._toggleLightsButton = QPushButton()

        self._initialize_components(canvas)
        self._initialize_style()

        self.setLayout(self._layout) 
Example 18
Project: eddy   Author: obdasystems   File: description.py    GNU General Public License v3.0 6 votes vote down vote up
def insertURL(self, url, alias):
        """
        Executed to insert a URL in the description.
        :param url: the URL to insert
        :type url: str
        :param alias: the URL anchor text
        :type alias: str
        """
        linkFormat = QtGui.QTextCharFormat()
        linkFormat.setForeground(QtGui.QColor("blue"))
        linkFormat.setFont(self.text.currentFont())
        linkFormat.setFontPointSize(self.text.fontPointSize())
        linkFormat.setAnchorHref(url)
        linkFormat.setFontUnderline(True)
        linkFormat.setAnchor(True)
        linkFormat.setToolTip(url)
        cursor = self.text.textCursor()
        cursor.insertText(alias if alias else url, linkFormat)
        cursor.insertText(" ", self.defaultCharFormat) 
Example 19
Project: eddy   Author: obdasystems   File: description.py    GNU General Public License v3.0 6 votes vote down vote up
def insertWikiTag(self, wikiTagURL, wikiLabel):
        """
        Executed to insert a wiki tag.
        :param wikiTag: the wiki tag URL to insert
        :type wikiTagURL: str
        :param wikiLabel: the wiki tag label to insert
        :type wikiLabel: str
        """
        linkFormat = QtGui.QTextCharFormat()
        linkFormat.setForeground(QtGui.QColor("blue"))
        linkFormat.setFont(self.text.currentFont())
        linkFormat.setFontPointSize(self.text.fontPointSize())
        linkFormat.setFontUnderline(True)
        linkFormat.setAnchor(True)
        linkFormat.setAnchorHref(wikiTagURL)
        linkFormat.setToolTip(wikiTagURL)

        self.text.textCursor().insertText(wikiLabel, linkFormat)
        self.text.textCursor().insertText(" ", self.defaultCharFormat) 
Example 20
Project: eddy   Author: obdasystems   File: view.py    GNU General Public License v3.0 6 votes vote down vote up
def setGridSize(self, size):
        """
        Sets the grid size.
        """
        action = self.session.action('toggle_grid')
        size = clamp(size, 0)
        if size <= 0 or not action.isChecked():
            brush = QtGui.QBrush(QtCore.Qt.NoBrush)
        else:
            image = QtGui.QImage(size, size, QtGui.QImage.Format_RGB32)
            image.fill(QtCore.Qt.white)
            painter = QtGui.QPainter(image)
            painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(80, 80, 80, 255)), 1, QtCore.Qt.SolidLine))
            painter.drawPoint(QtCore.QPointF(0, 0))
            painter.end()
            brush = QtGui.QBrush(image)
        self.setBackgroundBrush(brush) 
Example 21
Project: eddy   Author: obdasystems   File: palette.py    GNU General Public License v3.0 6 votes vote down vote up
def paintEvent(self, paintEvent):
        """
        Perform the painting of the button in the palette.
        :type paintEvent: QPaintEvent
        """
        icon = self.icon()
        painter = QtGui.QPainter(self)
        if self.isChecked():
            painter.setBrush(QtGui.QBrush(QtGui.QColor(66, 165, 245)))
            painter.setPen(QtGui.QPen(QtGui.QBrush(QtGui.QColor(66, 165, 245)), 1.0))
            painter.drawRect(0, 0, 60, 44)
        painter.setOpacity(1.0 if self.isEnabled() else 0.33)
        painter.drawPixmap(0, 0, icon.pixmap(QtCore.QSize(60, 44)))

    #############################################
    #   INTERFACE
    ################################# 
Example 22
Project: phidl   Author: amccaugh   File: quickplotter.py    MIT License 6 votes vote down vote up
def add_polygons(self, polygons, color = '#A8F22A', alpha = 1):
        qcolor = QColor()
        qcolor.setNamedColor(color)
        qcolor.setAlphaF(alpha)
        for points in polygons:
            qpoly = QPolygonF( [QPointF(p[0], p[1]) for p in points] )
            scene_poly = self.scene.addPolygon(qpoly)
            scene_poly.setBrush(qcolor)
            scene_poly.setPen(self.pen)
            self.scene_polys.append(scene_poly)
            # Update custom bounding box
            sr = scene_poly.sceneBoundingRect()
            if len(self.scene_polys) == 1:
                self.scene_xmin = sr.left()
                self.scene_xmax = sr.right()
                self.scene_ymin = sr.top()
                self.scene_ymax = sr.bottom()
            else:
                self.scene_xmin = min(self.scene_xmin, sr.left())
                self.scene_xmax = max(self.scene_xmax, sr.right())
                self.scene_ymin = min(self.scene_ymin, sr.top())
                self.scene_ymax = max(self.scene_ymax, sr.bottom()) 
Example 23
Project: hexutil   Author: stephanh42   File: example.py    MIT License 6 votes vote down vote up
def __init__(self, *args, **kws):
        super().__init__(*args, **kws)
        self.setMouseTracking(True) # we want to receive mouseMoveEvents

        self.level = Level(500)
        self.player = hexutil.origin
        self.hexgrid = hexutil.HexGrid(24)

        # initialize GUI objects needed for painting
        self.font = QtGui.QFont("Helvetica", 20)
        self.font.setStyleHint(QtGui.QFont.SansSerif)
        self.pen = QtGui.QPen()
        self.pen.setWidth(2)
        self.select_brush = QtGui.QBrush(QtGui.QColor(127, 127, 255, 127))
        self.unseen_brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 127))

        self.update_fov() 
Example 24
Project: plexdesktop   Author: coryo   File: delegates.py    GNU General Public License v3.0 6 votes vote down vote up
def placeholder_thumb_generator(title, size=150):
    """Returns a QPixmap of size with the first letter of each word in title"""
    initials = ' '.join([x[0] for x in title.split(' ') if len(x) > 2])
    key = 'placeholder' + initials
    img = QtGui.QPixmapCache.find(key)
    if img:
        return img
    qsize = QtCore.QSize(size, size)
    circle_color = QtGui.QColor(50, 50, 50)
    text_color = QtGui.QColor(75, 75, 75)
    rect = QtCore.QRect(QtCore.QPoint(0, 0), QtCore.QPoint(size, size))
    center = QtCore.QPoint(size / 2, size / 2)
    img = QtGui.QPixmap(qsize)
    img.fill(QtCore.Qt.transparent)
    p = QtGui.QPainter(img)
    p.setFont(QtGui.QFont('Open Sans', size / 4, weight=QtGui.QFont.Bold))
    p.setBrush(QtGui.QBrush(circle_color))
    p.setPen(circle_color)
    p.setRenderHint(QtGui.QPainter.Antialiasing, True)
    p.drawEllipse(center, size / 2 - 1, size / 2 - 1)
    p.setPen(text_color)
    p.drawText(rect, QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter, initials)
    QtGui.QPixmapCache.insert(key, img)
    return img 
Example 25
Project: plexdesktop   Author: coryo   File: delegates.py    GNU General Public License v3.0 6 votes vote down vote up
def draw_progress_bar(plex_item, pixmap, height=6):
    """draw a progress indicator on the bottom of pixmap with height pixels"""
    if not hasattr(plex_item, 'in_progress'):
        return
    if not plex_item.in_progress:
        return
    progress_color = QtGui.QColor(204, 123, 25)
    progress = plex_item.view_offset / max(1, plex_item.duration)
    p = QtGui.QPainter(pixmap)
    rect = p.window()
    progress_rect = QtCore.QRect(rect.bottomLeft() - QtCore.QPoint(0, height),
                                 rect.bottomRight())
    progress_fill = QtCore.QRect(progress_rect)
    progress_fill.setWidth(rect.width() * progress)
    p.fillRect(progress_rect, QtGui.QBrush(QtCore.Qt.black))
    p.fillRect(progress_fill, QtGui.QBrush(progress_color)) 
Example 26
Project: JI-Live-Danmu-Client   Author: SJTU-UMJI-Tech   File: Marquee.py    MIT License 5 votes vote down vote up
def initLabel(self, label, text):
        label.setText(text)
        label.setFont(QFont('SimHei', 24, 100))
        eff = QGraphicsDropShadowEffect()
        eff.setColor(QColor(6, 6, 6))
        eff.setBlurRadius(5)
        eff.setOffset(1.5, 1.5)
        label.setGraphicsEffect(eff)
        label.setGeometry(0, 0,
                          self.fontMetrics().boundingRect(text).width() + 20,
                          self.fontMetrics().boundingRect(text).height() + 10) 
Example 27
Project: ILTIS   Author: grg2rsr   File: Processing_Object.py    GNU General Public License v2.0 5 votes vote down vote up
def calc_colors(self,nColors,HSVsubset=(0,360),HSVoffset=0):
        h = sp.linspace(HSVsubset[0],HSVsubset[1],nColors,endpoint=False).astype('int')
        h = self.add_circular_offset(h,HSVoffset,HSVsubset[1]).tolist()
        s = [255] * nColors
        v = [255] * nColors
        colors = []
        for n in range(nColors):
            Color = QColor()
            Color.setHsv(h[n],s[n],v[n])
            colors.append(Color.getRgb())
        return colors 
Example 28
Project: ILTIS   Author: grg2rsr   File: Data_Selector_Widget.py    GNU General Public License v2.0 5 votes vote down vote up
def init_data(self):
                
        self.Main.Data.Metadata.paths = self.Main.Data.Metadata.paths
        self.setRowCount(len(self.Main.Data.Metadata.paths))
        
        # table entries
        for n, path in enumerate(self.Main.Data.Metadata.paths):
            self.setItem(n, 0, QtWidgets.QTableWidgetItem(self.Main.Data.Metadata.trial_labels[n]))
            
            color = self.Main.Options.view['colors'][n]
            QColor = QtGui.QColor(*color)
            QColor.setAlpha(100)
            self.item(n, 0).setBackground(QtGui.QBrush(QColor))  # FIXME find color solution

            verticalHeader = QtWidgets.QTableWidgetItem(str(n))
            verticalHeader.setBackground(QtGui.QBrush(QColor))
            
            QColor.setAlpha(255)
            verticalHeader.setForeground(QColor)
            
            self.setVerticalHeaderItem(n, verticalHeader)

        # connect
        self.itemSelectionChanged.connect(self.selection_changed)
        self.itemChanged.connect(self.labels_changed)
        
        # select all on startup
        selection = QtWidgets.QTableWidgetSelectionRange(0,0,len(self.Main.Data.Metadata.paths) - 1, 0)
        self.setRangeSelected(selection, True)
        
        self.verticalHeader().setStyle(QtWidgets.QStyleFactory.create('Cleanlooks')) # check on windows machines
        pass 
Example 29
Project: Pesterchum   Author: henry232323   File: dialogs.py    MIT License 5 votes vote down vote up
def add_user_item(self, user):
        if user.startswith("@"):
            nam = user[1:]
            self.memoUsers.addItem(nam)
            itm = self.memoUsers.item(self.memoUsers.count() - 1)
            itm.setIcon(QIcon(self.app.theme["path"] + "/op.png"))
        elif user.startswith("&"):
            nam = user[1:]
            self.memoUsers.addItem(nam)
            itm = self.memoUsers.item(self.memoUsers.count() - 1)
            itm.setIcon(QIcon(self.app.theme["path"] + "/admin.png"))
        elif user.startswith("%"):
            nam = user[1:]
            self.memoUsers.addItem(nam)
            itm = self.memoUsers.item(self.memoUsers.count() - 1)
            itm.setIcon(QIcon(self.app.theme["path"] + "/halfop.png"))
        elif user.startswith("~"):
            nam = user[1:]
            self.memoUsers.addItem(nam)
            itm = self.memoUsers.item(self.memoUsers.count() - 1)
            itm.setIcon(QIcon(self.app.theme["path"] + "/founder.png"))
        else:
            nam = user
            self.memoUsers.addItem(nam)
            itm = self.memoUsers.item(self.memoUsers.count() - 1)
        color = self.app.getColor(nam)
        if color.startswith("rgb"):
            r, g, b = color.split(",")
            r = int(r[-2:])
            g = int(g)
            b = int(b[:-1])
        else:
            r, g, b = rgb(color, type=tuple)
        itm.setForeground(QColor(r, g, b)) 
Example 30
Project: dcc   Author: amimo   File: DisasmViewMode.py    Apache License 2.0 5 votes vote down vote up
def drawSelected(self, qp):
        qp.setFont(self.font)

        cursorX, cursorY = self.cursor.getPosition()

        if len(self.OPCODES) - 1 < cursorY:
            return

        asm = self.OPCODES[cursorY]
        _, width, text = asm.getSelectedToken(cursorX)

        for i, asm in enumerate(self.OPCODES):
            for idx, length, value in asm.tokens():
                # skip current cursor position
                if cursorY == i and cursorX == idx:
                    continue

                # check every line, if match, select it
                if value == text:
                    qp.setOpacity(0.4)
                    brush = QtGui.QBrush(QtGui.QColor(0, 255, 0))
                    qp.fillRect(idx * self.fontWidth,
                                i * self.fontHeight + 2,
                                width * self.fontWidth,
                                self.fontHeight,
                                brush)
                    qp.setOpacity(1) 
Example 31
Project: dcc   Author: amimo   File: DisasmViewMode.py    Apache License 2.0 5 votes vote down vote up
def _drawRow(self, qp, cemu, row, asm, offset=-1):
        log.debug('DRAW AN INSTRUCTION %s %s %s %s %s', asm, row, asm.get_name(), len(asm.get_operands(offset)), hex(self.getPageOffset()))

        qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))

        hex_data = asm.get_hex()

        # write hexdump
        cemu.writeAt(0, row, hex_data)

        # fill with spaces
        cemu.write((MNEMONIC_COLUMN - len(hex_data)) * ' ')

        # let's color some branch instr
        # if asm.isBranch():
        #    qp.setPen(QtGui.QPen(QtGui.QColor(255, 80, 0)))
        # else:
        qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))

        mnemonic = asm.get_name()
        cemu.write(mnemonic)

        # leave some spaces
        cemu.write((MNEMONIC_WIDTH - len(mnemonic)) * ' ')

        if asm.get_symbol():
            qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))
            cemu.write_c('[')

            qp.setPen(QtGui.QPen(QtGui.QColor('yellow'), 1, QtCore.Qt.SolidLine))
            cemu.write(asm.get_symbol())

            qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))
            cemu.write_c(']')

        self._write_operands(asm, qp, cemu, offset)
        self._write_comments(asm, qp, cemu, offset) 
Example 32
Project: dcc   Author: amimo   File: DisasmViewMode.py    Apache License 2.0 5 votes vote down vote up
def _write_comments(self, asm, qp, cemu, offset):
        comments = asm.get_comments()
        if comments:
            cemu.write(30 * ' ')

            qp.setPen(QtGui.QPen(QtGui.QColor(82, 192, 192), 1, QtCore.Qt.SolidLine))
            cemu.write('; "{0}"'.format(' '.join(comments))) 
Example 33
Project: dcc   Author: amimo   File: SourceViewMode.py    Apache License 2.0 5 votes vote down vote up
def drawCursor(self, qp):
        cursorX, cursorY = self.cursor.getPosition()

        xstart = cursorX
        width = 1

        qp.setBrush(QtGui.QColor(255, 255, 0))

        qp.setOpacity(0.5)
        qp.drawRect(xstart * self.fontWidth, cursorY * self.fontHeight, width * self.fontWidth, self.fontHeight + 2)
        qp.setOpacity(1) 
Example 34
Project: dcc   Author: amimo   File: HexViewMode.py    Apache License 2.0 5 votes vote down vote up
def drawCursor(self, qp):
        qp.setBrush(QtGui.QColor(255, 255, 0))
        if self.isInEditMode():
            qp.setBrush(QtGui.QColor(255, 102, 179))

        cursorX, cursorY = self.cursor.getPosition()

        columns = self.HexColumns[self.idxHexColumns]
        if cursorX > columns:
            self.cursor.moveAbsolute(columns - 1, cursorY)

        # get cursor position again, maybe it was moved
        cursorX, cursorY = self.cursor.getPosition()

        qp.setOpacity(0.8)
        if self.isInEditMode():
            qp.setOpacity(0.5)
        # cursor on text
        qp.drawRect((self.COLUMNS * 3 + self.gap + cursorX) * self.fontWidth, cursorY * self.fontHeight + 2,
                    self.fontWidth, self.fontHeight)

        # cursor on hex
        if not self.isInEditMode():
            qp.drawRect(cursorX * 3 * self.fontWidth, cursorY * self.fontHeight + 2, 2 * self.fontWidth,
                        self.fontHeight)
        else:
            if self.highpart:
                qp.drawRect(cursorX * 3 * self.fontWidth, cursorY * self.fontHeight + 2, 1 * self.fontWidth,
                            self.fontHeight)
            else:
                qp.drawRect(cursorX * 3 * self.fontWidth + self.fontWidth, cursorY * self.fontHeight + 2,
                            1 * self.fontWidth, self.fontHeight)

        qp.setOpacity(1) 
Example 35
Project: dcc   Author: amimo   File: HexViewMode.py    Apache License 2.0 5 votes vote down vote up
def selectionChanged(self, selected, deselected):
        item = self.ann_w.treeWidget.currentItem()
        if item:
            offset = item.getOffset()
            size = item.getSize()
            u = offset
            v = offset + size
            self.selector.addSelection((u, v, QtGui.QBrush(QtGui.QColor(125, 255, 0)), 0.2),
                                       type=TextSelection.SelectionType.NORMAL)
            self.goTo(u) 
Example 36
Project: dcc   Author: amimo   File: HexViewMode.py    Apache License 2.0 5 votes vote down vote up
def onColorPicker(self):
        """
        Show color-picker dialog to select color.

        Qt will use the native dialog by default.

        """
        dlg = QtGui.QColorDialog(QtGui.QColor(self._color), None)

        # if self._color:
        #    dlg.setCurrentColor(QtGui.QColor(self._color))

        if dlg.exec_():
            self.setColor(dlg.currentColor().name()) 
Example 37
Project: dcc   Author: amimo   File: BinViewMode.py    Apache License 2.0 5 votes vote down vote up
def drawCursor(self, qp):
        cursorX, cursorY = self.cursor.getPosition()
        qp.setBrush(self.themes['background_cursor'])

        if self.isInEditMode():
            qp.setBrush(QtGui.QColor(255, 102, 179))

        qp.setOpacity(0.8)
        qp.drawRect(cursorX * self.fontWidth, cursorY * self.fontHeight, self.fontWidth, self.fontHeight + 2)
        qp.setOpacity(1) 
Example 38
Project: kucher   Author: Zubax   File: model.py    GNU General Public License v3.0 5 votes vote down vote up
def _data_foreground(self, index: QModelIndex) -> QColor:
        node = self._unwrap(index)
        palette = QPalette()
        if node.register and (self.flags(index) & Qt.ItemIsEditable):
            if node.register.cached_value_is_default_value or not node.register.has_default_value:
                return palette.color(QPalette.Link)
            else:
                return palette.color(QPalette.LinkVisited)

        return palette.color(QPalette.WindowText) 
Example 39
Project: geoscience   Author: rolandhill   File: SectionGrid.py    GNU General Public License v3.0 5 votes vote down vote up
def setStyle(self, layer, labelSuffix='', labels=True):
        # Set the line style
        r = layer.renderer()
        r.symbol().setColor(QtGui.QColor('grey'))
        r.symbol().setOpacity(0.5)

        #Set the label style
        if labels:
            settings = QgsPalLayerSettings()
            textFormat = QgsTextFormat()
            textFormat.setFont(QtGui.QFont("Arial", 10))
            textFormat.setColor(QtGui.QColor('grey'))
            textFormat.setOpacity(0.5)
            settings.setFormat(textFormat)
            if labelSuffix == '':
                settings.fieldName = 'Label'
            else:
    #            settings.fieldName = 'Label'
                settings.fieldName = str.format("format( '%%1%%2',  format_number(Label, 0), ' %s')" % labelSuffix)
                settings.isExpression = True
            settings.formatNumbers = True
            settings.decimals = 0
            settings.placement = QgsPalLayerSettings.Line
            labeling = QgsVectorLayerSimpleLabeling(settings)
            layer.setLabeling(labeling)
            layer.setLabelsEnabled(True) 
Example 40
Project: Python-GUI   Author: arpitj07   File: Project.py    MIT License 5 votes vote down vote up
def combo2(self):
        myteam=sqlite3.connect("TEAM.db")
        cu= myteam.cursor()
        
        team = self.eval_screen.SelectTeam.currentText()
        cu.execute("SELECT PlAYERS from team WHERE NAMES='"+team+"';")
        player= cu.fetchall()
        self.eval_screen.PlayerList.clear()
        for i in range(len(player)):
            item= QtWidgets.QListWidgetItem(player[i][0])
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            item.setFont(font)
            item.setBackground(QtGui.QColor('#ffff99'))
            self.eval_screen.PlayerList.addItem(item)
        
        cu.execute("SELECT SCORES from team WHERE NAMES='"+team+"';")
        score=cu.fetchall()
        self.teamscore=[]
        for i in range(len(score)):
            self.teamscore.append(score[i][0])
    
        self.eval_screen.ScoreList.clear()
        for i in range(len(score)):
            items= QtWidgets.QListWidgetItem(str(score[i][0]))
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            items.setFont(font)
            items.setBackground(QtGui.QColor('#fdc086'))
            self.eval_screen.ScoreList.addItem(items) 
Example 41
Project: Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader   Author: HA6Bots   File: videoeditor.py    MIT License 5 votes vote down vote up
def updateColors(self):
        for x, mainComment in enumerate(self.scriptWrapper.scriptMap):
            self.selectedMainComment = None
            for y, subComments in enumerate(mainComment):
                if y == 0:
                    self.selectedMainComment = self.getTopLevelByName("Main Comment %s" % str(x))
                    if subComments is True:
                        self.selectedMainComment.setForeground(0, QtGui.QBrush(QtGui.QColor("green")))
                    else:
                        self.selectedMainComment.setForeground(0, QtGui.QBrush(QtGui.QColor("red")))
                else:
                    if subComments is True:
                        self.selectedMainComment.child(y - 1).setForeground(0, QtGui.QBrush(QtGui.QColor("green")))
                    else:
                        self.selectedMainComment.child(y - 1).setForeground(0, QtGui.QBrush(QtGui.QColor("red"))) 
Example 42
Project: Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader   Author: HA6Bots   File: videoeditor.py    MIT License 5 votes vote down vote up
def animategroup(self, widgets, color):
        self.changeanimationgroup = QParallelAnimationGroup()
        for widget in widgets:
            effect = QtWidgets.QGraphicsColorizeEffect(widget)
            widget.setGraphicsEffect(effect)
            anim = QtCore.QPropertyAnimation(effect, b"color")
            anim.setDuration(500)
            anim.setStartValue(QtGui.QColor(0, 0, 0))
            anim.setKeyValueAt(0.25, color)
            anim.setEndValue(QtGui.QColor(0, 0, 0))
            self.changeanimationgroup.addAnimation(anim)
        self.changeanimationgroup.start() 
Example 43
Project: openeo-qgis-plugin   Author: Open-EO   File: drawPoly.py    Apache License 2.0 5 votes vote down vote up
def __init__(self, iface, action):
        canvas = iface  #.mapCanvas()
        QgsMapTool.__init__(self, canvas)
        self.canvas = canvas
        self.iface = iface
        self.action = action
        self.status = 0
        mFillColor = QColor(254, 178, 76, 63)
        self.rb = QgsRubberBand(self.canvas, QgsWkbTypes.PolygonGeometry)
        self.rb.setColor(mFillColor)
        #return None 
Example 44
Project: cct   Author: awacha   File: devicestatus.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def checkIfDeviceIsConnected(self, device: Device):
        if device.get_connected():
            color = QtGui.QColor('lightgreen')
            tooltip = 'Connected to {}'.format(':'.join([str(x) for x in device.deviceconnectionparameters]))
        else:
            color = QtGui.QColor('red')
            tooltip = 'Disconnected'
        self.setLabelBackgroundColor(self.connectedLabel, color)
        self.connectedLabel.setToolTip(tooltip) 
Example 45
Project: cct   Author: awacha   File: devicestatus.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def checkIfReady(self, device: Device):
        if device.is_ready():
            color = QtGui.QColor('lightgreen')
            tooltip = 'Device is ready'
        else:
            color = QtGui.QColor('red')
            tooltip = 'Device is not ready'
        self.setLabelBackgroundColor(self.readyLabel, color)
        self.readyLabel.setToolTip(tooltip) 
Example 46
Project: cct   Author: awacha   File: devicestatus.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def checkIfBusy(self, device: Device, status=None):
        if device.is_busy(status):
            color = QtGui.QColor('yellow')
            tooltip = 'Device is busy'
            text = 'BU'
        else:
            color = QtGui.QColor('lightgreen')
            tooltip = 'Device is idle'
            text = 'ID'
        self.setLabelBackgroundColor(self.busyLabel, color)
        self.busyLabel.setToolTip(tooltip)
        self.busyLabel.setText(text) 
Example 47
Project: cct   Author: awacha   File: devicestatus.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def onDeviceTelemetry(self, device: Device, telemetry: TelemetryInfo):
        if telemetry.last_recv > 5:
            color = QtGui.QColor('red')
            tooltip = 'Device is not responding. Last message received {:.3f} seconds ago'.format(telemetry.last_recv)
        else:
            color = QtGui.QColor('lightgreen')
            tooltip = 'Last message received {:.3f} seconds ago'.format(telemetry.last_recv)
        self.setLabelBackgroundColor(self.lastRecvLabel, color)
        self.lastRecvLabel.setToolTip(tooltip)

        if telemetry.last_send > 5:
            color = QtGui.QColor('red')
            tooltip = 'Not sending to device. Last message sent {:.3f} seconds ago'.format(telemetry.last_send)
        else:
            color = QtGui.QColor('lightgreen')
            tooltip = 'Last message sent {:.3f} seconds ago'.format(telemetry.last_send)
        self.setLabelBackgroundColor(self.lastSendLabel, color)
        self.lastSendLabel.setToolTip(tooltip)

        if telemetry.watchdog_active:
            if telemetry.watchdog > telemetry.watchdog_timeout:
                color = QtGui.QColor('red')
                tooltip = 'Communication watchdog error (wd value: {:.2f} sec)'.format(telemetry.watchdog)
            elif telemetry.watchdog > telemetry.watchdog_timeout * 0.5:
                color = QtGui.QColor('yellow')
                tooltip = 'Communication watchdog warning (wd value: {:.2f} sec)'.format(telemetry.watchdog)
            else:
                color = QtGui.QColor('lightgreen')
                tooltip = 'Communication watchdog OK (wd value: {:.2f} sec)'.format(telemetry.watchdog)
            self.setLabelBackgroundColor(self.watchDogLabel, color)
            self.watchDogLabel.setToolTip(tooltip)
            self.watchDogLabel.setEnabled(True)
        else:
            self.watchDogLabel.setEnabled(False)
            self.setLabelBackgroundColor(self.watchDogLabel, QtGui.QColor('gray')) 
Example 48
Project: cct   Author: awacha   File: logindialog.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def accept(self):
        if self.credo.services['accounting'].authenticate(self.operatorLineEdit.text(), self.passwordLineEdit.text()):
            return super().accept()
        else:
            palette = self.passwordLineEdit.palette()
            palette.setColor(QtGui.QPalette.Base, QtGui.QColor('red'))
            self.passwordLineEdit.setPalette(palette)
            return False 
Example 49
Project: cct   Author: awacha   File: detector.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setFlagBackground(self, flag: QtWidgets.QLabel, state: str):
        palette = flag.palette()
        assert isinstance(palette, QtGui.QPalette)
        if state == 'ok':
            palette.setColor(QtGui.QPalette.Window, QtGui.QColor('green'))
        elif state == 'warning':
            palette.setColor(QtGui.QPalette.Window, QtGui.QColor('orange'))
        else:
            palette.setColor(QtGui.QPalette.Window, QtGui.QColor('red'))
        flag.setPalette(palette)
        flag.setAutoFillBackground(True) 
Example 50
Project: cct   Author: awacha   File: motorconfig.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def onWidgetChanged(self):
        pal = self.sender().palette()
        pal.setColor(pal.Base, QtGui.QColor('yellow'))
        self.sender().setPalette(pal)