本文整理汇总了Python中urwid.TreeListBox方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.TreeListBox方法的具体用法?Python urwid.TreeListBox怎么用?Python urwid.TreeListBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid
的用法示例。
在下文中一共展示了urwid.TreeListBox方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import TreeListBox [as 别名]
def build(self, title, contents):
header = AM(urwid.Text(title), 'header')
#clist = self._build_tree(contents)
#listbox = urwid.TreeWalker(PackageNode(contents[0]))
#listbox = urwid.TreeListBox(urwid.TreeWalker(PackageNode(contents[0])))
#return urwid.Frame(AM(urwid.Filler(urwid.Text("Sample")), 'body'), header=header)
#treelist = CollapsibleArrowTreeListWalker([ListEntry(e) for e in contents])
#mtw = ModuleTreeWalker([ListEntry(e) for e in contents])
# define a list of trees to be passed on to SimpleTreeWalker
forrest = [construct_example_tree()]
# stick out test tree into a SimpleTreeWalker
swalker = walkers.SimpleTreeWalker(forrest)
if_grandchild = lambda pos: swalker.depth(pos) > 1
treelist = CollapsibleIndentedTreeListWalker(swalker,
#treelist = CollapsibleArrowTreeListWalker(swalker,
is_collapsed=if_grandchild,
#indent=6,
#childbar_offset=1,
selectable_icons=True,
icon_focussed_att='focus',
#icon_frame_left_char=None,
#icon_frame_right_char=None,
#icon_expanded_char='-',
#icon_collapsed_char='+',
)
#return urwid.Frame(AM(treebox, 'body'), header=header)
wlist = [ListEntry(e) for e in contents]
listbox = urwid.ListBox(urwid.SimpleListWalker(wlist))
treebox = TreeBox(treelist)
#return urwid.Frame(AM(treebox, 'body'), header=header)
return urwid.Pile([urwid.LineBox(listbox), urwid.LineBox(treebox)])
示例2: buildFrame
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import TreeListBox [as 别名]
def buildFrame(self):
topnode = CommentNode(self.comments)
return urwid.TreeListBox(urwid.TreeWalker(topnode))
示例3: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import TreeListBox [as 别名]
def __init__(self):
cwd = os.getcwd()
store_initial_cwd(cwd)
self.header = urwid.Text("")
self.listbox = urwid.TreeListBox(urwid.TreeWalker(DirectoryNode(cwd)))
self.listbox.offset_rows = 1
self.footer = urwid.AttrWrap(urwid.Text(self.footer_text),
'foot')
self.view = urwid.Frame(
urwid.AttrWrap(self.listbox, 'body'),
header=urwid.AttrWrap(self.header, 'head'),
footer=self.footer)
示例4: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import TreeListBox [as 别名]
def __init__(self, category_list):
'''
Constructor
'''
assert category_list
self.category_list = category_list
self.listbox = urwid.TreeListBox(urwid.TreeWalker(CategoryNode('test')))
self.header = urwid.AttrWrap(urwid.Text(self.header_text), 'head')
self.view = urwid.Frame(urwid.AttrWrap(self.listbox, 'body'),
header=self.header)
示例5: __init__
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import TreeListBox [as 别名]
def __init__(self, chat_widget, close_callback=None):
self.chat_widget = chat_widget
self.ui = chat_widget.ui
self.close_callback = close_callback
items = []
for server in sorted(chat_widget.discord.servers,
key=lambda s: s.name):
node = {"name": server.name,
'server_tree': self,
'server': server,
"children": []}
for ch in server.channels:
if ch.type == discord.ChannelType.text:
node['children'].append({
'name': ch.name,
'server_tree': self,
'channel': ch
})
nodeobj = TreeNodeServer(node)
nodeobj.expanded = False
items.append(nodeobj)
if len(chat_widget.discord.private_channels) > 0:
node = {"name": "Private Chats",
'server_tree': self,
'server': None,
"children": []}
for ch in chat_widget.discord.private_channels:
name = ''
if ch.type == discord.ChannelType.private:
name = ch.user.display_name
elif ch.type == discord.ChannelType.group:
name = ch.name or ', '.join(u.display_name for u in ch.recipients)
else:
continue
node['children'].append({
'name': name,
'server_tree': self,
'channel': ch
})
nodeobj = TreeNodeServer(node)
nodeobj.expanded = False
items.append(nodeobj)
self.w_listbox = urwid.TreeListBox(TreeWalker(items))
self.__super.__init__(self.w_listbox)