display.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:sshchan 作者: einchan 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号