Python PySide2.QtGui.QColor() Examples

The following are 30 code examples of PySide2.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 PySide2.QtGui , or try the search function .
Example #1
Source File: ControlsWidget.py    From debugger with MIT License 6 votes vote down vote up
def load_icon(fname_icon):
	path_this_file = os.path.abspath(__file__)
	path_this_dir = os.path.dirname(path_this_file)
	path_icons = os.path.join(path_this_dir, '..', 'media', 'icons')
	path_icon = os.path.join(path_icons, fname_icon)

	pixmap = QtGui.QPixmap(path_icon)

	#pixmap.fill(QtGui.QColor('red'))
	#pixmap.setMask(pixmap.createMaskFromColor(QtGui.QColor('black'), QtGui.Qt.MaskOutColor))

	icon = QtGui.QIcon()
	icon.addPixmap(pixmap, QtGui.QIcon.Normal)
	icon.addPixmap(pixmap, QtGui.QIcon.Disabled)

	return icon 
Example #2
Source File: core.py    From pylash_engine with MIT License 6 votes vote down vote up
def getColor(color):
	if isinstance(color, QtGui.QColor) or isinstance(color, QtGui.QGradient):
		return color
	elif hasattr(color, "addColorStop"):
		return color.value
	elif not color:
		return QtCore.Qt.transparent
	else:
		if isinstance(color, int):
			color = hex(color)
			
		if color[0 : 2].lower() == "0x":
			color = "#" + color[2 ::]

		colorObj = QtGui.QColor()
		colorObj.setNamedColor(color)

		return colorObj 
Example #3
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 #4
Source File: Airfoil.py    From PyAero with MIT License 6 votes vote down vote up
def makeSplineMarkers(self):
        """Create marker for polygon contour"""

        self.splineMarkers = list()

        for x, y in zip(*self.spline_data[0]):

            # put airfoil contour points as graphicsitem
            splinemarker = gic.GraphicsCollection()
            splinemarker.pen.setColor(QtGui.QColor(60, 60, 80, 255))
            splinemarker.brush.setColor(QtGui.QColor(180, 180, 50, 230))
            splinemarker.pen.setWidthF(1.6)
            # no pen thickness change when zoomed
            splinemarker.pen.setCosmetic(True)

            splinemarker.Circle(x, y, 0.004)

            splineMarkerItem = GraphicsItem.GraphicsItem(splinemarker)

            self.splineMarkers.append(splineMarkerItem) 
Example #5
Source File: gui.py    From EvilOSX with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        super(_QDarkPalette, self).__init__()

        self._color_white = QColor(255, 255, 255)
        self._color_black = QColor(0, 0, 0)
        self._color_red = QColor(255, 0, 0)
        self._color_primary = QColor(53, 53, 53)
        self._color_secondary = QColor(35, 35, 35)
        self._color_tertiary = QColor(42, 130, 218)

        self.setColor(QPalette.Window, self._color_primary)
        self.setColor(QPalette.WindowText, self._color_white)
        self.setColor(QPalette.Base, self._color_secondary)
        self.setColor(QPalette.AlternateBase, self._color_primary)
        self.setColor(QPalette.ToolTipBase, self._color_white)
        self.setColor(QPalette.ToolTipText, self._color_white)
        self.setColor(QPalette.Text, self._color_white)
        self.setColor(QPalette.Button, self._color_primary)
        self.setColor(QPalette.ButtonText, self._color_white)
        self.setColor(QPalette.BrightText, self._color_red)
        self.setColor(QPalette.Link, self._color_tertiary)
        self.setColor(QPalette.Highlight, self._color_tertiary)
        self.setColor(QPalette.HighlightedText, self._color_black) 
Example #6
Source File: colorwheel.py    From hotbox_designer with BSD 3-Clause Clear License 6 votes vote down vote up
def initUI(self):
        self._conicalGradient = QtGui.QConicalGradient(
            self.width() / 2, self.height() / 2, 180)
        for pos, (r, g, b) in CONICAL_GRADIENT:
            self._conicalGradient.setColorAt(pos, QtGui.QColor(r, g, b))

        top = self._rect.top()
        bottom = self._rect.top() + self._rect.height()
        self._vertical_gradient = QtGui.QLinearGradient(0, top, 0, bottom)
        self._vertical_gradient.setColorAt(0.0, QtGui.QColor(*TRANSPARENT))
        self._vertical_gradient.setColorAt(1.0, QtGui.QColor(BLACK))

        left = self._rect.left()
        right = self._rect.left() + self._rect.width()
        self._horizontal_gradient = QtGui.QLinearGradient(left, 0, right, 0)
        self._horizontal_gradient.setColorAt(0.0, QtGui.QColor(WHITE)) 
