Python PySide.QtGui.QColor() Examples

The following are 30 code examples of PySide.QtGui.QColor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PySide.QtGui , or try the search function .
Example #1
Source File: PySimulator.py    From PySimulator with GNU Lesser General Public License v3.0 6 votes vote down vote up
def _newPlotContainer(self):
        ''' Create a new plot and add it to the current tab '''
        plotContainer = plotWidget.plotContainer(self.mdi)
        # defaultWidget = plotWidget.DefaultPlotWidget(self, self.plotMenuCallbacks)
        # plotContainer.addRight(defaultWidget)
        plotContainer.addFirst(self, self.plotMenuCallbacks)
        self.plotContainers.append(plotContainer)
        plotContainer.activeWidgetChanged.connect(self._currentPlotChanged)
        plotContainer.closed.connect(self._removePlotContainer)
        window = self.mdi.addSubWindow(plotContainer)
        self.plotWindowNr += 1
        window.setWindowTitle("Tab " + str(self.plotWindowNr))
        p = QtGui.QPalette()
        p.setColor(QtGui.QPalette.Background, QtGui.QColor("white"))
        window.setPalette(p)
        window.setWindowIcon(QtGui.QIcon(self.rootDir + '/Icons/office-chart-line-stacked.png'))
        window.showMaximized()
        return plotContainer 
Example #2
Source File: app.py    From shortcircuit with MIT License 6 votes vote down vote up
def add_data_to_table(self, route):
        self.tableWidget_path.setRowCount(len(route))
        for i, row in enumerate(route):
            for j, col in enumerate(row):
                item = QtGui.QTableWidgetItem("{}".format(col))
                self.tableWidget_path.setItem(i, j, item)

                if j in [1, 2]:
                    self.tableWidget_path.item(i, j).setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)

                if row[1] == "HS":
                    color = QtGui.QColor(223, 240, 216)
                elif row[1] == "LS":
                    color = QtGui.QColor(252, 248, 227)
                elif row[1] == "NS":
                    color = QtGui.QColor(242, 222, 222)
                else:
                    color = QtGui.QColor(210, 226, 242)

                if j == 3 and "wormhole" in col:
                    self.tableWidget_path.item(i, j).setIcon(self.icon_wormhole)
                self.tableWidget_path.item(i, j).setBackground(color)
                self.tableWidget_path.item(i, j).setForeground(QtGui.QColor(0, 0, 0)) 
Example #3
Source File: bar_widget.py    From tdoa with Apache License 2.0 6 votes vote down vote up
def drawBars(self, painter):
        size = self.size()
        width = size.width()
        height = size.height()

        bar_width = float(width - self.padding) / self.bars_number

        color = QtGui.QColor(0, 0, 0)
        painter.setPen(color)
        painter.setBrush(color)
        painter.drawRect(0, 0, width, height)
        for bar, value in enumerate(self.bars):
            bar_height = (height - self.padding) * value / self.resolution
            if not bar_height:
                bar_height = 1
            painter.setBrush(self.barColor(bar))
            painter.drawRect(
                bar * bar_width + self.padding,
                height - bar_height,
                bar_width - self.padding,
                bar_height - self.padding) 
Example #4
Source File: test_version_creator.py    From anima with MIT License 6 votes vote down vote up
def test_takes_with_representations_shows_in_blue(self):
        """testing if takes with representations will be displayed in blue
        """
        # select project 1 -> task1
        item_model = self.dialog.tasks_treeView.model()
        selection_model = self.dialog.tasks_treeView.selectionModel()

        index = item_model.index(0, 0)
        project1_item = item_model.itemFromIndex(index)
        self.dialog.tasks_treeView.expand(index)

        task1_item = project1_item.child(0, 0)
        selection_model.select(
            task1_item.index(),
            QtGui.QItemSelectionModel.Select
        )

        # expect only one "Main" take listed in take_listWidget
        main_item = self.dialog.takes_listWidget.item(0)
        item_foreground = main_item.foreground()
        color = item_foreground.color()
        self.assertEqual(
            color,
            QtGui.QColor(0, 0, 255)
        ) 
