#NEWLINE# def __init__( self , parent = None ) : #NEWLINE# #INDENT# super ( Highlighter , self ) . __init__ ( parent ) #NEWLINE# keywordFormat = QtGui . QTextCharFormat ( ) #NEWLINE# keywordFormat . setForeground ( QtCore . Qt . blue ) #NEWLINE# keywordFormat . setFontWeight ( QtGui . QFont . Bold ) #NEWLINE# keywordPatterns = [ '\\b{}\\b' . format ( k ) for k in keyword . kwlist ] #NEWLINE# self . highlightingRules = [ ( QtCore . QRegExp ( pattern ) , keywordFormat ) for pattern in keywordPatterns ] #NEWLINE# classFormat = QtGui . QTextCharFormat ( ) #NEWLINE# classFormat . setFontWeight ( QtGui . QFont . Bold ) #NEWLINE# self . highlightingRules . append ( ( QtCore . QRegExp ( '\\bQ[A-Za-z]+\\b' ) , classFormat ) ) #NEWLINE# singleLineCommentFormat = QtGui . QTextCharFormat ( ) #NEWLINE# singleLineCommentFormat . setForeground ( QtCore . Qt . gray ) #NEWLINE# self . highlightingRules . append ( ( QtCore . QRegExp ( '#[^\n]*' ) , pattern ) ) #NEWLINE# quotationFormat = QtGui . QTextCharFormat ( ) #NEWLINE# quotationFormat . setForeground ( QtCore . Qt . darkGreen ) #NEWLINE# self . highlightingRules . append ( ( QtCore . QRegExp ( '".*"' ) , quotationFormat ) ) #NEWLINE# self . highlightingRules . append ( ( QtCore . QRegExp ( "'.*'" ) , quotationFormat ) )