コード例 #1
0
ファイル: ui.py プロジェクト: ramesharun/caribou
    def highlightBlock(self, text):
        string_format = QTextCharFormat()
        string_format.setForeground(QColor('#E6DB74'))

        number_format = QTextCharFormat()
        number_format.setForeground(QColor('#AE81FF'))

        get_format = QTextCharFormat()
        get_format.setForeground(QColor('#25A86B'))

        post_format = QTextCharFormat()
        post_format.setForeground(QColor('#FDA60A'))

        if text.startswith('GET '):
            self.setFormat(0, len('GET'), get_format)
        if text.startswith('POST '):
            self.setFormat(0, len('POST'), post_format)

        if len(text) == 0 or text[0] not in '{}[] ':
            return

        current = 0
        for tokentype, value in JsonLexer().get_tokens(text):
            if tokentype in Name or tokentype in String:
                self.setFormat(current, len(value), string_format)
            elif tokentype in Number or tokentype in Keyword:
                self.setFormat(current, len(value), number_format)
            current += len(value)
コード例 #2
0
    def __init__(self, *args):
        super().__init__(*args)

        if FORMATS['keyword'] is None:
            f = QTextCharFormat()
            f.setFont(Conf.code_font)
            f.setForeground(Qt.darkBlue)
            f.setFontWeight(QFont.Bold)
            FORMATS['keyword'] = f
        if FORMATS['quotation'] is None:
            f = QTextCharFormat()
            f.setFont(Conf.code_font)
            f.setForeground(Qt.darkGreen)
            FORMATS['quotation'] = f
        if FORMATS['function'] is None:
            f = QTextCharFormat()
            f.setFont(Conf.code_font)
            f.setForeground(Qt.blue)
            f.setFontWeight(QFont.Bold)
            FORMATS['function'] = f
        if FORMATS['comment'] is None:
            f = QTextCharFormat()
            f.setFont(Conf.code_font)
            f.setForeground(Qt.darkGreen)
            f.setFontWeight(QFont.Bold)
            FORMATS['comment'] = f
コード例 #3
0
    def setup_editor(self):
        variable_format = QTextCharFormat()
        variable_format.setFontWeight(QFont.Bold)
        variable_format.setForeground(Qt.blue)
        self._highlighter.add_mapping("\\b[A-Z_]+\\b", variable_format)

        single_line_comment_format = QTextCharFormat()
        single_line_comment_format.setBackground(QColor("#77ff77"))
        self._highlighter.add_mapping("#[^\n]*", single_line_comment_format)

        quotation_format = QTextCharFormat()
        quotation_format.setBackground(Qt.cyan)
        quotation_format.setForeground(Qt.blue)
        self._highlighter.add_mapping("\".*\"", quotation_format)

        function_format = QTextCharFormat()
        function_format.setFontItalic(True)
        function_format.setForeground(Qt.blue)
        self._highlighter.add_mapping("\\b[a-z0-9_]+\\(.*\\)", function_format)

        font = QFont()
        font.setFamily("Courier")
        font.setFixedPitch(True)
        font.setPointSize(10)

        self._editor = QPlainTextEdit()
        self._editor.setFont(font)
        self._highlighter.setDocument(self._editor.document())
コード例 #4
0
    def __init__(self, parent, color_scheme=None):
        # TODO: Use the color scheme. it's not used right now
        super().__init__(parent, color_scheme=color_scheme)

        self.doc = parent  # type: QCodeDocument

        if FORMATS['keyword'] is None:
            f = QTextCharFormat()
            f.setFont(Conf.code_font)
            f.setForeground(Qt.darkBlue)
            f.setFontWeight(QFont.Bold)
            FORMATS['keyword'] = f
        if FORMATS['quotation'] is None:
            f = QTextCharFormat()
            f.setFont(Conf.code_font)
            f.setForeground(Qt.darkGreen)
            FORMATS['quotation'] = f
        if FORMATS['function'] is None:
            f = QTextCharFormat()
            f.setFont(Conf.code_font)
            f.setForeground(Qt.blue)
            f.setFontWeight(QFont.Bold)
            FORMATS['function'] = f
        if FORMATS['comment'] is None:
            f = QTextCharFormat()
            f.setFont(Conf.code_font)
            f.setForeground(Qt.darkGreen)
            f.setFontWeight(QFont.Bold)
            FORMATS['comment'] = f