Example #7
Source File: Airfoil.py    From PyAero with MIT License 6 votes vote down vote up
def makeChord(self):
        line = gic.GraphicsCollection()
        color = QtGui.QColor(70, 70, 70, 255)
        line.pen.setColor(color)
        line.pen.setWidthF(0.8)
        # no pen thickness change when zoomed
        line.pen.setCosmetic(True)
        # setting CustomDashLine not needed as it will be set
        # implicitely by Qt when CustomDashLine is applied
        # put it just for completness
        line.pen.setStyle(QtCore.Qt.CustomDashLine)
        stroke = 10
        dot = 2
        space = 5
        line.pen.setDashPattern([stroke, space, dot, space])
        index_min = np.argmin(self.raw_coordinates[0])
        index_max = np.argmax(self.raw_coordinates[0])
        line.Line(self.raw_coordinates[0][index_min],
                  self.raw_coordinates[1][index_min],
                  self.raw_coordinates[0][index_max],
                  self.raw_coordinates[1][index_max])

        self.chord = GraphicsItem.GraphicsItem(line)
        self.chord.setAcceptHoverEvents(False) 
Example #8
Source File: qgraph_arrow.py    From angr-management with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def paint(self, painter, option, widget):
        lod = option.levelOfDetailFromTransform(painter.worldTransform())
        should_highlight = self._should_highlight()

        if should_highlight:
            pen = QPen(QColor(0, 0xfe, 0xfe), 2, self.style)
        else:
            pen = QPen(self.color, 2, self.style)
        painter.setPen(pen)

        painter.drawPath(self.path)

        # arrow
        if lod < 0.3:
            return

        # arrow
        if should_highlight:
            brush = QBrush(QColor(0, 0xfe, 0xfe))
        else:
            brush = QBrush(self.color)
        painter.setBrush(brush)
        painter.drawPolygon(self.arrow) 
Example #9
Source File: colorwheel.py    From hotbox_designer with BSD 3-Clause Clear License 6 votes vote down vote up
def set_current_color(self, color):
        [r, g, b] = color.getRgb()[:3]
        self._angle = 360.0 - (QtGui.QColor(r, g, b).getHslF()[0] * 360.0)
        self._angle = self._angle if self._angle != 720.0 else 0

        x = ((((
            sorted([r, g, b], reverse=True)[0] -
            sorted([r, g, b])[0]) / 255.0) * self._rect.width()) +
             self._rect.left())

        y = ((((
            255 - (sorted([r, g, b], reverse=True)[0])) / 255.0) *
              self._rect.height()) + self._rect.top())

        self._current_color = color
        self._color_point = QtCore.QPoint(x, y)
        self.repaint() 
Example #10
Source File: painting.py    From hotbox_designer with BSD 3-Clause Clear License 6 votes vote down vote up
def draw_editor(painter, rect, snap=None):
    # draw border
    pen = QtGui.QPen(QtGui.QColor('#333333'))
    pen.setStyle(QtCore.Qt.DashDotLine)
    pen.setWidth(3)
    brush = QtGui.QBrush(QtGui.QColor(255, 255, 255, 25))
    painter.setPen(pen)
    painter.setBrush(brush)
    painter.drawRect(rect)

    if snap is None:
        return
    # draw snap grid
    pen = QtGui.QPen(QtGui.QColor('red'))
    painter.setPen(pen)
    x = 0
    y = 0
    while y < rect.bottom():
        painter.drawPoint(x, y)
        x += snap[0]
        if x > rect.right():
            x = 0
            y += snap[1] 
Example #11
Source File: GraphicsItemsCollection.py    From PyAero with MIT License 6 votes vote down vote up
def __init__(self, name=None):

        pen = QtGui.QPen(QtCore.Qt.SolidLine)
        pen.setColor(QtGui.QColor(0, 0, 0, 255))
        pen.setWidthF(0.2)
        pen.setJoinStyle(QtCore.Qt.MiterJoin)
        self.pen = pen

        self.brush = QtGui.QBrush(QtGui.QColor(255, 255, 0, 255))
        self.font = QtGui.QFont('Decorative', 12)

        self.rect = QtCore.QRectF()
        self.shape = QtGui.QPainterPath()
        self.path = QtGui.QPainterPath()

        self.scale = (1, 1)
        self.tooltip = ''

        self.method = ''
        self.args = [] 
Example #12
Source File: GraphicsView.py    From PyAero with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):

        super().__init__(*args, **kwargs)

        self.view = args[1]

        # set pen and brush (filling)
        self.pen = QtGui.QPen()
        self.pen.setStyle(QtCore.Qt.DotLine)
        self.pen.setColor(QtGui.QColor(80, 80, 100))
        self.brush = QtGui.QBrush()
        color = QtGui.QColor(20, 20, 80, 30)
        self.brush.setColor(color)
        # self.brush.setStyle(QtCore.Qt.NoBrush)
        self.brush.setStyle(QtCore.Qt.SolidPattern)

        # set style selectively for the rubberband like that
        # see: http://stackoverflow.com/questions/25642618
        # required as opacity might not work
        # NOTE: opacity removed here
        self.setStyle(QtWidgets.QStyleFactory.create('windowsvista'))

        # set boolean for allowing zoom
        self.allow_zoom = False 
