Python curses 模块,A_UNDERLINE 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用curses.A_UNDERLINE

项目:ascii_qgis    作者:NathanW2    | 项目源码 | 文件源码
def display(self, title, content):
        curses.curs_set(0)
        self.infowin.clear()
        y, x = self.infowin.getmaxyx()
        self.infowin.bkgd(" ", curses.color_pair(6))
        self.infowin.box()
        self.infowin.addstr(0, 0, title + " - 'q' to close", curses.A_UNDERLINE | curses.A_BOLD)
        for count, line in enumerate(content.split('\n'), start=1):
            try:
                self.infowin.addstr(count, 1, line)
            except:
                pass

        self.infopanel.show()
        curses.panel.update_panels()
        curses.doupdate()
        while self.infowin.getch() != ord('q'):
            pass
        curses.curs_set(1)
项目:soyouhaveanidea    作者:yigitbey    | 项目源码 | 文件源码
def update(self):
        for index, item in enumerate(self.employees):
            mode = self.select_mode(index)

            try:
                if item.unlocked_age < 2:
                    mode = mode | curses.A_BOLD | curses.A_UNDERLINE
            except:
                pass

            if self.first_item_index > 0:
                self.window.addstr(0, 20, self.arrow_up)

            order = self.first_item_index + index + 1
            msg = self.item_message.format(order, item)
            self.window.addstr(1 + index, 1, msg, mode)

            if self.last_item_index < len(self.items):
                self.window.addstr(self.LIST_SIZE + 1, 20, self.arrow_down)

        self.window.refresh()
        curses.doupdate()
项目:cursed    作者:johannestaas    | 项目源码 | 文件源码
def _cw_menu_display(cls):
        x = 0
        # Because cls with MENU will add 1 to y in _fix_xy, we need true origin
        y = -1
        # Makes the menu standout
        menu_attrs = curses.A_REVERSE | curses.A_BOLD
        saved_pos = cls.getxy()
        for menu in Menu.ALL:
            # double check we're not going to write out of bounds
            if x + len(menu.title) + 2 >= cls.WIDTH:
                raise CursedSizeError('Menu %s exceeds width of window: x=%d' %
                                      (menu.title, x))
            y = -1
            cls.addstr(menu.title + '  ', x, y, attr=menu_attrs)
            mxlen = max([len(str(i)) for i in menu.items])
            if menu is cls._OPENED_MENU:
                for item in menu.items:
                    y += 1
                    itemstr = str(item)
                    wspace = (mxlen - len(itemstr)) * ' '
                    itemstr = itemstr + wspace
                    if item is menu.selected:
                        attr = curses.A_UNDERLINE
                    else:
                        attr = curses.A_REVERSE
                    cls.addstr(itemstr, x, y, attr=attr)
            # For the empty space filler
            x += len(menu.title) + 2
        # color the rest of the top of the window
        extra = 2 if cls.BORDERED else 0
        cls.addstr(' ' * (cls.WIDTH - x - extra), x, -1, attr=menu_attrs)
        cls.move(*saved_pos)
项目:youtube_watcher    作者:Sjc1000    | 项目源码 | 文件源码
def video_options(self, item, position):
        if position == self.pos:
            return curses.color_pair(1)

        options = 0
        options |= curses.A_DIM if item['seen'] else 0
        options |= curses.color_pair(3) if item.get('fav') else 0

        if item['title'] in self.data:
            info = self.data[item['title']]
            options |= curses.A_UNDERLINE if info.get('watch') else 0

        if any(item['title'] == i['title'] for i in self.selected):
            options |= curses.A_REVERSE
        return options
项目:trtop    作者:aol    | 项目源码 | 文件源码
def _print_header(self):
        row = 0
        self._print_line(row, 0, "TCP Remote TOP", color=curses.A_BOLD)
        self._print_line(row, 2, " - " + self.config_subtitle)

        row = 1
        self._print_line(row, 2, "Connections", color=curses.A_BOLD)
        self._print_line(row, 14, "Transport", color=curses.A_BOLD)
        self._print_line(row, 17, "Pcap", color=curses.A_BOLD)

        row = 3
        self._print_line(row, 0, "Host", color=curses.A_UNDERLINE)
        self._print_line(row, 2, "Syn(/s)", color=curses.A_UNDERLINE)
        self._print_line(row, 4, "Syn/Ack(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 6, "Est(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 8, "Rst(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 9, "Fin_O(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 10, "Fin_I(%)", color=curses.A_UNDERLINE)
        self._print_line(row, 11, "Est Rate", color=curses.A_UNDERLINE)
        self._print_line(row, 12, "QoS", color=curses.A_UNDERLINE)
        self._print_line(row, 13, "Lat", color=curses.A_UNDERLINE)

        self._print_line(row, 14, "Out", color=curses.A_UNDERLINE)
        self._print_line(row, 15, "In", color=curses.A_UNDERLINE)
        self._print_line(row, 16, "Rtt", color=curses.A_UNDERLINE)

        self._print_line(row, 17, "Err", color=curses.A_UNDERLINE)

        row = 4
        self._print_line(row, 2, "")
        return row + 1
项目:ffw    作者:dobin    | 项目源码 | 文件源码
def initCurses():
    screen = curses.initscr()
    curses.noecho()  # disable the keypress echo to prevent double input
    curses.cbreak()  # disable line buffers to run the keypress immediately
    curses.curs_set(0)
    screen.keypad(1)  # enable keyboard use

    screen.addstr(1, 2, "Fuzzing For Worms", curses.A_UNDERLINE)
    return screen
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def _setattr(self, a):
        if a is None:
            self.s.attrset(0)
            return
        elif not isinstance(a, AttrSpec):
            p = self._palette.get(a, (AttrSpec('default', 'default'),))
            a = p[0]

        if self.has_color:
            if a.foreground_basic:
                if a.foreground_number >= 8:
                    fg = a.foreground_number - 8
                else:
                    fg = a.foreground_number
            else:
                fg = 7

            if a.background_basic:
                bg = a.background_number
            else:
                bg = 0

            attr = curses.color_pair(bg * 8 + 7 - fg)
        else:
            attr = 0

        if a.bold:
            attr |= curses.A_BOLD
        if a.standout:
            attr |= curses.A_STANDOUT
        if a.underline:
            attr |= curses.A_UNDERLINE
        if a.blink:
            attr |= curses.A_BLINK

        self.s.attrset(attr)
项目: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()