コード例 #5
0
 def __init__(self, document):
     super().__init__(document)
     self.error_line = None
     self.command_format = QTextCharFormat()
     self.command_format.setForeground(QtCore.Qt.darkMagenta)
     self.error_format = QTextCharFormat()
     self.error_format.setUnderlineColor(QtCore.Qt.darkRed)
     self.error_format.setUnderlineStyle(
         QtGui.QTextCharFormat.SpellCheckUnderline)
     self.error_format.setBackground(QtCore.Qt.red)
コード例 #6
0
 def __init__(self, parent):
     super(Highlighter, self).__init__(parent)
     self.infoFormat = QTextCharFormat()
     self.infoFormat.setForeground(Qt.white)
     self.infoFormat.setBackground(Qt.green)
     self.warningFormat = QTextCharFormat()
     self.warningFormat.setForeground(Qt.black)
     # self.warningFormat.setBackground(Qt.yellow)
     self.warningFormat.setBackground(QColor(MACOSYELLOW[0], MACOSYELLOW[1], MACOSYELLOW[2]))
     self.errorFormat = QTextCharFormat()
     self.errorFormat.setForeground(Qt.white)
     self.errorFormat.setBackground(QColor(MACOSRED[0], MACOSRED[1], MACOSRED[2]))
コード例 #7
0
    def __init__(self, parent=None):
        super(Highlighter, self).__init__(parent)

        keywordFormat = QTextCharFormat()
        keywordFormat.setForeground(QColor("#00CCFF"))
        keywordFormat.setFontCapitalization(QFont.AllUppercase)

        keywordPatterns = ["\\bSELECT\\b", "\\bFROM\\b", "\\bWHERE\\b",
                "\\bselect\\b", "\\bfrom\\b", "\\bwhere\\b", 
                "\\bTABLE\\b", "\\btable\\b", "\\bON\\b", "\\bon\\b",
                "\\bORDER\\b", "\\border\\b", "\\bBY\\b", "\\bby\\b",
                "\\bLIMIT\\b", "\\blimit\\b", "\\bBETWEEN\\b",
                "\\bbetween\\b", "\\bLIKE\\b", "\\blike\\b", "\\bTO\\b", "\\bto\\b",
                "\\bINNER\\b", "\\inner\\b", "\\bJOIN\\b", "\\bjoin\\b", 
                "\\bAND\\b", "\\and\\b", "\\bOR\\b", "\\bor\\b", 
                ]

        self.highlightingRules = [(QRegExp(pattern), keywordFormat)
                for pattern in keywordPatterns]
        
        keyword2Format = QTextCharFormat()
        keyword2Format.setForeground(QColor("#DE0000"))
        keyword2Format.setFontCapitalization(QFont.AllUppercase)

        keyword2Patterns = ["\\bCREATE\\b", "\\bcreate\\b",
                 "\\bINSERT\\b", "\\binsert\\b", "\\bUPDATE\\b", "\\bupdate\\b",
                "\\bDELETE\\b","\\bdelete\\b", "\\bREPLACE\\b", "\\breplace\\b",
                "\\bDROP\\b", "\\bdrop\\b", "\\bRENAME\\b", "\\rename\\b",
                "\\bALTER\\b", "\\alter\\b",
                "\\bSET\\b", "\\bset\\b"
                ]


        self.highlightingRules.extend([(QRegExp(pattern), keyword2Format)
                for pattern in keyword2Patterns])
        
        table_name_format = QTextCharFormat()
        table_name_format.setForeground(QColor("#00FF7F"))
        table_name_format.setFontWeight(QFont.Bold)
        table_name_patterns = ["\\b{tn}\\b".format(tn=table.name) for table in Tables]
        ex_tables = ["\\b{tn}\\b".format(tn=table.name) for table in ExclusiveDbTables]
        table_name_patterns.extend(ex_tables)
        self.highlightingRules.extend([(QRegExp(pattern), table_name_format) for pattern in table_name_patterns])

        field_name_format = QTextCharFormat()
        field_name_format.setForeground(QColor("#00FF7F"))
        field_names = []
        for table in Tables:
            field_names.extend(getFieldNames(table.name))
        for table in ExclusiveDbTables:
            field_names.extend(getAllFieldNames(table.name, False))
        field_name_patterns = ["\\b{fn}\\b".format(fn=field_name) for field_name in field_names]
        self.highlightingRules.extend([(QRegExp(pattern), field_name_format) for pattern in field_name_patterns])
