本文整理匯總了Python中PyQt4.Qt.QTextCharFormat.merge方法的典型用法代碼示例。如果您正苦於以下問題:Python QTextCharFormat.merge方法的具體用法?Python QTextCharFormat.merge怎麽用?Python QTextCharFormat.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.Qt.QTextCharFormat
的用法示例。
在下文中一共展示了QTextCharFormat.merge方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: process_text
# 需要導入模塊: from PyQt4.Qt import QTextCharFormat [as 別名]
# 或者: from PyQt4.Qt.QTextCharFormat import merge [as 別名]
def process_text(state, text, nbsp_format, spell_format, user_data):
ans = []
fmt = None
if state.is_bold or state.is_italic:
fmt = syntax_text_char_format()
if state.is_bold:
fmt.setFontWeight(QFont.Bold)
if state.is_italic:
fmt.setFontItalic(True)
last = 0
for m in nbsp_pat.finditer(text):
ans.extend([(m.start() - last, fmt), (m.end() - m.start(), nbsp_format)])
last = m.end()
if not ans:
ans = [(len(text), fmt)]
elif last < len(text):
ans.append((len(text) - last, fmt))
if do_spell_check and state.tags and user_data.tag_ok_for_spell(state.tags[-1].name):
split_ans = []
locale = state.current_lang or dictionaries.default_locale
sfmt = QTextCharFormat(spell_format)
if fmt is not None:
sfmt.merge(fmt)
tpos = 0
for tlen, fmt in ans:
if fmt is nbsp_format:
split_ans.append((tlen, fmt))
else:
split_ans.extend(check_spelling(text[tpos:tpos+tlen], tlen, fmt, locale, sfmt, store_locale.enabled))
tpos += tlen
ans = split_ans
return ans