Python PyQt5.QtGui.QBrush() Examples

The following are 30 code examples of PyQt5.QtGui.QBrush(). 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 PyQt5.QtGui , or try the search function .
Example #1
Source File: Banners.py    From qiew with GNU General Public License v2.0 10 votes vote down vote up
def __init__(self, dataModel, viewMode):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode
        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))        
        

        # text font
        self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Light)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth  = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine) 
Example #2
Source File: Banners.py    From qiew with GNU General Public License v2.0 8 votes vote down vote up
def __init__(self, dataModel, viewMode):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode

        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))        
        

        # text font
        self.font = QtGui.QFont('Consolas', 11, QtGui.QFont.Light)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth  = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(255, 255, 0), 0, QtCore.Qt.SolidLine) 
Example #3
Source File: Banners.py    From qiew with GNU General Public License v2.0 8 votes vote down vote up
def __init__(self, dataModel, viewMode):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode

        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))        
        

        # text font
        self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Bold)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth  = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(255, 255, 0), 0, QtCore.Qt.SolidLine) 
Example #4
Source File: interSubs.py    From interSubs with MIT License 7 votes vote down vote up
def highligting(self, color, underline_width):
		color = QColor(color)
		color = QColor(color.red(), color.green(), color.blue(), 200)
		painter = QPainter(self)

		if config.hover_underline:
			font_metrics = QFontMetrics(self.font())
			text_width = font_metrics.width(self.word)
			text_height = font_metrics.height()

			brush = QBrush(color)
			pen = QPen(brush, underline_width, Qt.SolidLine, Qt.RoundCap)
			painter.setPen(pen)
			if not self.skip:
				painter.drawLine(0, text_height - underline_width, text_width, text_height - underline_width)

		if config.hover_hightlight:
			x = y = 0
			y += self.fontMetrics().ascent()

			painter.setPen(color)
			painter.drawText(x, y + config.outline_top_padding - config.outline_bottom_padding, self.word) 
Example #5
Source File: editor.py    From imperialism-remake with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, column, row):
        super().__init__()

        self.scene = QtWidgets.QGraphicsScene()
        self.setScene(self.scene)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        # TODO see EditorMap redraw
        brushes = {0: QtGui.QBrush(QtGui.QColor(64, 64, 255)), 1: QtGui.QBrush(QtGui.QColor(64, 255, 64)),
                   2: QtGui.QBrush(QtGui.QColor(64, 255, 64)), 3: QtGui.QBrush(QtGui.QColor(64, 255, 64)),
                   4: QtGui.QBrush(QtGui.QColor(222, 222, 222)), 5: QtGui.QBrush(QtGui.QColor(0, 128, 0)),
                   6: QtGui.QBrush(QtGui.QColor(222, 222, 0))}

        # TODO hardcore tile size somewhere else (and a bit less hard)
        self.TILE_SIZE = 80

        for i in range(0, 6):
            y = i // 4
            x = i % 4
            self.scene.addRect(x * self.TILE_SIZE, y * self.TILE_SIZE, self.TILE_SIZE, self.TILE_SIZE,
                               brush=brushes[i], pen=qt.TRANSPARENT_PEN) 
Example #6
Source File: breathing_dlg.py    From mindfulness-at-the-computer with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        super().__init__()
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setFixedWidth(VIEW_WIDTH_INT)
        self.setFixedHeight(VIEW_HEIGHT_INT)
        t_brush = QtGui.QBrush(QtGui.QColor(mc.mc_global.MC_WHITE_COLOR_STR))
        self.setBackgroundBrush(t_brush)
        self.setRenderHints(
            QtGui.QPainter.Antialiasing |
            QtGui.QPainter.SmoothPixmapTransform
        )
        self.setAlignment(QtCore.Qt.AlignCenter)

        self._graphics_scene = QtWidgets.QGraphicsScene()
        self.setScene(self._graphics_scene)

        # Custom dynamic breathing graphic (may be possible to change this in the future)
        self._breathing_gi = BreathingGraphicsObject()
        self._graphics_scene.addItem(self._breathing_gi)
        self._breathing_gi.update_pos_and_origin_point(VIEW_WIDTH_INT, VIEW_HEIGHT_INT)
        self._breathing_gi.hover_signal.connect(self._breathing_gi_hover)
        # -Please note that for breathing in we use a static sized rectangle (instead of the one the user sees),
        # this is the reason for using "hover" instead of "enter above"
        self._breathing_gi.leave_signal.connect(self._breathing_gi_leave)

        # Text
        self.text_gi = TextGraphicsItem()
        self.text_gi.setAcceptHoverEvents(False)  # -so that the underlying item will not be disturbed
        ib_str = mc.model.PhrasesM.get(mc.mc_global.active_phrase_id_it).ib
        self.text_gi.setHtml(mc.mc_global.get_html(ib_str))
        self.text_gi.setTextWidth(200)
        self.text_gi.update_pos_and_origin_point(VIEW_WIDTH_INT, VIEW_HEIGHT_INT)
        self.text_gi.setDefaultTextColor(QtGui.QColor(mc.mc_global.MC_DARKER_GREEN_COLOR_STR))
        self._graphics_scene.addItem(self.text_gi)

        self._peak_scale_ft = 1 