コード例 #8
0
ファイル: MainConsole.py プロジェクト: jbulow/Ryven
    def __init__(
            self,
            context=locals(),       # context for interpreter
            history: int = 100,     # max lines in history buffer
            blockcount: int = 5000  # max lines in output buffer
    ):

        super(MainConsole, self).__init__()

        # CREATE UI

        self.content_layout = QGridLayout(self)
        self.content_layout.setContentsMargins(0, 0, 0, 0)
        self.content_layout.setSpacing(0)

        # reset scope button
        self.reset_scope_button = QPushButton('reset console scope')
        self.reset_scope_button.clicked.connect(self.reset_scope_clicked)
        self.content_layout.addWidget(self.reset_scope_button, 0, 0, 1, 2)
        self.reset_scope_button.hide()

        # display for output
        self.out_display = ConsoleDisplay(blockcount, self)
        self.content_layout.addWidget(self.out_display, 1, 0, 1, 2)

        # colors to differentiate input, output and stderr
        self.inpfmt = self.out_display.currentCharFormat()
        self.inpfmt.setForeground(QBrush(QColor('white')))
        self.outfmt = QTextCharFormat(self.inpfmt)
        self.outfmt.setForeground(QBrush(QColor('#A9D5EF')))
        self.errfmt = QTextCharFormat(self.inpfmt)
        self.errfmt.setForeground(QBrush(QColor('#B55730')))

        # display input prompt left besides input edit
        self.prompt_label = QLabel('> ', self)
        self.prompt_label.setFixedWidth(15)
        self.content_layout.addWidget(self.prompt_label, 2, 0)

        # command line
        self.inpedit = LineEdit(max_history=history)
        self.inpedit.returned.connect(self.push)
        self.content_layout.addWidget(self.inpedit, 2, 1)


        self.interp = None
        self.reset_interpreter()

        self.buffer = []
        self.num_added_object_contexts = 0
コード例 #9
0
    def __init__(self):
        super().__init__('default')

        # override existing formats
        function_format = QTextCharFormat()
        function_format.setForeground(self._get_brush("0000ff"))
        self.formats['function'] = function_format
コード例 #10
0
ファイル: ui.py プロジェクト: ramesharun/caribou
    def highlightBlock(self, text):
        string_format = QTextCharFormat()
        string_format.setForeground(QColor('#E6DB74'))

        number_format = QTextCharFormat()
        number_format.setForeground(QColor('#AE81FF'))
        if len(text) == 0:
            return

        current = 0
        for tokentype, value in JsonLexer().get_tokens(text):
            if tokentype in Name or tokentype in String:
                self.setFormat(current, len(value), string_format)
            elif tokentype in Number or tokentype in Keyword:
                self.setFormat(current, len(value), number_format)
            current += len(value)
