本文整理汇总了Python中urwid.WidgetWrap类的典型用法代码示例。如果您正苦于以下问题:Python WidgetWrap类的具体用法?Python WidgetWrap怎么用?Python WidgetWrap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WidgetWrap类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, node, expanded=True):
self._node = node
self._innerwidget = None
self.is_leaf = not hasattr(node, 'get_first_child')
self.expanded = expanded
widget = self.get_indented_widget()
# Se omite la inicializacion de TreeWidget
WidgetWrap.__init__(self, widget)
示例2: __init__
def __init__(self, transport=None):
self.transport = transport or self.transport
WidgetWrap.__init__(self, AttrMap(Columns([
('weight', 1, PlayButton(self.transport)),
('weight', 1, RewindButton(self.transport)),
('weight', 3, Text('')),
('weight', 1, MetronomeWidget(self.transport)),
('weight', 1, TempoWidget(self.transport)),
('weight', 1, Text('Quant 1 bar')),
], 1), 'footer'))
示例3: __init__
def __init__(self, icon, label, on_press=None, user_data=None):
self._icon = AttrMap(SelectableIcon(icon, 0), 'clip_dim')
self._label = SelectableIcon(label, 0)
cols = Columns([
('fixed', len(icon), self._icon),
self._label],
dividechars=1)
WidgetWrap.__init__(self, cols)
connect_signal(self, 'click', on_press, user_data)
示例4: __init__
def __init__(self, tabs=[]):
"""Creates tabs with the names given in `tabs`."""
self.tabs = tabs
if tabs:
self.active_index = 0
self.visible_indexes = [0]
else:
self.active_index = -1
self.visible_indexes = []
created_text = self._create_text()
text = created_text if created_text else ''
WidgetWrap.__init__(self, Text(text))
示例5: __init__
def __init__(self, original_widget, title="",
tlcorner=u'┌', tline=u'─', lline=u'│',
trcorner=u'┐', blcorner=u'└', rline=u'│',
bline=u'─', brcorner=u'┘'):
"""
Use 'title' to set an initial title text with will be centered
on top of the box.
You can also override the widgets used for the lines/corners:
tline: top line
bline: bottom line
lline: left line
rline: right line
tlcorner: top left corner
trcorner: top right corner
blcorner: bottom left corner
brcorner: bottom right corner
"""
tline, bline = Divider(tline), Divider(bline)
lline, rline = SolidFill(lline), SolidFill(rline)
tlcorner, trcorner = Text(tlcorner), Text(trcorner)
blcorner, brcorner = Text(blcorner), Text(brcorner)
title_widget = ('fixed', len(title), AttrMap(Text(title), 'header'))
top = Columns([
('fixed', 1, tlcorner),
title_widget,
tline,
('fixed', 1, trcorner)
])
middle = Columns([('fixed', 1, lline),
original_widget,
('fixed', 1, rline)],
box_columns=[0, 2],
focus_column=1)
bottom = Columns([('fixed', 1, blcorner),
bline,
('fixed', 1, brcorner)])
pile = Pile([('flow', top),
middle,
('flow', bottom)],
focus_item=1)
# super?
WidgetDecoration.__init__(self, original_widget)
WidgetWrap.__init__(self, pile)
示例6: __init__
def __init__(self, height, directory=".", file="", attr=(None, None),
show_hidden=False):
"""
height -- height of the directory list and the file list
directory, file -- default selection
attr -- (inner selectable widgets, selected widgets)
show_hidden -- If True, hidden files are shown by default.
"""
self.directory = abspath(directory)
self.file = ""
self.attr = attr
self.height = height
self.show_hidden=show_hidden
#Create dummy widgets for directory and file display:
self.dir_widget = AttrWrap(BoxAdapter(ListBox([self._blank]),
self.height), self.attr[0])
self.file_widget = AttrWrap(BoxAdapter(ListBox([self._blank]),
self.height), self.attr[0])
columns = Columns([self.dir_widget, self.file_widget], 1)
#Selection widget:
self.select_widget = AttrWrap(Edit("", ""),
self.attr[0], self.attr[1])
#Buttons and checkbox:
button_widgets = [AttrWrap(Button(button, self._action),
attr[0], attr[1])
for button in ["OK", "Cancel"]]
button_grid = GridFlow(button_widgets, 12, 2, 1, 'center')
button_cols = Columns([CheckBox(self.SHOW_HIDDEN_TEXT,
self.show_hidden,
False, self._toggle_hidden),
button_grid])
self.outer_widget = Pile([columns,
self._blank,
Text(self.SELECTION_TEXT),
self.select_widget,
self._blank,
button_cols
])
self.update_widgets()
WidgetWrap.__init__(self, self.outer_widget)
示例7: __init__
def __init__(self, original_widget, title=None, title_attr=None, attr=None):#{{{
self.title = title
self.title_attr = title_attr
self.attr = attr
self._attr = attr
def _get_attr(w):
if attr is not None:
return AttrMap(w, attr)
return w
self.tline = _get_attr(Divider(utf8decode("─")))
self.bline = _get_attr(Divider(utf8decode("─")))
self.lline = _get_attr(SolidFill(utf8decode("│")))
self.rline = _get_attr(SolidFill(utf8decode("│")))
self.tlcorner = _get_attr(Text(utf8decode("┌")))
self.trcorner = _get_attr(Text(utf8decode("┐")))
self.blcorner = _get_attr(Text(utf8decode("└")))
self.brcorner = _get_attr(Text(utf8decode("┘")))
self._title_text = Text(" %s " % self.title, 'center')
self._title = AttrMap(self._title_text, self.title_attr)
top = Columns([('fixed', 1, self.tlcorner),
self.tline,
('fixed', len(self.title)+2, self._title),
self.tline,
('fixed', 1, self.trcorner)])
middle = Columns([('fixed', 1, self.lline),
original_widget,
('fixed', 1, self.rline)],
box_columns=[0,2],
focus_column=1)
bottom = Columns([('fixed', 1, self.blcorner),
self.bline,
('fixed', 1, self.brcorner)])
pile = Pile([('flow', top), middle, ('flow', bottom)], focus_item=1)
WidgetDecoration.__init__(self, original_widget)
WidgetWrap.__init__(self, pile)
示例8: __init__
def __init__(self, user, last_statuses):
"""
Receive a ``user`` and its ``last_statuses`` to render the widget.
"""
whitespace = Divider(' ')
widgets = []
# name
name = Text('%s' % user.name)
widgets.extend([name, whitespace])
# bio
if user.description:
description = Text(parse_attributes(user.description))
widgets.extend([description, whitespace])
# URL
if user.url:
url_text_with_attr = ('url', user.url)
url = Text(url_text_with_attr)
widgets.extend([url, whitespace])
# statistics: following, followers and favorites
# TODO: tweet count
following = Text(_('following:\n%s' % user.friends_count))
followers = Text(_('followers:\n%s' % user.followers_count))
favorites = Text(_('favorites:\n%s' % user.favorites_count))
stats = Columns([following, followers, favorites])
widgets.extend([stats, whitespace])
# Last n statuses
# TODO: make it configurable
statuses_to_show = configuration.styles['statuses_in_user_info']
status_widgets = [StatusWidget(status) for status in last_statuses[:statuses_to_show]]
widgets.extend(status_widgets)
pile = Pile(widgets)
WidgetWrap.__init__(self, LineBox(title='@%s' % user.screen_name,
original_widget=pile))
示例9: __init__
def __init__(self, configuration):
self._configuration = configuration
self._editor = None
# header
header = TabsWidget()
# body
body = Banner(configuration)
# footer
self._status_bar = configuration.styles.get("status_bar", False)
if self._status_bar:
footer = StatusBar("")
else:
footer = None
self.frame = Frame(body, header=header, footer=footer)
WidgetWrap.__init__(self, self.frame)
示例10: __init__
def __init__(self, user, configuration):
"""
"""
whitespace = Divider(' ')
widgets = []
# name
name = Text('%s' % user.name)
widgets.extend([name, whitespace])
# bio
if user.description:
description = Text(parse_attributes(user.description))
widgets.extend([description, whitespace])
# URL
if user.url:
url_text_with_attr = ('url', user.url)
url = Text(url_text_with_attr)
widgets.extend([url, whitespace])
# statistics: following, followers and favorites
following = Text(_('following:\n%s' % user.friends_count))
followers = Text(_('followers:\n%s' % user.followers_count))
favorites = Text(_('favorites:\n%s' % user.favorites_count))
stats = Columns([following, followers, favorites])
widgets.extend([stats, whitespace])
# last status
if user.status:
status = StatusWidget(user.status, configuration)
widgets.append(status)
pile = Pile(widgets)
WidgetWrap.__init__(self, LineBox(title='@%s' % user.screen_name,
original_widget=pile))
示例11: __init__
def __init__(self, app):
ClipLauncherUI.__init__(self, app)
# set colors
self.app.main_loop.screen.register_palette(self.palette)
# create widgets
tracks = enumerate(self.app.tracks)
self.cols = Columns(SimpleFocusListWalker(
[TrackWidget(self, t, n + 1) for n, t in tracks]),
self.track_spacing)
self.editor = Panel()
self.header = TransportWidget(app.transport)
self.footer = AttrMap(Text('foo'), 'footer')
# listen to events
INFO.append(self.on_info)
# init as pile of widgets
WidgetWrap.__init__(self, Pile([
('pack', self.header),
self.cols,
(10, self.editor),
('pack', self.footer)]))
示例12: _wrap
def _wrap(self, widgets):
widgets = widgets if isinstance(widgets, list) else [widgets]
composed_widget = Columns(widgets)
widget = AttrMap(LineBox(composed_widget), 'editor')
WidgetWrap.__init__(self, widget)