Python PyQt5.QtGui.QPen() Examples

The following are 30 code examples of PyQt5.QtGui.QPen(). 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 9 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 9 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 8 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: lab4.py    From Computer-graphics with MIT License 7 votes vote down vote up
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511)
        self.mainview.setScene(self.scene)
        self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied)
        self.pen = QPen()
        self.color_line = QColor(Qt.black)
        self.color_bground = QColor(Qt.white)
        self.draw_once.clicked.connect(lambda: draw_once(self))
        self.clean_all.clicked.connect(lambda: clear_all(self))
        self.btn_bground.clicked.connect(lambda: get_color_bground(self))
        self.btn_line.clicked.connect(lambda: get_color_line(self))
        self.draw_centr.clicked.connect(lambda: draw_centr(self))
        layout = QtWidgets.QHBoxLayout()
        layout.addWidget(self.what)
        layout.addWidget(self.other)
        self.setLayout(layout)
        self.circle.setChecked(True)
        self.canon.setChecked(True)
        #self.circle.toggled.connect(lambda : change_text(self)) 
Example #6
Source File: DisasmViewMode.py    From dcc with Apache License 2.0 6 votes vote down vote up
def _write_instruction2(self, asm, qp, cemu):
        s = asm.operands
        idx = 0
        qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))

        for tok in asm.lexer:
            if tok.lexpos > idx:
                cemu.write(s[idx:tok.lexpos])
                idx = tok.lexpos

            qp.save()
            if tok.type == 'REGISTER':
                qp.setPen(QtGui.QPen(QtGui.QColor('white')))

            if tok.type == 'NUMBER':
                qp.setPen(QtGui.QPen(QtGui.QColor('green')))

            cemu.write(tok.value)

            qp.restore()
            idx = tok.lexpos + len(tok.value)

        if idx < len(s):
            cemu.write(s[idx:]) 
Example #7
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(QtGui.QColor(192, 192, 192), 0, QtCore.Qt.SolidLine) 
Example #8
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 #9
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 #10
Source File: BinViewMode.py    From dcc with 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 #11
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 #12
Source File: lab3.py    From Computer-graphics with MIT License 6 votes vote down vote up
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = QtWidgets.QGraphicsScene(0, 0, 511, 511)
        self.mainview.setScene(self.scene)
        self.image = QImage(511, 511, QImage.Format_ARGB32_Premultiplied)
        self.pen = QPen()
        self.color_line = QColor(Qt.black)
        self.color_bground = QColor(Qt.white)
        self.draw_line.clicked.connect(lambda: draw_line(self))
        self.clean_all.clicked.connect(lambda : clear_all(self))
        self.btn_bground.clicked.connect(lambda: get_color_bground(self))
        self.btn_line.clicked.connect(lambda: get_color_line(self))
        self.draw_sun.clicked.connect(lambda: draw_sun(self))
        self.cda.setChecked(True) 
Example #13
Source File: lab6.py    From Computer-graphics with MIT License 6 votes vote down vote up
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = myScene(0, 0, 561, 581)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
        self.image.fill(col_zero)
        self.lock.clicked.connect(lambda: lock(self))
        self.erase.clicked.connect(lambda: clean_all(self))
        self.paint.clicked.connect(lambda: fill_with_seed(self))
        self.addpoint.clicked.connect(lambda: add_point_by_btn(self))
        self.pixel.clicked.connect(lambda: set_flag_zat(self))
        self.addcircle.clicked.connect(lambda: set_flag_cir(self))
        self.edges = []
        self.point_now = None
        self.point_lock = None

        self.pen = QPen(col_one)
        self.delay.setChecked(False) 
Example #14
Source File: lab7.py    From Computer-graphics with MIT License 6 votes vote down vote up
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = Scene(0, 0, 561, 581)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
        self.image.fill(Qt.white)
        self.bars.clicked.connect(lambda : set_bars(self))
        self.erase.clicked.connect(lambda: clean_all(self))
        self.paint.clicked.connect(lambda: clipping(self))
        self.rect.clicked.connect(lambda: set_rect(self))
        self.ect.clicked.connect(lambda: add_bars(self))
        self.lines = []
        self.clip = None
        self.point_now = None
        self.input_bars = False
        self.input_rect = False
        self.pen = QPen(red) 
Example #15
Source File: lab5.py    From Computer-graphics with MIT License 6 votes vote down vote up
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = myScene(0, 0, 561, 581)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
        self.image.fill(col_zero)
        self.lock.clicked.connect(lambda: lock(self))
        self.erase.clicked.connect(lambda: clean_all(self))
        self.paint.clicked.connect(lambda: fill_xor(self))
        self.addpoint.clicked.connect(lambda: add_point_by_btn(self))
        self.edges = []
        self.point_now = None
        self.point_lock = None
        self.pen = QPen(col_one)
        self.delay.setChecked(False) 