コード例 #11
0
    def highlight(self, addr):
        fmt = QTextCharFormat()
        fmt.setBackground(Qt.cyan)
        fmt.setFont('Courier New')

        cur = self.box.textCursor()

        text = self.box.toPlainText()
        count = 0
        for line in text.split('\n'):
            if len(line) > 0:
                line_addr = line.split()[0]
                n = (len(line_addr[2:-1]) * 4)
                mask = (2**n) - 1
                if int(line_addr[:-1], 16) == (addr & mask):
                    break
                count += 1
        block = self.box.document().findBlockByLineNumber(count)
        cur.setPosition(block.position())

        cur.select(QTextCursor.LineUnderCursor)

        cur.setCharFormat(fmt)

        self.box.setTextCursor(cur)
コード例 #12
0
 def fmt() -> QTextCharFormat:
     """
     Get text char formatting for this object
     """
     fmt = QTextCharFormat()
     fmt.setForeground(Conf.disasm_view_node_mnemonic_color)
     return fmt
コード例 #13
0
    def clear_highlight(self):
        fmt = QTextCharFormat()
        fmt.setFont('Courier New')

        cur = self.box.textCursor()
        cur.select(QTextCursor.Document)
        cur.setCharFormat(fmt)
        self.box.setTextCursor(cur)
コード例 #14
0
def text_format(color, style=''):
    f = QTextCharFormat()
    f.setForeground(color)
    if 'bold' in style:
        f.setFontWeight(QFont.Bold)
    if 'italic' in style:
        f.setFontItalic(True)
    return f
コード例 #15
0
ファイル: gameui.py プロジェクト: Matrixchung/EDAutopilot
 def onReceiveLog(self, data: LogMsg):
     format = QTextCharFormat()
     format.setForeground(QBrush(QColor(data.color)))
     self.mainUI.logText.setCurrentCharFormat(format)
     self.mainUI.logText.appendPlainText(data.text)
     format.setForeground(QBrush(
         QColor('black')))  # restore to default color
     self.mainUI.logText.setCurrentCharFormat(format)
コード例 #16
0
    def foo(self):
        fmt = QTextCharFormat()
        fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType)

        cursor = self.textEdit.textCursor()
        cursor.insertText(py3k.unichr(0xfffc), fmt)
        self.textEdit.setTextCursor(cursor)
        self.textEdit.close()
コード例 #17
0
ファイル: panel2.py プロジェクト: Zamtos/Panel2
    def newLetter(self):
        self.textEdit.clear()

        cursor = self.textEdit.textCursor()
        cursor.movePosition(QTextCursor.Start)
        topFrame = cursor.currentFrame()
        topFrameFormat = topFrame.frameFormat()
        topFrameFormat.setPadding(16)
        topFrame.setFrameFormat(topFrameFormat)
        #        timer = QTimer(self)
        #        timer.timeout.connect(self.showTime)
        #        timer.start(1000)
        textFormat = QTextCharFormat()
        boldFormat = QTextCharFormat()
        boldFormat.setFontWeight(QFont.Bold)
        italicFormat = QTextCharFormat()
        italicFormat.setFontItalic(True)

        tableFormat = QTextTableFormat()
        tableFormat.setBorder(1)
        tableFormat.setCellPadding(16)
        tableFormat.setAlignment(Qt.AlignRight)
        cursor.insertTable(1, 1, tableFormat)
        cursor.insertText("Tomasz Dróżdż", boldFormat)
        cursor.insertBlock()
        cursor.insertText("Politechnika Wrocławska", textFormat)
        cursor.insertBlock()
        cursor.insertText("Automatyka i Robotyka")
        cursor.insertBlock()
        cursor.insertText("SOLAR PANEL Program")
        cursor.setPosition(topFrame.lastPosition())
        cursor.insertText(
            QDate.currentDate().toString("Dziś jest: d MMMM yyyy:"),
            textFormat)
        cursor.insertText(QTime.currentTime().toString("  hh:mm:ss"),
                          textFormat)
        #        cursor.insertText(QTimer.timer("  hh:mm:ss", 1000), textFormat)
        cursor.insertBlock()
        cursor.insertBlock()
        cursor.insertText("Wrocław: ", textFormat)
        cursor.insertText("17.03 deg; 51.10 deg", textFormat)
        cursor.insertText(",", textFormat)
        for i in range(3):
            cursor.insertBlock()
        cursor.insertText("Text", textFormat)
