python类SimpleFocusListWalker()的实例源码

multiple.py 文件源码 项目:Adwear 作者: Uberi 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self):
        body = urwid.SimpleFocusListWalker([question()])
        super(ConversationListBox, self).__init__(body)
adventure.py 文件源码 项目:Adwear 作者: Uberi 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self):
        self.log = urwid.SimpleFocusListWalker([])
        self.top = urwid.ListBox(self.log)
        self.inventory = set()
        self.update_place(map_top)
fm.py 文件源码 项目:doubanfm-py 作者: nekocode 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, btns):
        super(SongListBox, self).__init__(urwid.SimpleFocusListWalker(btns))

        self._command_map['j'] = 'cursor down'
        self._command_map['k'] = 'cursor up'
chatwindow.py 文件源码 项目:ChatMaster3000 作者: pkrll 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self):
        body = urwid.SimpleFocusListWalker([])
        super(ChatWindow, self).__init__(body)
display.py 文件源码 项目:sshchan 作者: einchan 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def show_board(self):
        index = self.board.get_index()
        new_btn = ur.AttrMap(
            ur.Button("New thread", self.reply_box, -1), "green", "b_green")
        thread_list = ur.SimpleFocusListWalker(
            [ur.Padding(new_btn, "center", ("relative", 40)), self.parent.div])

        for thread in index:
            # Check subject, because empty subject with set color attribute
            # produces wrong output.
            subject = ("reverse_red", thread[1])
            if subject[1] == "":
                subject = (None, "")

            op = self.parse_post(thread[2])

            post_info = ur.Text([("reverse_green", op["name"]),
                                 " " + op["stamp"] + " ", subject, " No. " +
                                 op["id"]])
            reply_btn = ur.AttrMap(CleanButton(
                "Reply", self.print_thread, op["id"]), None, "reverse")

            replies = []
            if len(thread) > 3:
                for i in range(3, 6):
                    try:
                        reply = self.parse_post(thread[i])
                        replies_info = ur.Text(
                            [("green", reply["name"]), " " + reply["stamp"]])
                        no_btn = CleanButton(
                            "No. " + reply["id"],
                            self.print_thread,
                            reply["id"])

                        replies_header = ur.Padding(ur.Columns(
                            [("pack", replies_info), ("pack", no_btn)],
                            1), left=1)
                        reply_text = ur.Padding(reply["text"], left=1)

                        replies.extend(
                            [replies_header, reply_text, self.parent.div])
                    except IndexError:
                        break

            header = ur.AttrMap(ur.Columns(
                [("pack", post_info), ("pack", reply_btn)], 1), "reverse")

            thread_buf = [header, op["text"], self.parent.div]
            thread_buf.extend(replies)
            thread_list.extend(thread_buf)

        body = ur.ListBox(thread_list)
        if len(thread_list) > 0:
            body.set_focus(0)

        self.loop.Widget = ur.Frame(
            body, self.parent.header, self.parent.footer, "body")
main.py 文件源码 项目:bbj 作者: desvox 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def on_post(self, button, message):
        quotes = self.get_quotes(message)
        author = self.usermap[message["author"]]
        buttons = []

        if not self.window_split:
            buttons.append(urwid.Button("Reply", self.reply, message))

        if quotes and message["post_id"] != 0:
            buttons.append(urwid.Button(
                "View %sQuote" % ("a " if len(quotes) != 1 else ""),
                self.quote_view_menu, quotes))

        if network.can_edit(message["thread_id"], message["post_id"]) \
               and not self.window_split:

            if message["post_id"] == 0:
                msg = "Thread"
            else: msg = "Post"

            raw = message["send_raw"]
            buttons.insert(0, urwid.Button("Delete %s" % msg, self.deletion_dialog, message))
            buttons.insert(0, urwid.Button(
                "Enable Formatting" if raw else "Disable Formatting",
                self.toggle_formatting, message))
            buttons.insert(0, urwid.Button("Edit Post", self.edit_post, message))

        if not buttons:
            return

        widget = OptionsMenu(
            urwid.ListBox(urwid.SimpleFocusListWalker(buttons)),
            title=str(">>%d (%s)" % (message["post_id"], author["user_name"])),
            **frame_theme()
        )
        size = self.loop.screen_size

        self.loop.widget = urwid.Overlay(
            urwid.AttrMap(widget, str(author["color"]*10)),
            self.loop.widget,
            align=("relative", 50),
            valign=("relative", 50),
            width=30,
            height=len(buttons) + 2
        )


问题


面经


文章

微信
公众号

扫码关注公众号