Example #16
Source File: lab8.py    From Computer-graphics with MIT License 6 votes vote down vote up
def __init__(self):
        QtWidgets.QWidget.__init__(self)
        uic.loadUi("window.ui", self)
        self.scene = Scene(0, 0, 561, 581)
        self.scene.win = self
        self.view.setScene(self.scene)
        self.image = QImage(561, 581, QImage.Format_ARGB32_Premultiplied)
        self.image.fill(Qt.white)
        self.bars.clicked.connect(lambda : set_bars(self))
        self.erase.clicked.connect(lambda: clean_all(self))
        self.paint.clicked.connect(lambda: clipping(self))
        self.rect.clicked.connect(lambda: set_rect(self))
        self.ect.clicked.connect(lambda: add_bars(self))
        self.lock.clicked.connect(lambda: lock(self))
        self.lines = []
        self.edges = []
        self.clip = None
        self.point_now_rect = None
        self.point_now_bars = None
        self.point_lock = None
        self.input_bars = False
        self.input_rect = False
        self.pen = QPen(black) 
Example #17
Source File: TextDecorators.py    From qiew with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, viewmode):
        self.operations = []
        self.dataModel = viewmode.getDataModel()
        self.viewmode = viewmode
        self.penMap = {}
        self.brushMap = {}
        self.PenInterval = []

        self.normalPen = QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine)

        # if we want to generate T/F table
        self.Special =  string.ascii_letters + string.digits + ' .;\':;=\"?-!()/\\_'
        self.Special = [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, 
                        False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, True, 
                        True, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, True, False, True, 
                        False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, 
                        True, True, True, False, True, False, False, True, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True,
                        True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, 
                        False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, 
                        False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, 
                        False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, 
                        False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, 
                        False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, 
                        False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] 
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: 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 #20
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 #21
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 #22
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 #23
Source File: player.py    From MusicBox with MIT License 6 votes vote down vote up
def paintEvent(self, event):
        painter = QPainter(self)
        painter.setFont(self.font)
        
        linear = QLinearGradient(QPoint(self.rect().topLeft()), QPoint(self.rect().bottomLeft()))
        linear.setStart(0, 10)
        linear.setFinalStop(0, 50)
        linear.setColorAt(0.1, QColor(14, 179, 255));
        linear.setColorAt(0.5, QColor(154, 232, 255));
        linear.setColorAt(0.9, QColor(14, 179, 255));
        
        linear2 = QLinearGradient(QPoint(self.rect().topLeft()), QPoint(self.rect().bottomLeft()))
        linear2.setStart(0, 10)
        linear2.setFinalStop(0, 50)
        linear2.setColorAt(0.1, QColor(222, 54, 4));
        linear2.setColorAt(0.5, QColor(255, 172, 116));
        linear2.setColorAt(0.9, QColor(222, 54, 4));
        
        painter.setPen(QColor(0, 0, 0, 200));
        painter.drawText(QRect(1, 1, self.screen.width(), 60), Qt.AlignHCenter | Qt.AlignVCenter, self.lyric)
        
        painter.setPen(QColor('transparent'));
        self.textRect = painter.drawText(QRect(0, 0, self.screen.width(), 60), Qt.AlignHCenter | Qt.AlignVCenter, self.lyric)

        painter.setPen(QPen(linear, 0))
        painter.drawText(self.textRect, Qt.AlignLeft | Qt.AlignVCenter, self.lyric)
        if self.intervel != 0:
            self.widthBlock = self.textRect.width()/(self.intervel/150.0)
        else:
            self.widthBlock = 0
        self.maskRect = QRectF(self.textRect.x(), self.textRect.y(), self.textRect.width(), self.textRect.height())
        self.maskRect.setWidth(self.maskWidth)
        painter.setPen(QPen(linear2, 0));
        painter.drawText(self.maskRect, Qt.AlignLeft | Qt.AlignVCenter, self.lyric) 