コード例 #18
0
ファイル: sn_toolbars.py プロジェクト: JasonReek/SmartNotes
    def changeFontSize(self):
        font_format = QTextCharFormat()
        font_size = int(self._font_sizes.currentText())
        font_format.setFontPointSize(font_size)
        cursor = self._parent.activeNotepad().textCursor()
        cursor.mergeBlockCharFormat(font_format)

        self._parent.activeNotepad().setTextCursor(cursor)
        self._parent.activeNotepad().setFontPointSize(font_size)
コード例 #19
0
 def highlightBlock(self, text):  # Function for formatting
     if not self.dict:  # the text inside this text
         return  # edit field, sets the format
     formats = QTextCharFormat()  # of the text that not match
     formats.setUnderlineColor(Qt.red)  # to the dicts. Red underline.
     formats.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)
     for w in re.finditer(self.words, text):
         if not self.dict.check(w.group()):
             self.setFormat(w.start(), w.end() - w.start(), formats)
コード例 #20
0
    def newLetter(self):
        self.textEdit.clear()

        cursor = self.textEdit.textCursor()
        cursor.movePosition(QTextCursor.Start)
        topFrame = cursor.currentFrame()
        topFrameFormat = topFrame.frameFormat()
        topFrameFormat.setPadding(16)
        topFrame.setFrameFormat(topFrameFormat)

        textFormat = QTextCharFormat()
        boldFormat = QTextCharFormat()
        boldFormat.setFontWeight(QFont.Bold)
        italicFormat = QTextCharFormat()
        italicFormat.setFontItalic(True)

        tableFormat = QTextTableFormat()
        tableFormat.setBorder(1)
        tableFormat.setCellPadding(16)
        tableFormat.setAlignment(Qt.AlignRight)
        cursor.insertTable(1, 1, tableFormat)
        cursor.insertText("The Firm", boldFormat)
        cursor.insertBlock()
        cursor.insertText("321 City Street", textFormat)
        cursor.insertBlock()
        cursor.insertText("Industry Park")
        cursor.insertBlock()
        cursor.insertText("Some Country")
        cursor.setPosition(topFrame.lastPosition())
        cursor.insertText(QDate.currentDate().toString("d MMMM yyyy"),
                          textFormat)
        cursor.insertBlock()
        cursor.insertBlock()
        cursor.insertText("Dear ", textFormat)
        cursor.insertText("NAME", italicFormat)
        cursor.insertText(",", textFormat)
        for i in range(3):
            cursor.insertBlock()
        cursor.insertText("Yours sincerely,", textFormat)
        for i in range(3):
            cursor.insertBlock()
        cursor.insertText("The Boss", textFormat)
        cursor.insertBlock()
        cursor.insertText("ADDRESS", italicFormat)
コード例 #21
0
def reset_formats():
    f = QTextCharFormat()
    f.setForeground(QBrush(Conf.pseudocode_keyword_color))
    f.setFontWeight(QFont.Bold)
    FORMATS['keyword'] = f

    f = QTextCharFormat()
    f.setForeground(QBrush(Conf.pseudocode_quotation_color))
    FORMATS['quotation'] = f

    f = QTextCharFormat()
    f.setForeground(QBrush(Conf.pseudocode_function_color))
    f.setFontWeight(QFont.Bold)
    FORMATS['function'] = f

    f = QTextCharFormat()
    f.setForeground(QBrush(Conf.pseudocode_comment_color))
    f.setFontWeight(QFont.Bold)
    FORMATS['comment'] = f