Example #13
Source File: qblock.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _calc_backcolor(self, should_omit_text):
        color = self.workspace.plugins.color_block(self.addr)
        if color is not None:
            return color

        if should_omit_text:
            return QColor(0xda, 0xda, 0xda)

        return self._config.disasm_view_node_background_color 
Example #14
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 #15
Source File: qinstruction.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _calc_backcolor(self):
        # First we'll check for customizations
        color = self.workspace.plugins.color_insn(self.insn.addr, self.selected)
        if color is not None:
            return color

        if self.selected:
            return QColor(0xb8, 0xc3, 0xd6)

        return None  # None here means transparent, reusing the block color 
Example #16
Source File: qstate_table.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def widgets(self):
        state = self.state

        name = state.gui_data.name
        base_name = state.gui_data.base_name
        is_changed = 'No' if state.gui_data.is_original else 'Yes'
        mode = state.mode
        address = '%#x' % state.addr if isinstance(state.addr, int) else 'Symbolic'
        state_options = {o for o, v in state.options._options.items() if v is True}
        options_plus = state_options - angr.sim_options.modes[mode]
        options_minus = angr.sim_options.modes[mode] - state_options
        options = ' '.join([' '.join('+' + o for o in options_plus), ' '.join('-' + o for o in options_minus)])

        widgets = [
            QTableWidgetItem(name),
            QTableWidgetItem(address),
            QTableWidgetItem(is_changed),
            QTableWidgetItem(base_name),
            QTableWidgetItem(mode),
            QTableWidgetItem(options),
        ]

        if state.gui_data.is_base:
            color = QColor(0, 0, 0x80)
        elif state.gui_data.is_original:
            color = QColor(0, 0x80, 0)
        else:
            color = QColor(0, 0, 0)

        for w in widgets:
            w.setFlags(w.flags() & ~Qt.ItemIsEditable)
            w.setForeground(color)

        return widgets 
Example #17
Source File: cutterplugin.py    From CutterDRcov with MIT License 5 votes vote down vote up
def set_color(self):
        """
        This function changes color of drcoved bbs and reflects
        the change to gui.
        """
        new_color = QColorDialog.getColor(QColor(self.config['color']))
        if not new_color.isValid():
            return
        self.config['color'] = new_color.rgb()
        self.paint() 
Example #18
Source File: event_callback.py    From pivy with ISC License 5 votes vote down vote up
def main():
    app = QApplication(sys.argv)
    viewer = quarter.QuarterWidget()

    root = coin.SoSeparator()
    root += coin.SoCone()
    root += test()

    viewer.setSceneGraph(root)
    viewer.setBackgroundColor(QColor(255, 255, 255))
    viewer.setWindowTitle("minimal")
    viewer.show()
    sys.exit(app.exec_()) 
Example #19
Source File: qsymexec_graph.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _draw_edges(self, painter, topleft_point, bottomright_point):
        for edge in self._edges:
            edge_coords = edge.coordinates

            color = QColor(0x70, 0x70, 0x70)
            pen = QPen(color)
            pen.setWidth(1.5)
            painter.setPen(pen)

            for from_, to_ in zip(edge_coords, edge_coords[1:]):
                start_point = QPointF(*from_)
                end_point = QPointF(*to_)
                # optimization: don't draw edges that are outside of the current scope
                if (start_point.x() > bottomright_point.x() or start_point.y() > bottomright_point.y()) and \
                        (end_point.x() > bottomright_point.x() or end_point.y() > bottomright_point.y()):
                    continue
                elif (start_point.x() < topleft_point.x() or start_point.y() < topleft_point.y()) and \
                        (end_point.x() < topleft_point.x() or end_point.y() < topleft_point.y()):
                    continue
                painter.drawPolyline((start_point, end_point))

            # arrow
            # end_point = self.mapToScene(*edges[-1])
            end_point = (edge_coords[-1][0], edge_coords[-1][1])
            arrow = [QPointF(end_point[0] - 3, end_point[1]), QPointF(end_point[0] + 3, end_point[1]),
                     QPointF(end_point[0], end_point[1] + 6)]
            brush = QBrush(color)
            painter.setBrush(brush)
            painter.drawPolygon(arrow) 
