#NEWLINE# def _get_format_from_style( self , token , style ) : #NEWLINE# #INDENT# ' Returns a QTextCharFormat for token by reading a Pygments style.\n        ' #NEWLINE# result = QtGui . QTextCharFormat ( ) #NEWLINE# try : #NEWLINE# #INDENT# style = style . style_for_token ( token ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# style = style . style_for_token ( Text ) #NEWLINE# #UNINDENT# for ( key , value ) in list ( style . items ( ) ) : #NEWLINE# #INDENT# if value : #NEWLINE# #INDENT# if ( key == 'color' ) : #NEWLINE# #INDENT# result . setForeground ( self . _get_brush ( value ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'bgcolor' ) : #NEWLINE# #INDENT# result . setBackground ( self . _get_brush ( value ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'bold' ) : #NEWLINE# #INDENT# result . setFontWeight ( QtGui . QFont . Bold ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'italic' ) : #NEWLINE# #INDENT# result . setFontItalic ( True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'underline' ) : #NEWLINE# #INDENT# result . setUnderlineStyle ( QtGui . QTextCharFormat . SingleUnderline ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'sans' ) : #NEWLINE# #INDENT# result . setFontStyleHint ( QtGui . QFont . SansSerif ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'roman' ) : #NEWLINE# #INDENT# result . setFontStyleHint ( QtGui . QFont . Times ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key == 'mono' ) : #NEWLINE# #INDENT# result . setFontStyleHint ( QtGui . QFont . TypeWriter ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return result