コード例 #22
0
 def _formatiraj(self, r, g, b, stil=''):
     #_boja = QColor()
     _boja = QColor.fromRgb(r, g, b, 255)
     _format = QTextCharFormat()
     _format.setForeground(_boja)
     if 'bold' in stil:
         _format.setFontWeight(QFont.Bold)
     if 'italic' in stil:
         _format.setFontItalic(True)
     return _format
コード例 #23
0
    def generatePlotFormat(plot, width, height):
        picture = QPicture()
        qcpPainter = QCPPainter()
        qcpPainter.begin(picture)
        plot.toPainter(qcpPainter, width, height)
        qcpPainter.end()

        result = QTextCharFormat()
        result.setObjectType(MainWindow.QCPTextFormat)
        result.setProperty(MainWindow.QCPData, picture)
        return result
コード例 #24
0
ファイル: python.py プロジェクト: Sugz/SugzEditor-PySide2
    def getTextCharFormat(self, color, style=None):
        """Return a QTextCharFormat with the given attributes."""
        textCharFormat = QTextCharFormat()
        textCharFormat.setForeground(color)
        if style is not None:
            if 'bold' in style:
                textCharFormat.setFontWeight(QFont.Bold)
            if 'italic' in style:
                textCharFormat.setFontItalic(True)

        return textCharFormat
コード例 #25
0
def format(color, style=''):
    """Return a QTextCharFormat with the given attributes."""
    _color = eval('getThemeColor(ThemeColor.%s)' % color)

    _format = QTextCharFormat()
    _format.setForeground(_color)
    if 'bold' in style:
        _format.setFontWeight(QFont.Bold)
    if 'italic' in style:
        _format.setFontItalic(True)

    return _format
