modify qscintilla python lexar
Question: Similar to this question: [Creating and colorizing new constructs on a
existing Scintilla
lexer](http://stackoverflow.com/questions/22021294/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?](http://stackoverflow.com/questions/4097773/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](http://i.stack.imgur.com/5ONqn.png)

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.


Answer: 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](http://pyqt.sourceforge.net/Docs/QScintilla2/index.html).

