Пример #1
0
    def __init__(self, parent=None):
        super().__init__(parent)

        # Set the default font
        font = QFont()
        font.setFamily('Courier')
        font.setFixedPitch(True)
        font.setPointSize(10)
        self.setFont(font)
        self.setMarginsFont(font)

        # Margin 0 is used for line numbers
        fontmetrics = QFontMetrics(font)
        self.setMarginsFont(font)
        self.setMarginWidth(0, fontmetrics.width("000") + 6)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QColor("#E3F0FF"))

        # Brace matching: enable for a brace immediately before or after
        # the current position
        #
        self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

        # Current line visible with special background color
        self.setCaretLineVisible(True)
        self.setCaretLineBackgroundColor(QColor("#A5ABBD"))

        # Set Python lexer
        # Set style for Python comments (style number 1) to a fixed-width
        # courier.
        #
        lexer = Qsci.QsciLexerJSON(self)
        lexer.setDefaultFont(font)
        self.setLexer(lexer)
        # self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

        # Don't want to see the horizontal scrollbar at all
        # Use raw message to Scintilla here (all messages are documented
        # here: http://www.scintilla.org/ScintillaDoc.html)
        self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

        # not too small
        self.setMinimumSize(300, 100)
Пример #2
0
    def setEditorType(self, tpe: EditorType, inner=False):
        self.editType = tpe
        if not inner:
            self.editorTypeBox.setCurrentIndex(tpe.value)

        if tpe == EditorType.JSON:
            self.editor.changeLexer(Qsci.QsciLexerJSON(self.editor), 'JSON')
        elif tpe == EditorType.XML:
            self.editor.changeLexer(Qsci.QsciLexerXML(self.editor), 'XML')
        elif tpe == EditorType.HTML:
            self.editor.changeLexer(Qsci.QsciLexerHTML(self.editor), 'HTML')
        elif tpe == EditorType.Javascript:
            self.editor.changeLexer(Qsci.QsciLexerJavaScript(self.editor),
                                    'Javascript')
        else:
            self.editor.changeLexer(Qsci.QsciLexerMarkdown(self.editor),
                                    'Text<')

        self.editorTypeChanged.emit(tpe.value)
Пример #3
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.setLexer(Qsci.QsciLexerJSON(self))
     self.setText(JSON)