本文整理汇总了Python中PyQt5.Qt.QTextCharFormat.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCharFormat.setBackground方法的具体用法?Python QTextCharFormat.setBackground怎么用?Python QTextCharFormat.setBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTextCharFormat
的用法示例。
在下文中一共展示了QTextCharFormat.setBackground方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.Qt import QTextCharFormat [as 别名]
# 或者: from PyQt5.Qt.QTextCharFormat import setBackground [as 别名]
def __init__(self, right=False, parent=None, show_open_in_editor=False):
PlainTextEdit.__init__(self, parent)
self.setFrameStyle(0)
self.show_open_in_editor = show_open_in_editor
self.side_margin = 0
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.show_context_menu)
self.setFocusPolicy(Qt.NoFocus)
self.right = right
self.setReadOnly(True)
self.setLineWrapMode(self.WidgetWidth)
font = self.font()
ff = tprefs['editor_font_family']
if ff is None:
ff = default_font_family()
font.setFamily(ff)
font.setPointSize(tprefs['editor_font_size'])
self.setFont(font)
self.calculate_metrics()
self.setTabStopWidth(tprefs['editor_tab_stop_width'] * self.space_width)
font = self.heading_font = QFont(self.font())
font.setPointSize(int(tprefs['editor_font_size'] * 1.5))
font.setBold(True)
theme = get_theme(tprefs['editor_theme'])
pal = self.palette()
pal.setColor(pal.Base, theme_color(theme, 'Normal', 'bg'))
pal.setColor(pal.AlternateBase, theme_color(theme, 'CursorLine', 'bg'))
pal.setColor(pal.Text, theme_color(theme, 'Normal', 'fg'))
pal.setColor(pal.Highlight, theme_color(theme, 'Visual', 'bg'))
pal.setColor(pal.HighlightedText, theme_color(theme, 'Visual', 'fg'))
self.setPalette(pal)
self.viewport().setCursor(Qt.ArrowCursor)
self.line_number_area = LineNumbers(self)
self.blockCountChanged[int].connect(self.update_line_number_area_width)
self.updateRequest.connect(self.update_line_number_area)
self.line_number_palette = pal = QPalette()
pal.setColor(pal.Base, theme_color(theme, 'LineNr', 'bg'))
pal.setColor(pal.Text, theme_color(theme, 'LineNr', 'fg'))
pal.setColor(pal.BrightText, theme_color(theme, 'LineNrC', 'fg'))
self.line_number_map = LineNumberMap()
self.search_header_pos = 0
self.changes, self.headers, self.images = [], [], OrderedDict()
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff), self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.diff_backgrounds = {
'replace' : theme_color(theme, 'DiffReplace', 'bg'),
'insert' : theme_color(theme, 'DiffInsert', 'bg'),
'delete' : theme_color(theme, 'DiffDelete', 'bg'),
'replacereplace': theme_color(theme, 'DiffReplaceReplace', 'bg'),
'boundary': QBrush(theme_color(theme, 'Normal', 'fg'), Qt.Dense7Pattern),
}
self.diff_foregrounds = {
'replace' : theme_color(theme, 'DiffReplace', 'fg'),
'insert' : theme_color(theme, 'DiffInsert', 'fg'),
'delete' : theme_color(theme, 'DiffDelete', 'fg'),
'boundary': QColor(0, 0, 0, 0),
}
for x in ('replacereplace', 'insert', 'delete'):
f = QTextCharFormat()
f.setBackground(self.diff_backgrounds[x])
setattr(self, '%s_format' % x, f)