Example #24
Source File: globalmapwidget.py    From PyPipboyApp with GNU General Public License v3.0 6 votes vote down vote up
def showArtilleryRange(self, value, updateSignal = True):
        idList = self.widget._app.settings.value('globalmapwidget/showArtilleryFormIDs', [])
        if idList == None: # Yes, this happens (because of buggy Linux QSettings implementation)
            idList = []
        if value:
            if self.pipValue and self.pipValue.child('LocationMarkerFormId'):
                id = hex(self.pipValue.child('LocationMarkerFormId').value()).lower()
                if not id in idList:
                    idList.append(id)
            self.artilleryRangeCircle = self.scene.addEllipse(0, 0, 0, 0)
            self.artilleryRangeCircle.setPen(QtGui.QPen(self.color, 2))
            self.positionDirty = True
        else:
            if self.pipValue and self.pipValue.child('LocationMarkerFormId'):
                id = hex(self.pipValue.child('LocationMarkerFormId').value()).lower()
                if id in idList:
                    idList.remove(id)
            if self.artilleryRangeCircle:
                self.scene.removeItem(self.artilleryRangeCircle)
            self.artilleryRangeCircle = None
            self.positionDirty = True
        self.widget._app.settings.setValue('globalmapwidget/showArtilleryFormIDs', idList)
        if updateSignal:
            self.doUpdate() 
Example #25
Source File: sparrow-wifi.py    From sparrow-wifi with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, displayText, parent, textColor=Qt.white):
        # super().__init__(displayText, parent)
        super().__init__(parent=parent)
        self.textColor = textColor
        self.chartParent = parent
        
        # Pen draws the outline, brush does the character fill
        # The doc says the pen is slow so don't use it unless you have to
        # penBorder = QPen(self.textColor)
        # penBorder.setWidth(2)
        # self.setPen(penBorder)

        newBrush = QBrush(self.textColor)
        self.setBrush(newBrush)
        
    # Has setText() and text() methods 
Example #26
Source File: items.py    From Miyamoto with GNU General Public License v3.0 6 votes vote down vote up
def paint(self, painter, option, widget):
        """
        Paints the object
        """
        if self.isSelected():
            painter.setPen(QtGui.QPen(globals.theme.color('object_lines_s'), 1, Qt.DotLine))
            painter.drawRect(self.SelectionRect)
            painter.fillRect(self.SelectionRect, globals.theme.color('object_fill_s'))

            painter.fillRect(self.DrawGrabberRectTL, globals.theme.color('object_lines_s'))
            painter.fillRect(self.DrawGrabberRectTR, globals.theme.color('object_lines_s'))
            painter.fillRect(self.DrawGrabberRectBL, globals.theme.color('object_lines_s'))
            painter.fillRect(self.DrawGrabberRectBR, globals.theme.color('object_lines_s'))
            painter.fillRect(self.DrawGrabberRectMT, globals.theme.color('object_lines_s'))
            painter.fillRect(self.DrawGrabberRectML, globals.theme.color('object_lines_s'))
            painter.fillRect(self.DrawGrabberRectMB, globals.theme.color('object_lines_s'))
            painter.fillRect(self.DrawGrabberRectMR, globals.theme.color('object_lines_s')) 
Example #27
Source File: pkcharts.py    From pkmeter with BSD 3-Clause "New" or "Revised" License 5 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 Lines
        for i in range(len(self.data[0])):
            path = None
            pen = QtGui.QPen(self.colors[i % len(self.colors)])
            for j in range(len(self.data)):
                value = self.data[j][i]
                prevvalue = self.data[j-1][i]
                if value == -1 or prevvalue == -1:
                    continue
                if not self.showzero and value <= 0 and prevvalue <= 0:
                    continue
                x1 = (self.pxperpt * (j - 0.5) + self.pxperpt / 4) - self.offset
                x2 = (self.pxperpt * j + self.pxperpt / 4) - self.offset
                y1 = self.height() - int((self.height() - 1) * (prevvalue / self.maxvalue))
                y2 = self.height() - int((self.height() - 1) * (value / self.maxvalue))
                path = path or QtGui.QPainterPath(QtCore.QPointF(x1,y1))
                path.cubicTo(x1, y1, x1, y2, x2, y2)
            if path:
                painter.strokePath(path, pen)
        painter.end() 
Example #28
Source File: DisasmViewMode.py    From dcc with 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 #29
Source File: DisasmViewMode.py    From dcc with 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 #30
Source File: SourceViewMode.py    From dcc with Apache License 2.0 5 votes vote down vote up
def __init__(self, themes, width, height, data, cursor, widget=None):
        super(SourceViewMode, self).__init__()

        self.themes = themes

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

        self.width = width
        self.height = height

        self.cursor = cursor
        self.widget = widget

        self.refresh = True

        # background brush
        self.backgroundBrush = QtGui.QBrush(self.themes['background'])

        # text font
        self.font = self.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(self.themes['pen'], 0, QtCore.Qt.SolidLine)
        self.resize(width, height)

        self.Paints = {}
        self.Ops = []
        self.newPix = None

        self.selector = TextSelection.DefaultSelection(themes, self)

        self.LINES = self.dataModel.current_class.get_source().split('\n')