2

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. The closes I found is QScintilla: how to create a new lexer or modify an existing one? 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): enter image description here

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.

Community
  • 1
  • 1
user-2147482637
  • 2,115
  • 8
  • 35
  • 56

1 Answers1

3

To set the foreground colour for e.g. 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.

ekhumoro
  • 115,249
  • 20
  • 229
  • 336