Example #5
Source File: syntax.py    From hrdev with MIT License 5 votes vote down vote up
def highlightBlock(self, text):
        '''Highlight block.'''

        for pattern, hl_format in self._highlighting_rules:
            expression = QtCore.QRegExp(pattern)
            index = expression.indexIn(text)
            while index >= 0:
                length = expression.matchedLength()
                self.setFormat(index, length, hl_format)
                index = expression.indexIn(text, index + length)

        self.setCurrentBlockState(0)

        start_index = 0
        if self.previousBlockState() != 1:
            start_index = self.comment_start_expression.indexIn(text)

        while start_index >= 0:
            end_index = self.comment_end_expression.indexIn(text, start_index)

            if end_index == -1:
                self.setCurrentBlockState(1)
                comment_length = text.length() - start_index
            else:
                comment_length = end_index - \
                                 start_index + \
                                 self.comment_end_expression.matchedLength()

            multi_line_comment_format = QtGui.QTextCharFormat()
            multiline_color = self.config_theme.get('tokens_highlight',
                                                    'quotation_color')
            multi_line_comment_format.setForeground(QtGui.QColor(multiline_color))
            self.setFormat(start_index, comment_length,
                           multi_line_comment_format)
            start_index = self.comment_start_expression.indexIn(text,
                                                                start_index +
                                                                comment_length)
        return 
Example #6
Source File: preferences.py    From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 5 votes vote down vote up
def generateWidget( self, dimensioningProcess, width = 60, height = 30 ):
        self.dimensioningProcess = dimensioningProcess
        clr = QtGui.QColor(*unsignedToRGB(self.dd_parms.GetUnsigned( self.name, self.defaultValue )) )
        self.colorRect.setBrush( QtGui.QBrush( clr ) )
        colorBox = QtGui.QGraphicsView( self.graphicsScene )
        colorBox.setMaximumWidth( width )
        colorBox.setMaximumHeight( height )
        colorBox.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff )
        colorBox.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff )
        return  DimensioningTaskDialog_generate_row_hbox( self.label, colorBox ) 
Example #7
Source File: preferences.py    From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 5 votes vote down vote up
def revertToDefault( self ):
        self.family_textbox.setText( self.dd_parms.GetString(self.name + '_family', self.defaultValue[0]) )
        self.size_textbox.setText( self.dd_parms.GetString(self.name + '_size', self.defaultValue[1]) )
        clr = QtGui.QColor(*unsignedToRGB(self.dd_parms.GetUnsigned( self.name+'_color', self.defaultValue[2] )) )
        self.colorRect.setBrush( QtGui.QBrush( clr ) )
        self.update_dimensionConstructorKWs() 
Example #8
Source File: SheetMetalUnfolder.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def colorF(self):
        return QtGui.QColor(self._color).getRgbF() 
Example #9
Source File: SheetMetalUnfolder.py    From FreeCAD_SheetMetal with GNU General Public License v3.0 5 votes vote down vote up
def onColorPicker(self):
        dlg = QtGui.QColorDialog()
        if self._color:
            dlg.setCurrentColor(QtGui.QColor('self._color'))
        if dlg.exec_():
            self.setColor(dlg.currentColor().name()) 
Example #10
Source File: exportPartToVRML.py    From kicad-3d-models-in-freecad with GNU General Public License v2.0 5 votes vote down vote up
def comboBox_Changed(text_combo):
    global ui
    say(text_combo)
    if text_combo not in shaderColors.named_colors:
        return
    if len(shaderColors.named_colors)>1:
        pal = QtGui.QPalette()
        bgc = QtGui.QColor(*shaderColors.named_colors[text_combo].getDiffuseInt())
        pal.setColor(QtGui.QPalette.Base, bgc)
        ui.plainTextEdit_2.viewport().setPalette(pal)