コード例 #26
0
    def highlight(self, addr, group):
        self.clear_highlight()
        
        # adding new highlights
        fmt = QTextCharFormat()
        fmt.setBackground(Qt.cyan)
        fmt.setFont('Courier New')

        addr_block = self.addresses.document().findBlockByLineNumber((addr - self.baseAddress) // 16) # gets linenos 
        mem_block = self.mem_display.document().findBlockByLineNumber((addr - self.baseAddress) // 16)
        chr_block = self.chr_display.document().findBlockByLineNumber((addr - self.baseAddress) // 16)

        addr_cur = self.addresses.textCursor()  # getting cursors
        mem_cur = self.mem_display.textCursor()
        chr_cur = self.chr_display.textCursor()


        char_offset = 0
        mem_offset = 0
        self.endian_sem.acquire()
        if self.endian == Endian.big:
            mem_offset = ((addr % 16) // group) * (2 * group + 1)
            char_offset = (addr % 16) * 3
        elif self.endian == Endian.little:
            mem_offset = (((16 / group) - 1 )* (2 * group + 1)) - ((addr % 16) // group) * (2 * group + 1)
            char_offset = (15*3) - ((addr % 16) * 3)
        self.endian_sem.release()
        addr_cur.setPosition(addr_block.position()) # getting positions
        mem_cur.setPosition(mem_block.position() + mem_offset) # gives character offset within 16 byte line
        chr_cur.setPosition(chr_block.position() + char_offset) # sets position of char

        chr_text = self.chr_display.toPlainText()
        if chr_text[chr_cur.position()] == '\\' and chr_cur.position() + 1 < len(chr_text) and chr_text[chr_cur.position() + 1] in ['0', 'n', 't']:
            chr_cur.setPosition(chr_cur.position() + 2, mode=QTextCursor.KeepAnchor) 
        else:
            chr_cur.setPosition(chr_cur.position() + 1, mode=QTextCursor.KeepAnchor) 


        addr_cur.select(QTextCursor.LineUnderCursor)    # selects whole line
        mem_cur.select(QTextCursor.WordUnderCursor)     # selects just one word

        addr_cur.setCharFormat(fmt) # setting format
        mem_cur.setCharFormat(fmt)
        chr_cur.setCharFormat(fmt)

        self.addresses.setTextCursor(addr_cur)
        self.mem_display.setTextCursor(mem_cur)
        self.chr_display.setTextCursor(chr_cur)
        
        self.highlight_sem.acquire()
        self.is_highlighted = True
        self.highlight_addr = addr
        self.highlight_sem.release()
コード例 #27
0
    def highlightBlock(self, text):
        myClassFormat = QTextCharFormat()
        myClassFormat.setFontWeight(QFont.Bold)

        expression = QRegularExpression(self.pattern)
        i = expression.globalMatch(text)

        while i.hasNext():
            match = i.next()
            myClassFormat.setForeground(
                self.tagColorMap[match.capturedTexts()[0]])
            self.setFormat(match.capturedStart(), match.capturedLength(),
                           myClassFormat)
コード例 #28
0
    def newLetter(self):

        self.textEdit.clear()
        self.text2 = QLabel("<b>Domyślne Współrzędne:</b><br/>"
                            "Szerokość: 51° 06' 00''<br/>"
                            "Długość: 17° 01' 00''<br/>"
                            "(Współrzędne geograficzne Wrocławia)")

        cursor = self.textEdit.textCursor()
        cursor.movePosition(QTextCursor.Start)
        topFrame = cursor.currentFrame()
        topFrameFormat = topFrame.frameFormat()
        topFrameFormat.setPadding(16)
        topFrame.setFrameFormat(topFrameFormat)
        textFormat = QTextCharFormat()
        boldFormat = QTextCharFormat()
        boldFormat.setFontWeight(QFont.Bold)
        italicFormat = QTextCharFormat()
        italicFormat.setFontItalic(True)

        tableFormat = QTextTableFormat()
        tableFormat.setBorder(1)
        tableFormat.setCellPadding(16)
        tableFormat.setAlignment(Qt.AlignRight)
        cursor.insertTable(1, 1, tableFormat)
        cursor.insertText("Domyślne Współrzędne: ", boldFormat)
        self.text2.setText(self.nameEdit.text())
        cursor.insertText
        #self.text1.setText(self.nameEdit.text())
        cursor.insertBlock()
        cursor.insertBlock()
        cursor.insertText("Szerokość: 51° 06' 00''", textFormat)
        cursor.insertBlock()
        cursor.insertBlock()
        cursor.insertText("Długość: 17° 01' 00''")
        cursor.insertBlock()
        cursor.insertBlock()
        cursor.insertText("(Współrzędne geograficzne Wrocławia)")
        cursor.setPosition(topFrame.lastPosition())
コード例 #29
0
def txformat(color, style=''):
    """Return a QTextCharFormat with the given attributes.
    """
    _color = QColor()
    _color.setNamedColor(color)

    _format = QTextCharFormat()
    _format.setForeground(_color)
    if 'bold' in style:
        _format.setFontWeight(QFont.Bold)
    if 'italic' in style:
        _format.setFontItalic(True)

    return _format
コード例 #30
0
ファイル: sub.py プロジェクト: kiwitreekor/namuplant
 def __init__(self):
     super().__init__()
     self.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
     self.setColumnCount(4)
     self.horizontalHeader().setVisible(False)
     self.verticalHeader().setVisible(False)
     self.horizontalHeader().setStretchLastSection(True)
     self.horizontalHeader().setMinimumSectionSize(10)
     self.horizontalHeader().setSectionResizeMode(
         QHeaderView.ResizeToContents)
     self.verticalHeader().setSectionResizeMode(
         QHeaderView.ResizeToContents)
     # 컬러 세트
     color_sub = QColor()
     color_sub.setNamedColor('#ffaaaa')
     color_add = QColor()
     color_add.setNamedColor('#aaffaa')
     self.fmt_sub = QTextCharFormat()
     self.fmt_sub.setBackground(color_sub)
     self.fmt_add = QTextCharFormat()
     self.fmt_add.setBackground(color_add)
     self.a = ''
     self.b = ''