menu.py 文件源码

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

项目:soyouhaveanidea 作者: yigitbey 项目源码 文件源码
def __init__(self, items, parent_window, which_menu="left"):
        self.which_menu = which_menu
        self.window = parent_window.derwin(1, 0)
        self.window.keypad(1)
        curses.noecho()
        curses.raw()

        self.position = 0
        self.items = items

        if self.which_menu == 'left':
            nothing = namedtuple("Nothing", 'message, action_str', 'article', 'formatted')
            nothing.message = "Nothing"
            nothing.action_str = "Do"
            nothing.article = ""
            nothing.formatted = "Nothing"
            self.items.insert(0, nothing)

        self.detailwindow = None

        code = locale.getpreferredencoding()
        self.arrow_up = (3*'\u2191').encode(code)
        self.arrow_down = (3*'\u2193').encode(code)

        self.first_item_index = self.position
        self.last_item_index = min(self.LIST_SIZE, len(self.items))

        self.next_window = None
        self.has_focus = False

        self.item_message = '{1.action_str} {1.article} {1.message}'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号