### 
Example #11
Source File: exportPartToVRML.py    From kicad-3d-models-in-freecad with GNU General Public License v2.0 5 votes vote down vote up
def comboBox_Changed(text_combo):
    global ui
    #say(text_combo)
    if text_combo not in shaderColors.named_colors:
        return
    if len(shaderColors.named_colors)>1:
        pal = QtGui.QPalette()
        bgc = QtGui.QColor(*shaderColors.named_colors[text_combo].getDiffuseInt())
        pal.setColor(QtGui.QPalette.Base, bgc)
        ui.plainTextEdit_2.viewport().setPalette(pal)

### 
Example #12
Source File: preferences.py    From FreeCAD_drawing_dimensioning with GNU Lesser General Public License v2.1 5 votes vote down vote up
def revertToDefault( self ):
        clr = QtGui.QColor(*unsignedToRGB(self.dd_parms.GetUnsigned( self.name, self.defaultValue )) )
        self.colorRect.setBrush( QtGui.QBrush( clr ) )
        self.dimensioningProcess.dimensionConstructorKWs[ self.name ] = self.getDefaultValue() 
Example #13
Source File: GDT.py    From FreeCAD-GDT with GNU Lesser General Public License v2.1 5 votes vote down vote up
def getRGB(param):
    color = QtGui.QColor(getParam(param,16753920)>>8)
    r = float(color.red()/255.0)
    g = float(color.green()/255.0)
    b = float(color.blue()/255.0)
    col = (r,g,b,0.0)
    return col 
Example #14
Source File: VariablesBrowser.py    From PySimulator with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, numberedModelName, variable):
        self.numberedModelName = numberedModelName
        self.variable = variable
        QtGui.QLineEdit.__init__(self)
        self.setFrame(True)

        ''' Set background to white as default
        '''
        self._palette = QtGui.QPalette()
        self._palette.setColor(self.backgroundRole(), QtGui.QColor(255, 255, 255))
        self.setPalette(self._palette)

        self.editingFinished.connect(self._relay)
        self.textEdited.connect(self._edited) 
Example #15
Source File: VariablesBrowser.py    From PySimulator with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _edited(self):
        ''' if text was edited, set background to grey
        '''
        self._palette.setColor(self.backgroundRole(), QtGui.QColor(200, 200, 200))
        self.setPalette(self._palette) 
Example #16
Source File: VariablesBrowser.py    From PySimulator with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _relay(self):
        if self.isModified():
            self.valueChanged.emit(self.numberedModelName, self.variable, self.text())
            self.setModified(False)
            ''' When editing is finished, reset background color to white
            '''
            self._palette.setColor(self.backgroundRole(), QtGui.QColor(255, 255, 255))
            self.setPalette(self._palette) 
Example #17
Source File: PySimulator.py    From PySimulator with GNU Lesser General Public License v3.0 5 votes vote down vote up
def showAbout(self):
        widget = QtGui.QDialog(self)
        widget.setWindowTitle("About PySimulator")
        p = QtGui.QPalette()
        p.setColor(QtGui.QPalette.Background, QtGui.QColor("white"))
        widget.setPalette(p)
        layout = QtGui.QGridLayout(widget)
        widget.setLayout(layout)
        pixmap = QtGui.QPixmap(self.rootDir + "/Icons/dlr-splash.png")
        iconLabel = QtGui.QLabel()
        iconLabel.setPixmap(pixmap)
        layout.addWidget(iconLabel, 0, 0)
        layout.addWidget(QtGui.QLabel("Copyright (C) 2011-2015 German Aerospace Center DLR (Deutsches Zentrum fuer Luft- und Raumfahrt e.V.),\nInstitute of System Dynamics and Control. All rights reserved.\n\nPySimulator is free software: You can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nPySimulator is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with PySimulator. If not, see www.gnu.org/licenses."), 1, 0)
        layout.addWidget(QtGui.QLabel("PySimulator Version: " + str(version)), 2, 0)
        button = QtGui.QPushButton("OK")
        button.clicked.connect(widget.close)
        layout.addWidget(button, 3, 0)
        widget.show() 
