简体   繁体   English

修改qscintilla python lexar

[英]modify qscintilla python lexar

Similar to this question: Creating and colorizing new constructs on a existing Scintilla lexer but instead of adding, I would like to modify text colors of the lexer in pyqt4. 与此问题类似: 在现有的Scintilla词法分析器上创建新结构并为其着色,但是我不想添加,而是要修改pyqt4中该词法分析器的文本颜色。 The closes I found is QScintilla: how to create a new lexer or modify an existing one? 我发现的结案QScintilla:如何创建新的词法分析器或修改现有的词法分析器? in which the user just gave up. 用户刚刚放弃。

Basically I would like to switch to a darker text editor theme, such as MAYA (Not the same keyword/syntax highlighting, just the overall color theme): 基本上,我想切换到较暗的文本编辑器主题,例如MAYA(不是同一关键字/语法突出显示,只是整个颜色主题): 在此处输入图片说明

I have been able to modify some open code online to set my background and default text: 我已经能够在线修改一些开放代码来设置背景和默认文本:

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')

I cant find access to setting colors for the python lexer like comments, imports, exceptions, etc. 我找不到对python词法分析器设置颜色的访问权限,例如注释,导入,异常等。

To set the foreground colour for eg comments: 设置例如评论的前景色:

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

To set the background colour: 设置背景颜色:

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

To set the font: 设置字体:

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

For other possibilities, consult the QScintilla docs . 有关其他可能性,请参阅QScintilla文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM