menu_item.py 文件源码

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

项目:aws-ec2rescue-linux 作者: awslabs 项目源码 文件源码
def _draw_input(self, stdscr, header, message):
        """
        Draw an input window with the provided message.

        Parameters:
            stdscr (WindowObject): the screen; handled by curses.wrapper
            header (str): header message displayed above the text entry box
            message (str): the message to the user displayed between the header and the text entry

        Returns:
            (Textbox): the Textbox's edit() returns a string representing the user's input
        """
        stdscr.clear()

        # Setup the title
        stdscr.addstr("ec2rl module configurator", curses.A_REVERSE)
        stdscr.chgat(-1, curses.A_REVERSE)
        curses.curs_set(0)

        num_columns = 30
        num_lines = 1
        uly = 3
        ulx = 3

        main_window = curses.newwin(curses.LINES - 1, curses.COLS, 1, 0)
        screen = main_window.subwin(curses.LINES - 7, curses.COLS - 4, 4, 2)

        # Setup background colors
        main_window.bkgd(" ", curses.color_pair(1))
        screen.bkgd(" ", curses.color_pair(2))

        # Draw borders around the screen subwindow
        screen.box()

        input_screen = main_window.subwin(num_lines, num_columns, uly + 5, ulx + 3)
        ec2rlcore.menu_textpad_mod.rectangle(screen, uly, ulx, uly + 1 + num_lines, ulx + 1 + num_columns)
        screen.addstr(1, 2, header, curses.A_UNDERLINE)
        # Truncate the string, if needed
        display_str = message[:curses.COLS - 10]
        screen.addstr(2, 5, display_str)

        # Draw the pieces of the overall screen (order matters)
        stdscr.refresh()
        main_window.noutrefresh()
        screen.noutrefresh()
        input_screen.noutrefresh()
        stdscr.noutrefresh()
        curses.doupdate()

        return ec2rlcore.menu_textpad_mod.Textbox(input_screen, bkgd_color=curses.color_pair(2)).edit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号