modules/pmg_qt/syntax/__init__.py
raw| 1 | from pymol.Qt import QtGui |
| 2 | |
| 3 | |
| 4 | def textformat(color, style=''): |
| 5 | fmt = QtGui.QTextCharFormat() |
| 6 | fmt.setForeground(QtGui.QColor(color)) |
| 7 | |
| 8 | for word in style.split(): |
| 9 | if word == 'bold': |
| 10 | fmt.setFontWeight(QtGui.QFont.Bold) |
| 11 | elif word == 'italic': |
| 12 | fmt.setFontItalic(True) |
| 13 | elif word.startswith('bg:'): |
| 14 | fmt.setBackground(QtGui.QColor(word[3:])) |
| 15 | else: |
| 16 | print('unhandled style:', word) |
| 17 | |
| 18 | return fmt |