Python PyQt5.QtGui.QPen() Examples
The following are 30 code examples for showing how to use PyQt5.QtGui.QPen(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
PyQt5.QtGui
, or try the search function
.
Example 1
Project: interSubs Author: oltodosel File: interSubs.py License: MIT License | 7 votes |
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 2
Project: dcc Author: amimo File: DisasmViewMode.py License: Apache License 2.0 | 6 votes |
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 3
Project: dcc Author: amimo File: Banners.py License: Apache License 2.0 | 6 votes |
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 4
Project: dcc Author: amimo File: Banners.py License: Apache License 2.0 | 6 votes |
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 5
Project: dcc Author: amimo File: Banners.py License: Apache License 2.0 | 6 votes |
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 6
Project: dcc Author: amimo File: BinViewMode.py License: Apache License 2.0 | 6 votes |
def handleEditMode(self, modifiers, key, event): if key in range(0, 256): offs = self.getCursorOffsetInPage() self.dataModel.setData_b(self.dataModel.getOffset() + offs, str(event.text())) z = self.dataModel.getOffset() + offs # TODO: sa nu se repete, tre original_transformengine self.transformationEngine = RangePen(self.original_textdecorator, z, z + 0, QtGui.QPen(QtGui.QColor(218, 94, 242), 0, QtCore.Qt.SolidLine), ignoreHighlights=True) self.moveCursor(Directions.Right) x, y = self.cursor.getPosition() self.draw(refresh=True, row=y, howMany=1)
Example 7
Project: malss Author: canard0328 File: waiting_animation.py License: MIT License | 6 votes |
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 8
Project: Computer-graphics Author: Panda-Lewandowski File: lab6.py License: MIT License | 6 votes |
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 9
Project: Computer-graphics Author: Panda-Lewandowski File: lab7.py License: MIT License | 6 votes |
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 10
Project: Computer-graphics Author: Panda-Lewandowski File: lab5.py License: MIT License | 6 votes |
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 11
Project: Computer-graphics Author: Panda-Lewandowski File: lab8.py License: MIT License | 6 votes |
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 12
Project: Computer-graphics Author: Panda-Lewandowski File: lab4.py License: MIT License | 6 votes |
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 13
Project: qiew Author: mtivadar File: TextDecorators.py License: GNU General Public License v2.0 | 6 votes |
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 14
Project: qiew Author: mtivadar File: Banners.py License: GNU General Public License v2.0 | 6 votes |
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 15
Project: qiew Author: mtivadar File: Banners.py License: GNU General Public License v2.0 | 6 votes |
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 16
Project: qiew Author: mtivadar File: Banners.py License: GNU General Public License v2.0 | 6 votes |
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 17
Project: qiew Author: mtivadar File: elf.py License: GNU General Public License v2.0 | 6 votes |
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 18
Project: qiew Author: mtivadar File: bootsector.py License: GNU General Public License v2.0 | 6 votes |
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 19
Project: qiew Author: mtivadar File: binary.py License: GNU General Public License v2.0 | 6 votes |
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 20
Project: 15-minute-apps Author: learnpyqt File: paint.py License: MIT License | 6 votes |
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 21
Project: PyPipboyApp Author: matzman666 File: globalmapwidget.py License: GNU General Public License v3.0 | 6 votes |
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 22
Project: sparrow-wifi Author: ghostop14 File: sparrow-wifi.py License: GNU General Public License v3.0 | 6 votes |
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 23
Project: Miyamoto Author: aboood40091 File: items.py License: GNU General Public License v3.0 | 6 votes |
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 24
Project: pkmeter Author: pkkid File: pkcharts.py License: BSD 3-Clause "New" or "Revised" License | 5 votes |
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 25
Project: dcc Author: amimo File: DisasmViewMode.py License: Apache License 2.0 | 5 votes |
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 26
Project: dcc Author: amimo File: DisasmViewMode.py License: Apache License 2.0 | 5 votes |
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 27
Project: dcc Author: amimo File: SourceViewMode.py License: Apache License 2.0 | 5 votes |
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')
Example 28
Project: dcc Author: amimo File: TextDecorators.py License: Apache License 2.0 | 5 votes |
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 29
Project: dcc Author: amimo File: TextDecorators.py License: Apache License 2.0 | 5 votes |
def highliteWidechar2(self, page): pageStart = self.dataModel.getOffset() pageEnd = pageStart + len(page) touched = False # for s, e in self.Intervals: # touched = True if not touched: # expand Match = [(m.start(), m.end()) for m in re.finditer(r'([a-zA-Z0-9\-\\.%*:/? ]\x00){4,}', page)] for s, e in Match: for i in range(e - s): self.penMap[pageStart + s + i] = QtGui.QPen(QtGui.QColor(255, 255, 0)) # get rid of '\x00' string = page[s:e:2] l = len(string) # copy string that has no zeros page[s:s + l] = string # fill with zeros the remaining space page[s + l: s + 2 * l] = '\x00' * l return page ### todo: other way to highlight widechar, should test and see which one is faster
Example 30
Project: interSubs Author: oltodosel File: interSubs.py License: MIT License | 5 votes |
def draw_text_n_outline(self, painter: QPainter, x, y, outline_width, outline_blur, text): outline_color = QColor(config.outline_color) font = self.font() text_path = QPainterPath() if config.R2L_from_B: text_path.addText(x, y, font, ' ' + r2l(text.strip()) + ' ') else: text_path.addText(x, y, font, text) # draw blur range_width = range(outline_width, outline_width + outline_blur) # ~range_width = range(outline_width + outline_blur, outline_width, -1) for width in range_width: if width == min(range_width): alpha = 200 else: alpha = (max(range_width) - width) / max(range_width) * 200 blur_color = QColor(outline_color.red(), outline_color.green(), outline_color.blue(), alpha) blur_brush = QBrush(blur_color, Qt.SolidPattern) blur_pen = QPen(blur_brush, width, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin) painter.setPen(blur_pen) painter.drawPath(text_path) # draw outline outline_color = QColor(outline_color.red(), outline_color.green(), outline_color.blue(), 255) outline_brush = QBrush(outline_color, Qt.SolidPattern) outline_pen = QPen(outline_brush, outline_width, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin) painter.setPen(outline_pen) painter.drawPath(text_path) # draw text color = self.palette().color(QPalette.Text) painter.setPen(color) painter.drawText(x, y, text)