本文整理匯總了Python中prompt_toolkit.styles.Style.get_attrs_for_style_str方法的典型用法代碼示例。如果您正苦於以下問題:Python Style.get_attrs_for_style_str方法的具體用法?Python Style.get_attrs_for_style_str怎麽用?Python Style.get_attrs_for_style_str使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類prompt_toolkit.styles.Style
的用法示例。
在下文中一共展示了Style.get_attrs_for_style_str方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_class_combinations_1
# 需要導入模塊: from prompt_toolkit.styles import Style [as 別名]
# 或者: from prompt_toolkit.styles.Style import get_attrs_for_style_str [as 別名]
def test_class_combinations_1():
# In this case, our style has both class 'a' and 'b'.
# Given that the style for 'a b' is defined at the end, that one is used.
style = Style([
('a', '#0000ff'),
('b', '#00ff00'),
('a b', '#ff0000'),
])
expected = Attrs(color='ff0000', bgcolor='', bold=False, underline=False,
italic=False, blink=False, reverse=False, hidden=False)
assert style.get_attrs_for_style_str('class:a class:b') == expected
assert style.get_attrs_for_style_str('class:a,b') == expected
assert style.get_attrs_for_style_str('class:a,b,c') == expected
# Changing the order shouldn't matter.
assert style.get_attrs_for_style_str('class:b class:a') == expected
assert style.get_attrs_for_style_str('class:b,a') == expected
示例2: test_substyles
# 需要導入模塊: from prompt_toolkit.styles import Style [as 別名]
# 或者: from prompt_toolkit.styles.Style import get_attrs_for_style_str [as 別名]
def test_substyles():
style = Style([
('a.b', '#ff0000 bold'),
('a', '#0000ff'),
('b', '#00ff00'),
('b.c', '#0000ff italic'),
])
# Starting with a.*
expected = Attrs(color='0000ff', bgcolor='', bold=False, underline=False,
italic=False, blink=False, reverse=False, hidden=False)
assert style.get_attrs_for_style_str('class:a') == expected
expected = Attrs(color='ff0000', bgcolor='', bold=True, underline=False,
italic=False, blink=False, reverse=False, hidden=False)
assert style.get_attrs_for_style_str('class:a.b') == expected
assert style.get_attrs_for_style_str('class:a.b.c') == expected
# Starting with b.*
expected = Attrs(color='00ff00', bgcolor='', bold=False, underline=False,
italic=False, blink=False, reverse=False, hidden=False)
assert style.get_attrs_for_style_str('class:b') == expected
assert style.get_attrs_for_style_str('class:b.a') == expected
expected = Attrs(color='0000ff', bgcolor='', bold=False, underline=False,
italic=True, blink=False, reverse=False, hidden=False)
assert style.get_attrs_for_style_str('class:b.c') == expected
assert style.get_attrs_for_style_str('class:b.c.d') == expected
示例3: test_class_combinations_2
# 需要導入模塊: from prompt_toolkit.styles import Style [as 別名]
# 或者: from prompt_toolkit.styles.Style import get_attrs_for_style_str [as 別名]
def test_class_combinations_2():
# In this case, our style has both class 'a' and 'b'.
# The style that is defined the latest get priority.
style = Style([
('a b', '#ff0000'),
('b', '#00ff00'),
('a', '#0000ff'),
])
expected = Attrs(color='00ff00', bgcolor='', bold=False, underline=False,
italic=False, blink=False, reverse=False, hidden=False)
assert style.get_attrs_for_style_str('class:a class:b') == expected
assert style.get_attrs_for_style_str('class:a,b') == expected
assert style.get_attrs_for_style_str('class:a,b,c') == expected
# Defining 'a' latest should give priority to 'a'.
expected = Attrs(color='0000ff', bgcolor='', bold=False, underline=False,
italic=False, blink=False, reverse=False, hidden=False)
assert style.get_attrs_for_style_str('class:b class:a') == expected
assert style.get_attrs_for_style_str('class:b,a') == expected