Example #7
Source File: rawscriptsmenu.py    From Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader with MIT License 6 votes vote down vote up
def addRawScriptsToTree(self):
        self.treeWidget.clear()
        for i, vid in enumerate(videoscriptcore.video_scripts):
            new_item = self.addChild(vid.sub_reddit, "script%s"%vid.vidNo)
            if vid.status == "EDITING":
                new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("yellow")))
            elif vid.status == "RAW":
                if settings.darkMode:
                    new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("white")))
                else:
                    new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("black")))
            elif vid.status == "COMPLETE":
                new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("green")))
            elif vid.status == "MANUALCOMPLETE":
                new_item.setForeground(0, QtGui.QBrush(QtGui.QColor("darkgreen")))

        self.treeWidget.expandToDepth(0) 
Example #8
Source File: rawscriptsmenu.py    From Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader with MIT License 6 votes vote down vote up
def updateColors(self):
        try:
            children = self.count_tems()
            for i in range(len(children)):
                scriptName = children[i].text(0)
                scriptNo = scriptName.replace("script", "")
                indexSelectedScript = videoscriptcore.getScripts().index(int(scriptNo))
                status = videoscriptcore.video_scripts[indexSelectedScript].status
                if hasattr(self, "currentTreeWidget"):
                    if status == "RAW":
                        if settings.darkMode:
                            children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("white")))
                        else:
                            children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("black")))
                    elif status == "EDITING":
                        children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("yellow")))
                    elif status == "COMPLETE":
                        children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("green")))
                    elif status == "MANUALCOMPLETE":
                        children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("darkgreen")))
                    elif status == "QUALITY":
                        children[i].setForeground(0, QtGui.QBrush(QtGui.QColor("red")))
        except:
            print("error occured recolouring scripts") 
Example #9
Source File: rawscriptsmenu.py    From Automatic-Youtube-Reddit-Text-To-Speech-Video-Generator-and-Uploader with MIT License 6 votes vote down vote up
def updateDetailScreen(self):
        self.textBrowser.clear()
        self.currentTreeWidget = self.treeWidget.currentItem()
        try:
            scriptName = self.currentTreeWidget.text(0)
            scriptNo = scriptName.replace("script", "")
            indexSelectedScript = videoscriptcore.getScripts().index(int(scriptNo))
            selectedScript = videoscriptcore.video_scripts[indexSelectedScript]
            self.currentScriptSelected = selectedScript.scriptno
            self.textBrowser.append("Category: %s\n"%selectedScript.sub_reddit)
            self.textBrowser.append("Upvotes: %s"%selectedScript.upvotes)
            self.textBrowser.append("Author: %s"%selectedScript.author)
            self.textBrowser.append("Vid Number: %s"%selectedScript.vidNo)
            self.textBrowser.append("Status: %s"%selectedScript.status)
            self.textBrowser.append("Script ID: %s"%selectedScript.scriptno)
            self.textBrowser.append("Being Edited by: %s"%selectedScript.editedby)
            self.textBrowser.append("\nTitle: %s\n"%selectedScript.title)

            self.editedby.setText(selectedScript.editedby)
            self.currentTreeWidget.setForeground(0, QtGui.QBrush(QtGui.QColor("blue")))
        except AttributeError:
            pass
        self.updateColors() 
