def __init__(self, text, textType, parent=None): super(TextEditorWidget, self).__init__(parent) font = QtGui.QFont() font.setFamily('Courier') font.setFixedPitch(True) font.setPointSize(10) self.setFont(font) self.setMarginsFont(font) fontmetrics = QtGui.QFontMetrics(font) self.setMarginsFont(font) self.setMarginWidth(0, fontmetrics.width("00000") + 6) self.setMarginLineNumbers(0, True) self.setMarginsBackgroundColor(QtGui.QColor("#cccccc")) self.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.setCaretLineVisible(True) self.setCaretLineBackgroundColor(QtGui.QColor("#ffe4e4")) if textType == CSS: lexer = QsciLexerCSS() elif textType == JSON: lexer = QsciLexerJavaScript() else: lexer = QsciLexerHTML() lexer.setDefaultFont(font) self.setLexer(lexer) self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier') self.setText(text)
def __init__(self, filename='', parent=None): ''' Constructor ''' QWidget.__init__(self, parent) self.filename = filename self.label = 'untitled' self.modified = False self.layout = QVBoxLayout(self) self.editor = QsciScintilla() self.layout.addWidget(self.editor, stretch=1) # Give the editor its content if len(filename) > 0: # Open the file and read in its contents f = open(filename, 'r') contents = f.read() self.editor.setText(contents) f.close() self.label = os.path.basename(filename) # Setup the features of the editor lexer = QsciLexerJavaScript() self.editor.setLexer(lexer) # Connect signals self.editor.textChanged.connect(self.onTextChanged)
dumpLexer( QsciLexerPython() ) dumpLexer( QsciLexerBash() ) dumpLexer( QsciLexerBatch() ) dumpLexer( QsciLexerCMake() ) dumpLexer( QsciLexerCPP() ) dumpLexer( QsciLexerCSharp() ) dumpLexer( QsciLexerCSS() ) dumpLexer( QsciLexerDiff() ) dumpLexer( QsciLexerD() ) dumpLexer( QsciLexerFortran77() ) dumpLexer( QsciLexerFortran() ) dumpLexer( QsciLexerHTML() ) dumpLexer( QsciLexerIDL() ) dumpLexer( QsciLexerJava() ) dumpLexer( QsciLexerJavaScript() ) dumpLexer( QsciLexerLua() ) dumpLexer( QsciLexerMakefile() ) dumpLexer( QsciLexerPascal() ) dumpLexer( QsciLexerPerl() ) dumpLexer( QsciLexerPostScript() ) dumpLexer( QsciLexerPOV() ) dumpLexer( QsciLexerProperties() ) dumpLexer( QsciLexerRuby() ) dumpLexer( QsciLexerSQL() ) dumpLexer( QsciLexerTCL() ) dumpLexer( QsciLexerTeX() ) dumpLexer( QsciLexerVHDL() ) dumpLexer( QsciLexerXML() ) dumpLexer( QsciLexerYAML() )