2014-10-11 42 views
2

与此问题类似:Creating and colorizing new constructs on a existing Scintilla lexer但我不想添加,我想修改pyqt4中词法分析器的文本颜色。我发现的关闭是QScintilla: how to create a new lexer or modify an existing one?,其中用户刚刚放弃。修改qscintilla python lexar

基本上我想改用较暗的文本编辑器主题,如MAYA(不相同的关键字/语法高亮,整体色彩主题): enter image description here

我已经能够修改一些开放代码网上设置我的背景和默认的文本:

lexer = getattr(Qsci, 'QsciLexer' + 'Python')() 
lexer.setDefaultFont(font) 
lexer.setDefaultPaper(QColor("#3c3c3c")) 
lexer.setDefaultColor(QColor("#f9f9f9")) 
self.setLexer(lexer) 
self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Helvetica') 

我找不到访问设置颜色蟒蛇词法分析器这样的评论,进口,例外等

+0

在QScintilla上有一个新手入门教程:http://qscintilla.com – 2017-01-26 13:36:18

回答

3

要设置前景色colou r例如评论:

lexer.setColor(QColor('lightblue'), QsciLexerPython.Comment) 

要设置背景色:

lexer.setPaper(QColor('darkblue'), QsciLexerPython.Comment) 

要设置字体:

lexer.setFont(QFont('DejaVu Sans'), QsciLexerPython.Comment) 

对于其他的可能性,咨询QScintilla docs