Example #10
Source File: paint.py    From 15-minute-apps with MIT License 6 votes vote down vote up
def selectpoly_copy(self):
        """
        Copy a polygon region from the current image, returning it.

        Create a mask for the selected area, and use it to blank
        out non-selected regions. Then get the bounding rect of the
        selection and crop to produce the smallest possible image.

        :return: QPixmap of the copied region.
        """
        self.timer_cleanup()

        pixmap = self.pixmap().copy()
        bitmap = QBitmap(*CANVAS_DIMENSIONS)
        bitmap.clear()  # Starts with random data visible.

        p = QPainter(bitmap)
        # Construct a mask where the user selected area will be kept, 
        # the rest removed from the image is transparent.
        userpoly = QPolygon(self.history_pos + [self.current_pos])
        p.setPen(QPen(Qt.color1))
        p.setBrush(QBrush(Qt.color1))  # Solid color, Qt.color1 == bit on.
        p.drawPolygon(userpoly)
        p.end()

        # Set our created mask on the image.
        pixmap.setMask(bitmap)

        # Calculate the bounding rect and return a copy of that region.
        return pixmap.copy(userpoly.boundingRect())

    # Select rectangle events 
Example #11
Source File: paint.py    From 15-minute-apps with MIT License 6 votes vote down vote up
def generic_shape_mouseReleaseEvent(self, e):
        if self.last_pos:
            # Clear up indicator.
            self.timer_cleanup()

            p = QPainter(self.pixmap())
            p.setPen(QPen(self.primary_color, self.config['size'], Qt.SolidLine, Qt.SquareCap, Qt.MiterJoin))

            if self.config['fill']:
                p.setBrush(QBrush(self.secondary_color))
            getattr(p, self.active_shape_fn)(QRect(self.origin_pos, e.pos()), *self.active_shape_args)
            self.update()

        self.reset_mode()

    # Line events 
Example #12
Source File: Banners.py    From dcc with Apache License 2.0 6 votes vote down vote up
def __init__(self, themes, dataModel, viewMode):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode

        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(themes['background'])

        # text font
        self.font = themes['font']

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(themes['pen'], 0, QtCore.Qt.SolidLine) 
Example #13
Source File: Banners.py    From dcc with Apache License 2.0 6 votes vote down vote up
def __init__(self, themes, dataModel, viewMode):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode
        self.backgroundBrush = QtGui.QBrush(themes['background'])

        self.qpix = self._getNewPixmap(self.width, self.height)

        # text font
        self.font = themes['font']

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(themes['pen'], 0, QtCore.Qt.SolidLine) 
Example #14
Source File: waiting_animation.py    From malss with MIT License 6 votes vote down vote up
def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 200)))
        painter.setPen(QPen(Qt.NoPen))

        if self.lists is not None:
            path = os.path.abspath(os.path.dirname(__file__)) + '/static/'
            path += self.lists[self.list_index] + '.png'
            self.list_index += 1
            if self.list_index >= len(self.lists):
                self.list_index = 0
            image = QImage(path)
            rect_image = image.rect()
            rect_painter = event.rect()
            dx = (rect_painter.width() - rect_image.width()) / 2.0
            dy = (rect_painter.height() - rect_image.height()) / 2.0
            painter.drawImage(dx, dy, image)

        painter.end() 
Example #15
Source File: binary.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
def init(self, viewMode, parent):
        self._viewMode = viewMode

        self.MZbrush = QtGui.QBrush(QtGui.QColor(128, 0, 0))
        self.greenPen = QtGui.QPen(QtGui.QColor(255, 255, 0))
        self.grayBrush = QtGui.QBrush(QtGui.QColor(128, 128, 128))
        self.whitePen = QtGui.QPen(QtGui.QColor(255, 255, 255))        


        self.textDecorator = TextDecorator(viewMode)
        self.textDecorator = HighlightASCII(self.textDecorator)
        self.textDecorator = HighlightPrefix(self.textDecorator, 'MZ', brush=self.MZbrush, pen=self.greenPen)
        self.textDecorator = HighlightPrefix(self.textDecorator, 'PE\x00\x00', brush=self.MZbrush, pen=self.greenPen)
        self.textDecorator = HighlightPrefix(self.textDecorator, '\xFF\x15', additionalLength=4, brush=self.grayBrush, pen=self.whitePen)
        self.textDecorator = HighlightWideChar(self.textDecorator)

        self._viewMode.setTransformationEngine(self.textDecorator)
        return True 