Example #18
Source File: treeview.py    From LCInterlocking with GNU Lesser General Public License v2.1 5 votes vote down vote up
def data(self, index, role):
        if not index.isValid():
            return None

        if role == QtCore.Qt.ForegroundRole:
            item = index.internalPointer()
            if item.type == TreeItem.PART_LINK or item.type == TreeItem.TAB_LINK:
                return QtGui.QColor(190, 190, 190)

        if role != QtCore.Qt.DisplayRole:
            return None

        item = index.internalPointer()
        return item.data(index.column()) 
Example #19
Source File: FinderOverlay.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def initUI(self):
        # container = QWidget(self)
        # container.resize(200, 100);
        # container.setStyleSheet("background-color:black;")

        font_size = QLabel('Font Size')
        font_size.fillColor = QColor(30, 30, 30, 120)
        font_size.penColor = QColor("#333333")

        grid = QGridLayout()
        grid.setContentsMargins(50, 10, 10, 10)
        grid.addWidget(font_size, 0, 0)
        self.setLayout(grid)

        # palette = QPalette(self.palette())
        # palette.setColor(self.backgroundRole(), Qt.black)
        # palette.setColor(palette.Background, Qt.transparent)

        # self.setPalette(palette)

    # def paintEvent(self, event):        
    #     painter = QPainter()
    #     painter.begin(self)
    #     # painter.setRenderHint(QPainter.Antialiasing)
    #     painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 127)))
    #     painter.drawLine(self.width() / 8, self.height() / 8, 7 * self.width() / 8, 7 * self.height() / 8)
    #     painter.drawLine(self.width() / 8, 7 * self.height() / 8, 7 * self.width() / 8, self.height() / 8)
    #     # painter.setPen(QPen(Qt.NoPen)) 
Example #20
Source File: heatmap.py    From heatmappy with MIT License 5 votes vote down vote up
def _paint_points(self, img, points):
        painter = QtGui.QPainter(img)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)

        pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 0))
        pen.setWidth(0)
        painter.setPen(pen)

        for point in points:
            self._paint_point(painter, *point)
        painter.end() 
Example #21
Source File: heatmap.py    From heatmappy with MIT License 5 votes vote down vote up
def _paint_point(self, painter, x, y):
        grad = QtGui.QRadialGradient(x, y, self.point_diameter/2)
        grad.setColorAt(0, QtGui.QColor(0, 0, 0, max(self.point_strength, 0)))
        grad.setColorAt(1, QtGui.QColor(0, 0, 0, 0))
        brush = QtGui.QBrush(grad)
        painter.setBrush(brush)
        painter.drawEllipse(
            x - self.point_diameter/2,
            y - self.point_diameter/2,
            self.point_diameter,
            self.point_diameter
        ) 
