def __init__(self, *contents, tabbar=None):
"""Create new Tabs widget
contents: Iterable of dictionaries or iterables that match the arguments
of the `insert` method
tabbar: TabBar instance that is used to display tab titles or any object
with a 'base_widget' attribute (e.g. AttrMap) that returns a
TabBar object
"""
if tabbar is None:
self._tabbar = TabBar()
elif not isinstance(tabbar, urwid.Widget):
raise ValueError('tabbar must be TabBar instance, not {}: {!r}'
.format(type(tabbar).__name__, tabbar))
else:
self._tabbar = tabbar
self._ids = []
self._contents = urwid.MonitoredFocusList()
for content in contents:
if not isinstance(content, collections.Mapping):
content = dict(zip(('title', 'widget', 'position', 'focus'),
content))
self.insert(**content)
评论列表
文章目录