本文整理汇总了Python中urwid.Text方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.Text方法的具体用法?Python urwid.Text怎么用?Python urwid.Text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid
的用法示例。
在下文中一共展示了urwid.Text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_status_bar
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def get_status_bar(self):
cur = -1
total = 0
if len(self.body.positions()) > 0:
cur = self.focus_position
total = len(self.body.positions())
status_title = \
urwid.AttrMap(urwid.Text('Help',
wrap='clip'),
'status_bar')
status_index = \
('pack', urwid.AttrMap(urwid.Text(' ' +
str(cur + 1) +
'/' +
str(total)),
'status_bar'))
return \
urwid.AttrMap(urwid.Columns([ status_title, status_index ]),
'status_bar')
示例2: create_color_help_lines
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def create_color_help_lines(self):
lines = [ urwid.AttrMap(urwid.Text(''),
'help_header',
'help_focus') ]
lines.append(urwid.AttrMap(urwid.Text(' Colors'),
'help_header',
'help_focus'))
fmap = {}
for c in self.config.colors:
fmap[re.search('^(.*)(_fg|_bg)$', c).group(1)] = 'help_focus'
for c in self.config.colors:
lines.append(
urwid.AttrMap(urwid.AttrMap(
urwid.Text(
[
('help_descr', ('{:>' + str(self.descr_width) + '} ').format(self.config.get_color_descr(c))),
('help_config', ('{:>' + str(self.config_width) + '} ').format('clr_' + c)),
(re.search('^(.*)(_fg|_bg)$', c).group(1), "'" + self.config.get_color(c) + "'")
]
),
attr_map = None,
focus_map = fmap
), 'default', 'help_focus'))
return lines
示例3: make_table_with_categories
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def make_table_with_categories(contents: PopUpViewTableContent,
column_widths: List[int],
dividechars: int=2) -> List[Any]:
"""
Returns a list of widgets to render a table with different categories.
"""
widgets = [] # type: List[Any]
for category, content in contents:
if category:
if len(widgets) > 0: # Separate categories with newline.
widgets.append(urwid.Text(''))
widgets.append(urwid.Text(('popup_category', category)))
for index, row in enumerate(content):
label, data = row
strip = urwid.Columns([
urwid.Text(label),
(column_widths[1], urwid.Text(data))
], dividechars=dividechars)
widgets.append(urwid.AttrWrap(
strip, None if index % 2 else 'popup_contrast')
)
return widgets
示例4: stream_header
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def stream_header(self) -> Any:
stream_topic_separator = '▶'
color = self.model.stream_dict[self.stream_id]['color']
bar_color = 's' + color
stream_title_markup = ('bar', [
(bar_color, '{} {} '.format(self.stream_name,
stream_topic_separator)),
('title', ' {}'.format(self.topic_name))
])
stream_title = urwid.Text(stream_title_markup)
header = urwid.Columns([
('pack', stream_title),
(1, urwid.Text((color, ' '))),
urwid.AttrWrap(urwid.Divider('━'), color),
])
header.markup = stream_title_markup
return header
示例5: main_view
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def main_view(self) -> Any:
search_text = ("Search ["
+ ", ".join(keys_for_command("SEARCH_MESSAGES"))
+ "]: ")
self.text_box = ReadlineEdit(search_text + " ")
# Add some text so that when packing,
# urwid doesn't hide the widget.
self.conversation_focus = urwid.Text(" ")
self.search_bar = urwid.Columns([
('pack', self.conversation_focus),
('pack', urwid.Text(" ")),
self.text_box,
])
self.msg_narrow = urwid.Text("DONT HIDE")
self.recipient_bar = urwid.LineBox(
self.msg_narrow, title="Current message recipients",
tline='─', lline='', trcorner='─', tlcorner='─',
blcorner='─', rline='', bline='─', brcorner='─')
return [self.search_bar, self.recipient_bar]
示例6: test_main_view_generates_stream_header
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def test_main_view_generates_stream_header(self, mocker, message,
to_vary_in_last_message):
self.model.stream_dict = {
5: {
'color': '#bd6',
},
}
last_message = dict(message, **to_vary_in_last_message)
msg_box = MessageBox(message, self.model, last_message)
view_components = msg_box.main_view()
assert len(view_components) == 3
assert isinstance(view_components[0], Columns)
assert isinstance(view_components[0][0], Text)
assert isinstance(view_components[0][1], Text)
assert isinstance(view_components[0][2], Divider)
示例7: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def __init__(self, exit_code):
self.exit_code = exit_code
self.message = Text('Do you want to quit?', align='center')
super().__init__(LineBox(Pile([
Padding.line_break(""),
self.message,
Padding.line_break(""),
Columns([
Text(""),
SubmitButton('Yes', lambda _: self.confirm()),
Text(""),
SubmitButton('No', lambda _: self.cancel()),
Text(""),
]),
Padding.line_break(""),
])))
if events.Error.is_set():
self.confirm()
示例8: _build_footer
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def _build_footer(self):
no = menu_btn(on_press=self.cancel,
label="\n NO\n")
yes = menu_btn(on_press=self.submit,
label="\n YES\n")
self.buttons = Columns([
('fixed', 2, Text("")),
('fixed', 11, Color.menu_button(
no,
focus_map='button_primary focus')),
Text(""),
('fixed', 11, Color.menu_button(
yes,
focus_map='button_primary focus')),
('fixed', 2, Text(""))
])
self.footer = Pile([
Padding.line_break(""),
self.buttons
])
return Color.frame_footer(self.footer)
示例9: _build_widget
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def _build_widget(self):
applications = self.app.juju.client.applications
total_items = [Instruction("Deployment Information:"), HR()]
tbl = Pile([
Columns([('fixed', 15, Text("Name")),
Text(self.model['name'])]),
Columns([('fixed', 15, Text("Cloud")),
Text(self.model['cloud'])]),
Columns([('fixed', 15, Text("Status")),
Text(self.model['status']['current'])]),
Columns([('fixed', 15, Text("Online")),
Text(self._sanitize_date(
self.model['status']['since']))]),
Columns([('fixed', 15, Text("Applications")),
Text(", ".join(applications.keys()))]),
Columns([('fixed', 15, Text("Machines")),
Text(str(self._total_machines(self.model)))])
])
total_items.append(tbl)
total_items.append(HR())
return Padding.center_80(Filler(Pile(total_items), valign='top'))
示例10: build_widget
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def build_widget(self):
return [
Columns([
('fixed', 16, Text('network bridge', align="right")),
Color.string_input(
self.lxd_config['network'],
focus_map='string_input focus')
], dividechars=1),
HR(),
Columns([
('fixed', 16, Text('storage pool', align="right")),
Color.string_input(
self.lxd_config['storage-pool'],
focus_map='string_input focus')
], dividechars=1),
]
示例11: build_widget
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def build_widget(self):
self.choices.append(HR())
for addon in sorted(app.addons.values(), key=attrgetter('name')):
self.choices.append_option(label=addon.friendly_name,
value=addon.name,
state=addon.name in app.selected_addons)
self.choices.append(Padding.line_break(""))
self.choices.append(
Columns([
('fixed', 3, Text('')),
Text(addon.description)
], dividechars=5)
)
self.choices.append(HR())
if app.addons:
self.choices.focus_position = 1
return self.choices
示例12: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def __init__(self, app, public_clouds, custom_clouds,
compatible_cloud_types, cb=None, back=None):
self.app = app
self.cb = cb
self.back = back
self.public_clouds = public_clouds
self.custom_clouds = custom_clouds
self.compatible_cloud_types = compatible_cloud_types
self.config = self.app.config
self.buttons_pile_selected = False
self.message = Text('')
self._items_localhost_idx = None
self.show_back_button = back is not None
super().__init__()
self.update_message()
示例13: build_widget
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def build_widget(self):
rows = []
def add_row(label, field):
rows.extend([
Columns([('fixed', 23, Text(label)),
Color.string_input(field,
focus_map='string_input focus')]),
Padding.line_break(""),
])
add_row('Email:', self.email),
add_row('Password:', self.password),
add_row('Two-Factor Auth (2FA):', self.twofa),
if self.error:
rows.append(Color.error_major(Text(" {}".format(self.error))))
return rows
示例14: do_toggle_show_all_config
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def do_toggle_show_all_config(self):
if not self.showing_all:
new_ows = await self.get_non_whitelisted_option_widgets()
header = Text("Advanced Configuration Options")
opts = self.widget.options()
self.widget.contents.append((header, opts))
for ow in new_ows:
self.widget.contents.append((ow, opts))
self.toggle_show_all_button.set_label(
"Hide Advanced Configuration")
self.showing_all = True
else:
i = self.toggle_show_all_button_index
self.widget.contents = self.widget.contents[:i + 1]
self.toggle_show_all_button.set_label(
"Show Advanced Configuration")
self.showing_all = False
示例15: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import Text [as 别名]
def __init__(self, app, step_model):
"""
Arguments:
step_model: step model
step_model_widget: step model widget
cb: callback
"""
self.app = app
self.model = step_model
self.title = Text(('info_minor', step_model.title))
self.description = Text(('body', step_model.description))
self.result = Text(step_model.result)
self.sudo_label = Text(('body', ''))
self.icon = Text(("pending_icon", "\N{BALLOT BOX}"))
self.sudo_input = None
self.complete = asyncio.Event()
self.requires_input = False
form_fields = (self._build_form_header() +
self._build_sudo_field() +
self._build_form_fields())
super().__init__(form_fields)
if self.sudo_input or self.fields:
self.show_button()
self.focus_position = 4