Example #16
Source File: bootsector.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
def init(self, viewMode, parent):
        self.viewMode = viewMode

        self.MZbrush = QtGui.QBrush(QtGui.QColor(128, 0, 0))
        self.greenPen = QtGui.QPen(QtGui.QColor(255, 255, 0))


        self.textDecorator = TextDecorator(viewMode)
        self.textDecorator = HighlightASCII(self.textDecorator)
        self.textDecorator = HighlightPrefix(self.textDecorator, '\x55\xAA', brush=self.MZbrush, pen=self.greenPen)

        self.viewMode.setTransformationEngine(self.textDecorator)
        self.viewMode.selector.addSelection((446,      446+1*16, QtGui.QBrush(QtGui.QColor(125, 75, 150)), 0.8), type=TextSelection.SelectionType.PERMANENT)
        self.viewMode.selector.addSelection((446+16,   446+2*16, QtGui.QBrush(QtGui.QColor(55, 125, 50)), 0.8), type=TextSelection.SelectionType.PERMANENT)
        self.viewMode.selector.addSelection((446+2*16, 446+3*16, QtGui.QBrush(QtGui.QColor(125, 75, 150)), 0.8), type=TextSelection.SelectionType.PERMANENT)
        self.viewMode.selector.addSelection((446+3*16, 446+4*16, QtGui.QBrush(QtGui.QColor(55, 125, 50)), 0.8), type=TextSelection.SelectionType.PERMANENT)

        return True 
Example #17
Source File: first.py    From FIRST-plugin-ida with GNU General Public License v2.0 6 votes vote down vote up
def set_colors(self, changed='66d9ef', unchanged='d2d2d2', default='ffffff', select='a9c5ff'):
                '''Sets the colors associated with the various properties.

                Args:
                    changed (:obj:`str`): Change color, default: '66d9ef'
                    unchanged (:obj:`str`): Unchanged color, default: 'd2d2d2'
                    default (:obj:`str`): Default color, default: 'ffffff'
                    select (:obj:`str`): Selected color, default: 'a9c5ff'
                '''
                colors = [changed, unchanged, default, select]

                if None in [re.match('^[a-fA-F0-9]{6}$', x) for x in colors]:
                    #   Invalid color provided
                    return

                self.colors = []
                for c in colors:
                    r, g, b = int(c[:2], 16), int(c[2:4], 16), int(c[-2:], 16)
                    self.colors.append(QtGui.QBrush(QtGui.QColor.fromRgb(r, g, b))) 
Example #18
Source File: elf.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, dataModel, viewMode, elfplugin):
        self.width = 0
        self.height = 0
        self.dataModel = dataModel
        self.viewMode = viewMode
        self.qpix = self._getNewPixmap(self.width, self.height)
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))

        self.elfplugin = elfplugin

        self.elf = self.elfplugin.elf        

        # text font
        self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Bold)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self.fontWidth  = fm.width('a')
        self.fontHeight = fm.height()

        self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine) 
Example #19
Source File: DisasmViewMode.py    From qiew with GNU General Public License v2.0 6 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]
        cx, width, text = asm.getSelectedToken(cursorX)

        cemu = ConsoleEmulator(qp, self.ROWS, self.COLUMNS)

        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 #20
Source File: playerconditionwidget.py    From PyPipboyApp with GNU General Public License v3.0 6 votes vote down vote up
def init(self, app, datamanager):
        super().init(app, datamanager)
        self.statsColor = QtGui.QColor.fromRgb(20,255,23)
        self.dataManager = datamanager
        self.dataManager.registerRootObjectListener(self._onPipRootObjectEvent)
        self.statsView = self.widget.graphicsView
        self.statsScene = QtWidgets.QGraphicsScene()
        self.statsScene.setBackgroundBrush(QtGui.QBrush(QtGui.QColor.fromRgb(0,0,0)))
        self.statsView.setScene(self.statsScene)
        self.bodyCondFilePath = os.path.join('res', 'body_condition_0.svg')
        self.headCondFilePath = os.path.join('res', 'head_condition_0.svg')
        self.headCondition = 0
        headPixmap = self.imageFactory.getPixmap(self.headCondFilePath, height=50, color=self.statsColor)
        self.statsHeadItem = self.statsScene.addPixmap(headPixmap)
        self.statsHeadItem.setPos(-headPixmap.width()/2, 0)
        self.bodyCondition = 0
        bodyPixmap = self.imageFactory.getPixmap(self.bodyCondFilePath, height=100, color=self.statsColor)
        self.statsBodyItem = self.statsScene.addPixmap(bodyPixmap)
        self.statsBodyItem.setPos(-bodyPixmap.width()/2, 42) 
