def __init__(self, srvapi, tid, title=None):
self._title = title
self._torrent = {}
sections = []
self._sections = {}
for section_cls in _sections:
section = section_cls()
sections.append(section)
self._sections[section.title] = section
def add_title(title, section):
header = urwid.Columns([('pack', urwid.Text('??? %s ?' % title)),
urwid.Divider('?')])
return urwid.Pile([('pack', header), section])
grid = urwid.GridFlow([], cell_width=1, h_sep=3, v_sep=1, align='left')
for section in sections:
opts = grid.options('given', section.width)
section_wrapped = add_title(section.title, section)
grid.contents.append((section_wrapped, opts))
grid_sb = urwid.AttrMap(
ScrollBar(urwid.AttrMap(Scrollable(grid), 'torrentsummary')),
'scrollbar'
)
super().__init__(grid_sb)
# Register new request in request pool
keys = set(('name',)).union(key for w in sections for key in w.needed_keys)
self._poller = srvapi.create_poller(srvapi.torrent.torrents, (tid,), keys=keys)
self._poller.on_response(self._handle_response)
评论列表
文章目录