curses_ui.py 文件源码

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

项目:huhamhire-hosts 作者: jiangsile 项目源码 文件源码
def configure_settings_frame(self, pos=None):
        """
        Draw `Configure Setting` frame with a index number (`pos`) of the item
        selected.

        :param pos: Index of selected item in `Configure Setting` frame. The
            default value of `pos` is `None`.
        :type pos: int or None

        .. note:: None of the items in `Configure Setting` frame would be
            selected if pos is `None`.
        """
        self._stdscr.keypad(1)
        screen = self._stdscr.subwin(8, 25, 2, 0)
        screen.bkgd(' ', curses.color_pair(4))
        # Set local variable
        normal = curses.A_NORMAL
        select = curses.color_pair(5)
        select += curses.A_BOLD

        for p, item in enumerate(self.settings):
            item_str = item[0].ljust(12)
            screen.addstr(3 + p, 2, item_str, select if p == pos else normal)
            if p:
                choice = "[%s]" % item[2][item[1]]
            else:
                choice = "[%s]" % item[2][item[1]]["label"]
            screen.addstr(3 + p, 15, ''.ljust(10), normal)
            screen.addstr(3 + p, 15, choice, select if p == pos else normal)
        screen.refresh()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号