本文整理汇总了Python中PyQt5.QtGui.QTextCharFormat.underlineColor方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCharFormat.underlineColor方法的具体用法?Python QTextCharFormat.underlineColor怎么用?Python QTextCharFormat.underlineColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QTextCharFormat
的用法示例。
在下文中一共展示了QTextCharFormat.underlineColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FormatChoice
# 需要导入模块: from PyQt5.QtGui import QTextCharFormat [as 别名]
# 或者: from PyQt5.QtGui.QTextCharFormat import underlineColor [as 别名]
class FormatChoice( ChoiceWidget ) :
# combobox value
def __init__( self, title, explainer ) :
super().__init__( title, explainer )
#Current color and line style are kept in this QTextCharFormat
self.text_format = QTextCharFormat()
# Set up the underline menu
self.ul_menu = QComboBox()
self.ul_menu.addItems( list( UNDERLINES.values() ) )
self.ul_menu.currentIndexChanged[int].connect(self.ul_change)
self.layout().addWidget( self.ul_menu, 0 )
# Set up the color swatch
self.swatch = Swatch( self )
self.layout().addWidget( self.swatch, 0 )
self.swatch.clicked.connect( self.color_change )
# Set up the text sample
self.sample = Sample()
self.layout().addWidget( self.sample )
self.reset() # set widgets to current value
# Combine the underline choice and swatch color into a QTextCharFormat.
def make_format( self, ul_index, qc ) :
qtcf = QTextCharFormat()
qtcf.setUnderlineStyle( ul_index )
if ul_index == QTextCharFormat.NoUnderline :
qtcf.setBackground(QBrush(qc))
else :
qtcf.setUnderlineColor(qc) # underline color gets a QColor
qtcf.clearBackground()
return qtcf
# Parse self.text_format and display it in the swatch and combobox.
def show_format( self ) :
un = self.text_format.underlineStyle()
if un == QTextCharFormat.NoUnderline :
qc = self.text_format.background().color()
else :
qc = self.text_format.underlineColor()
self.swatch.set_color( qc )
self.ul_menu.setCurrentIndex( un )
self.sample.change_format(self.text_format)
# Handle a change in selection of the underline popup
def ul_change( self, index ) :
self.text_format = self.make_format( index, self.swatch.qc )
self.show_format()
# Handle a click on the color swatch. Show the color dialog. After it
# ends, the Preferences dialog will be behind the main window. Why? Who
# knows! But raise it back up to visibility.
def color_change(self) :
qc = colors.choose_color(
_TR('Browse dialog for color preference',
'Choose a color for scanno marking'),
self.swatch.qc )
BIG_FAT_KLUDGE.raise_()
if qc is not None :
self.text_format = self.make_format( self.ul_menu.currentIndex(), qc )
self.show_format()
示例2: QTextCharFormat
# 需要导入模块: from PyQt5.QtGui import QTextCharFormat [as 别名]
# 或者: from PyQt5.QtGui.QTextCharFormat import underlineColor [as 别名]
global SIGCOUNT
SIGCOUNT += 1
colors.notify_me(dingdong)
colors.set_modified_color(QColor('#101010'))
assert SIGCOUNT == 1
assert colors.get_modified_color().name() == '#101010'
qtcf = QTextCharFormat()
qtcf.setUnderlineStyle(QTextCharFormat.WaveUnderline)
qtcf.setUnderlineColor(QColor('#202020'))
colors.set_current_line_format(qtcf)
assert SIGCOUNT == 2
s0cf = QTextCharFormat()
colors.get_current_line_format(s0cf)
assert '#202020' == s0cf.underlineColor().name()
assert s0cf.underlineStyle() == QTextCharFormat.WaveUnderline
s0cf.setUnderlineStyle(QTextCharFormat.NoUnderline)
s0cf.setBackground(QColor('#303030'))
colors.set_find_range_format(s0cf)
assert SIGCOUNT == 3
s0cf = QTextCharFormat()
colors.get_find_range_format(s0cf)
assert '#303030' == s0cf.background().color().name()
assert s0cf.underlineStyle() == QTextCharFormat.NoUnderline
s1cf = QTextCharFormat()
s1cf.setUnderlineStyle(QTextCharFormat.DashDotDotLine)
s1cf.setUnderlineColor(QColor('#303030'))
colors.set_scanno_format(s1cf)