當前位置: 首頁>>代碼示例>>Python>>正文


Python urwid.TreeListBox方法代碼示例

本文整理匯總了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)]) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:38,代碼來源:widgets.py

示例2: buildFrame

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import TreeListBox [as 別名]
def buildFrame(self):
        topnode = CommentNode(self.comments)
        return urwid.TreeListBox(urwid.TreeWalker(topnode)) 
開發者ID:wtheisen,項目名稱:TerminusBrowser,代碼行數:5,代碼來源:threadFrame.py

示例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) 
開發者ID:zstackio,項目名稱:zstack-utility,代碼行數:14,代碼來源:browse.py

示例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) 
開發者ID:zstackio,項目名稱:zstack-utility,代碼行數:12,代碼來源:setting.py

示例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) 
開發者ID:topisani,項目名稱:Discurses,代碼行數:48,代碼來源:server_tree.py


注:本文中的urwid.TreeListBox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。