Example #20
Source File: qfunction_table.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def data(self, index, role):
        if not index.isValid():
            return None

        row = index.row()
        if row >= len(self):
            return None

        col = index.column()
        func = self.func_list[row]

        if role == Qt.DisplayRole:
            return self._get_column_text(func, col)

        elif role == Qt.ForegroundRole:
            color = QColor(0, 0, 0)
            if func.is_syscall:
                color = QColor(0, 0, 0x80)
            elif func.is_plt:
                color = QColor(0, 0x80, 0)
            elif func.is_simprocedure:
                color = QColor(0x80, 0, 0)
            elif func.alignment:
                color = Qt.darkMagenta

            #for w in widgets:
            #    w.setFlags(w.flags() & ~Qt.ItemIsEditable)
            #    w.setForeground(color)

            return QBrush(color)

        elif role == Qt.BackgroundColorRole:
            color = self.workspace.plugins.color_func(func)
            if color is None:
                color = QColor(0xff, 0xff, 0xff)

            return QBrush(color)

        elif role == Qt.FontRole:
            return Conf.tabular_view_font 
Example #21
Source File: qfunction_table.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _get_function_backcolor(self, func) -> QColor:
        return self._backcolor_callback(func) 
Example #22
Source File: config_manager.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def color_constructor(config_option, value):
    if isinstance(value, str):
        value = int(value, 0)

    if type(value) is int:
        return QColor(value)
    elif isinstance(value, dict):
        keys = set(value.keys())
        expected_keys = {'r', 'g', 'b'}
        if keys != expected_keys:
            _l.warning('Found color type with keys %s for option %s, expecting %s. Skipping...',
                    config_option, keys, expected_keys)
        return QColor(value['r'], value['g'], value['b'])
    else:
        _l.error('Failed to parse value %s for option %s', value, config_option) 
Example #23
Source File: trace_plugin.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def color_func(self, func):
        if self.multi_trace != None:
            return self.multi_trace.get_percent_color(func)

        if self.trace != None:
            for itr_func in self.trace.trace_func:
                if itr_func.bbl_addr == func.addr:
                    return QColor(0xf0, 0xe7, 0xda)
            return QColor(0xee, 0xee, 0xee)
        return None 
Example #24
Source File: qtrace_viewer.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _on_select_ins(self, **kwargs):
        if self.trace == None:
            return

        if self.mark is not None:
            for i in self.mark.childItems():
                self.mark.removeFromGroup(i)
                self.scene.removeItem(i)
            self.scene.removeItem(self.mark)

        self.mark = QGraphicsItemGroup()
        self.scene.addItem(self.mark)

        if self.selected_ins:
            addr = next(iter(self.selected_ins))
            positions = self.trace.get_positions(addr)
            if positions: #if addr is in list of positions
                if not self._use_precise_position: #handle case where insn was selected from disas view
                    self.curr_position = positions[0] - self.trace.count
                for p in positions:
                    color = self._get_mark_color(p, self.trace.count)
                    y = self._get_mark_y(p, self.trace.count)

                    if p == self.trace.count + self.curr_position: #add thicker line for 'current' mark
                        self.mark.addToGroup(self.scene.addRect(self.MARK_X, y, self.MARK_WIDTH,
                                            self.MARK_HEIGHT*4, QPen(QColor('black')), QBrush(color)))
                    else:
                        self.mark.addToGroup(self.scene.addRect(self.MARK_X, y, self.MARK_WIDTH,
                                                                self.MARK_HEIGHT, QPen(color), QBrush(color)))
                #y = self._get_mark_y(positions[0], self.trace.count)
                #self.view.verticalScrollBar().setValue(y - 0.5 * self.view.size().height())

                self.scene.update() #force redraw of the scene
                self.scroll_to_position(self.curr_position) 
Example #25
Source File: dep_plugin.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def color_insn(self, addr, selected) -> Optional[QColor]:
        if not selected:
            try:
                block_addr = next(self.covered_blocks.irange(maximum=addr, reverse=True))
            except StopIteration:
                return None
            block_size = self.covered_blocks[block_addr]
            if block_addr <= addr < block_addr + block_size:
                return QColor(0xa5, 0xd0, 0xf3)
        return None 
Example #26
Source File: dep_plugin.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def color_func(self, func) -> Optional[QColor]:
        # test if we have a match
        match = sink_manager.has_function_sink(func.demangled_name)
        if match:
            return self.sink_color

        return None 
Example #27
Source File: base_plugin.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def color_insn(self, addr, selected) -> Optional[QColor]:
        return None 
Example #28
Source File: base_plugin.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def color_func(self, func) -> Optional[QColor]:
        return None 
Example #29
Source File: plugin_manager.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def color_insn(self, addr, selected) -> Optional[QColor]:
        for res in self._dispatch(BasePlugin.color_insn, True, addr, selected):
            if res is not None:
                return res
        return None 
Example #30
Source File: plugin_manager.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def color_block(self, addr) -> Optional[QColor]:
        for res in self._dispatch(BasePlugin.color_block, True, addr):
            if res is not None:
                return res
        return None