Example #22
Source File: QtShim.py    From grap with MIT License 5 votes vote down vote up
def get_QColor():
    """QColor getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QColor
    except ImportError:
        import PyQt5.QtGui as QtGui
        return QtGui.QColor 
Example #23
Source File: vfpfunc.py    From vfp2py with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
            QtGui.QFrame.__init__(self)
            Custom.__init__(self, *args, **kwargs)
            self.setFrameStyle(QtGui.QFrame.VLine | QtGui.QFrame.Plain)
            palette = self.palette()
            palette.setColor(self.foregroundRole(), QtGui.QColor(0, 0, 0, 0))
            self.setPalette(palette)
            margin = 4
            self.setContentsMargins(margin, 0, margin, 0) 
Example #24
Source File: vfpfunc.py    From vfp2py with MIT License 5 votes vote down vote up
def rgb(red, green, blue):
    return QtGui.QColor(red, green, blue) 
Example #25
Source File: mainform.py    From Satori with Artistic License 2.0 5 votes vote down vote up
def set_shadow_effect(self, widget, radius=5, offset=(1, 1)):
        shadow_effect = QtGui.QGraphicsDropShadowEffect(self)
        shadow_effect.setBlurRadius(radius)
        shadow_effect.setColor(QtGui.QColor("#000000"))
        shadow_effect.setOffset(*offset)
        widget.setGraphicsEffect(shadow_effect) 
Example #26
Source File: glTFExport.py    From maya-glTF with MIT License 5 votes vote down vote up
def _create_metallic_roughness_map(self, metal_map, rough_map):

        metal = QImage(metal_map)
        rough = QImage(rough_map)
        metal_pixel = QColor()

        metal = metal.convertToFormat(QImage.Format_RGB32);
        rough = rough.convertToFormat(QImage.Format_RGB32);
        metal_uchar_ptr = metal.bits()
        rough_uchar_ptr = rough.bits()
        if (not metal.width() == rough.width()
                or not metal.height() == rough.height()):
            raise RuntimeError("Error processing material: {}. Metallic map and roughness map must have same dimensions.".format(self.maya_node))
        width = metal.width();
        height = metal.height();

        i = 0
        for y in range(height):
            for x in range(width):
                metal_color = struct.unpack('I', metal_uchar_ptr[i:i+4])[0]
                rough_color = struct.unpack('I', rough_uchar_ptr[i:i+4])[0]
                metal_pixel.setRgb(0, qGreen(rough_color), qBlue(metal_color))
                metal_uchar_ptr[i:i+4] = struct.pack('I', metal_pixel.rgb())
                i+=4
                
        output = ExportSettings.out_dir + "/"+self.name+"_metalRough.jpg"
        return output, metal 
Example #27
Source File: heatmap.py    From heatmappy with MIT License 5 votes vote down vote up
def heatmap(self, width, height, points):
        base_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32)
        base_image.fill(QtGui.QColor(255, 255, 255, 255))

        self._paint_points(base_image, points)
        return self._qimage_to_pil_image(base_image).convert('L') 
Example #28
Source File: CodeEditor.py    From cadquery-freecad-module with GNU Lesser General Public License v3.0 5 votes vote down vote up
def highlightCurrentLine(self):
        extraSelections = []
        if (not self.isReadOnly()):
            lineColor = QColor("#E0EEEE")
            selection = QTextEdit.ExtraSelection()
            selection.format.setBackground(lineColor)
            selection.format.setProperty(QTextCharFormat.FullWidthSelection, True)
            selection.cursor=self.textCursor()
            selection.cursor.clearSelection()
            extraSelections.append(selection)
        self.setExtraSelections(extraSelections) 
Example #29
Source File: gui.py    From autopilot with Mozilla Public License 2.0 5 votes vote down vote up
def init_ui(self):
        """
        Initialized graphical elements. Literally just filling a table.
        """
        # set shape (rows by cols
        self.shape = (len(self.mice_weights), len(self.colnames.keys()))
        self.setRowCount(self.shape[0])
        self.setColumnCount(self.shape[1])


        for row in range(self.shape[0]):
            for j, col in enumerate(self.colnames.keys()):
                try:
                    if col == "date":
                        format_date = datetime.datetime.strptime(self.mice_weights[row][col], '%y%m%d-%H%M%S')
                        format_date = format_date.strftime('%b %d')
                        item = QtGui.QTableWidgetItem(format_date)
                    elif col == "stop":
                        stop_wt = str(self.mice_weights[row][col])
                        minimum = float(self.mice_weights[row]['minimum_mass'])
                        item = QtGui.QTableWidgetItem(stop_wt)
                        if float(stop_wt) < minimum:
                            item.setBackground(QtGui.QColor(255,0,0))

                    else:
                        item = QtGui.QTableWidgetItem(str(self.mice_weights[row][col]))
                except:
                    item = QtGui.QTableWidgetItem(str(self.mice_weights[row][col]))
                self.setItem(row, j, item)

        # make headers
        self.setHorizontalHeaderLabels(self.colnames.values())
        self.resizeColumnsToContents()
        self.updateGeometry()
        self.adjustSize()
        self.sortItems(0) 
Example #30
Source File: bar_widget.py    From tdoa with Apache License 2.0 5 votes vote down vote up
def blue2red(self, position):
        position &= 0xFF
        if position < 128:
            return QtGui.QColor(0, position * 2, 255 - position * 2)
        else:
            position -= 128
            return QtGui.QColor(position * 2, 255 - position * 2, 0)