def __init__(self, mod: Mod, *callbacks: Iterable[ModItemCallback]):
"""Wrap mod in the set of display widgets.
Keyword arguments:
mod: The :class:`Mod` to be wrapped.
callbacks: The functions to be called when this object
is selected.
"""
btn_prefix = ' ? '
# Construct button (the selectable part)
btn = urwid.Button('')
btn._w = urwid.AttrMap(
urwid.SelectableIcon([btn_prefix, mod.name], 2),
'title', 'title_focus',
)
for callback in callbacks:
urwid.connect_signal(btn, 'click', callback, user_args=[mod])
# Construct the mod summary
text = urwid.Padding(
urwid.AttrMap(urwid.Text(mod.summary), 'description'),
left=len(btn_prefix)*2,
)
pile = btn, text
super().__init__(pile)
评论列表
文章目录