Example #21
Source File: pkcharts.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def paintEvent(self, event):
        if not self.data: return
        QtWidgets.QFrame.paintEvent(self, event)
        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        # Draw background
        painter.setBrush(QtGui.QBrush(self.bgcolor))
        painter.setPen(Qt.NoPen)
        painter.drawRoundedRect(self.contentsRect(), 2, 2)
        # Draw the bars
        barwidth = (self.width() - 4) / len(self.data)
        for i in range(len(self.data)):
            barheight = int(self.height() * (self.data[i] / 100))
            baroffset = i * barwidth + 2
            painter.setBrush(QtGui.QBrush(self.colors[i % len(self.colors)]))
            painter.drawRoundedRect(baroffset, self.height()-barheight, barwidth, barheight, 1, 1)
        painter.end() 
Example #22
Source File: pkcharts.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def paintEvent(self, event):
        QtWidgets.QFrame.paintEvent(self, event)
        painter = QtGui.QPainter()
        painter.begin(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        painter.setPen(Qt.NoPen)
        # Draw the Pie
        rwidth = int(min([self.width(), self.height()]) - 2)
        x = int((self.width() / 2) - (rwidth / 2))
        y = int((self.height() / 2) - (rwidth / 2))
        rect = QtCore.QRect(x, y, rwidth, rwidth)
        angle1 = 0
        for i in range(len(self.data)):
            angle2 = angle1 + (3.6 * self.data[i])
            painter.setBrush(QtGui.QBrush(self.colors[i % len(self.colors)]))
            painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16)
            angle1 = angle2
        # Draw the remainer (background)
        angle2 = 360
        painter.setBrush(QtGui.QBrush(self.bgcolor))
        painter.drawPie(rect, angle1*-16, (angle2-angle1)*-16)
        painter.end() 
Example #23
Source File: generate_protocol_tab.py    From MDT with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _create_volume_number_column(self):
        """Callback function to generate the volume number column cells.

        This should return a list of cells in the correct order.
        """
        cells = []
        for volume_nmr in range(self._protocol.length):
            cell = NumericalSortedTableItem(str(volume_nmr))
            cell.setFlags(QtCore.Qt.ItemIsEnabled)
            cell.setBackground(QBrush(Qt.lightGray))
            cells.append(cell)
        return cells 
Example #24
Source File: HyperLprGUI.py    From lpr with Apache License 2.0 5 votes vote down vote up
def init_ui(self):

        scene = QGraphicsScene()
        scene.setBackgroundBrush(QColor(100, 100, 100))
        scene.setItemIndexMethod(QGraphicsScene.BspTreeIndex)

        scene.setSceneRect(scene.itemsBoundingRect())

        self.setDragMode(QGraphicsView.RubberBandDrag)
        self.setViewportUpdateMode(QGraphicsView.FullViewportUpdate)
        self.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing)

        self.frame_item = QGraphicsPixmapItem()

        self.text_item_offset = 0
        self.rect_item_array = []
        self.text_item_array = []
        for i in range(0, 5):
            rect_item = QGraphicsRectItem()
            rect_item.setVisible(False)
            rect_item.setZValue(20.0)
            rect_item.setPen(QPen(Qt.red, 5))
            rect_item.setRect(20, 20, 20, 20)
            scene.addItem(rect_item)
            self.rect_item_array.append(rect_item)
            text_item = QGraphicsSimpleTextItem("")
            text_item.setBrush(QBrush(Qt.red))
            text_item.setZValue(20.0)
            text_item.setPos(10, 50)
            text_item.setFont(QFont("黑体", 24))
            text_item.setVisible(False)
            scene.addItem(text_item)
            self.text_item_array.append(text_item)

        scene.addItem(self.frame_item)

        self.curr_factor = 1.0

        self.setScene(scene) 
Example #25
Source File: generate_protocol_tab.py    From MDT with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _update_table_view(self):
        all_column_names, real_column_names, estimated_column_names, system_column_names = self._get_column_names()

        self.protocol_table.clear()
        self.protocol_table.setRowCount(self._protocol.length)
        self.protocol_table.setColumnCount(len(all_column_names))

        for index, column_name in enumerate(all_column_names):
            header_cell = QTableWidgetItem(column_name)
            if column_name in estimated_column_names:
                header_cell.setToolTip('This column is estimated from the other columns in the protocol.')
            self.protocol_table.setHorizontalHeaderItem(index, header_cell)

        for column_ind, column_name in enumerate(all_column_names):
            if column_name in system_column_names:
                generate_function = self._system_columns[column_name]
                cells = generate_function()
                for row, cell in enumerate(cells):
                    self.protocol_table.setItem(row, column_ind, cell)
            else:
                try:
                    values = self._protocol.get_column(column_name)
                    for row in range(self._protocol.length):
                        cell = NumericalSortedTableItem('{:e}'.format(values[row, 0]))
                        cell.setFlags(QtCore.Qt.ItemIsEnabled)

                        if column_name in estimated_column_names:
                            cell.setBackground(QBrush(Qt.lightGray))

                        self.protocol_table.setItem(row, column_ind, cell)
                except KeyError:
                    for row in range(self._protocol.length):
                        cell = QTableWidgetItem('?')
                        cell.setFlags(QtCore.Qt.ItemIsEnabled)
                        cell.setBackground(QBrush(Qt.lightGray))
                        self.protocol_table.setItem(row, column_ind, cell)

        self.protocol_table.resizeColumnsToContents() 
Example #26
Source File: HexViewMode.py    From qiew with GNU General Public License v2.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 #27
Source File: ntfs.py    From qiew with GNU General Public License v2.0 5 votes vote down vote up
def _goto_mft(self):
        fobj = self.ntfs.mft.get_file_record(0)

        if fobj:
            self._viewMode.selector.addSelection((fobj.offset, fobj.offset + fobj.size, QtGui.QBrush(QtGui.QColor(125, 175, 150)), 0.4), type=TextSelection.SelectionType.IF_CURSOR_IN_RANGE)
            self._viewMode.goTo(fobj.offset) 
Example #28
Source File: ntfs.py    From qiew with GNU General Public License v2.0 5 votes vote down vote up
def _goto_root(self):
        fobj = self.ntfs.mft.get_file_record(5)

        if fobj:
            self._viewMode.selector.addSelection((fobj.offset, fobj.offset + fobj.size, QtGui.QBrush(QtGui.QColor(125, 175, 150)), 0.4), type=TextSelection.SelectionType.IF_CURSOR_IN_RANGE)
            self._viewMode.goTo(fobj.offset) 
Example #29
Source File: BinViewMode.py    From qiew with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, width, height, data, cursor, widget=None, plugin=None):
        super(BinViewMode, self).__init__()

        self.dataModel = data
        self.addHandler(self.dataModel)

        self.width = width
        self.height = height

        self.cursor = cursor
        self.widget = widget

        self.refresh = True

        self.selector = TextSelection.DefaultSelection(self)

        # background brush
        self.backgroundBrush = QtGui.QBrush(QtGui.QColor(0, 0, 128))

        # text font
        #self.font = QtGui.QFont('Terminus (TTF)', 12, QtGui.QFont.Light)
        #self.font.setStyleHint(QtGui.QFont.AnyStyle, QtGui.QFont.PreferBitmap)
        self.font = QtGui.QFont('Terminus', 11, QtGui.QFont.Light)

        # font metrics. assume font is monospaced
        self.font.setKerning(False)
        self.font.setFixedPitch(True)
        fm = QtGui.QFontMetrics(self.font)
        self._fontWidth  = fm.width('a')
        self._fontHeight = fm.height()


        
        self.textPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine)
        self.resize(width, height)

        self.Paints = {}
        self.newPix = None
        self.Ops = []
        self.plugin = plugin 
Example #30
Source File: pkwidgets.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def paint_slider_off(self, painter):
        swidth = int((self.width() / 2) - 2)
        sheight = int(self.height() - 2)
        painter.setBrush(QtGui.QBrush(QtGui.QColor(0,0,0,50)))
        painter.drawRoundedRect(self.contentsRect(), 3, 3)
        painter.setBrush(QtGui.QBrush(self.bgcolor_slider))
        painter.drawRoundedRect(3, 1, swidth, sheight, 2, 2)
        painter.setPen(QtGui.QColor(0,0,0,150))
        painter.drawText(swidth+3, 1, swidth, sheight, Qt.AlignCenter | Qt.AlignVCenter, 'Off')