Python curses 模块,A_BOLD 实例源码

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

项目:defuse_division    作者:lelandbatey    | 项目源码 | 文件源码
def refresh(self):
        prior, (cursr_y, cursr_x) = curses.curs_set(0), curses.getsyx()
        for idx, item in enumerate(self.items):
            fmt = '{{: <{}}}'.format(self.width-1)
            s = fmt.format(str(item))[:self.width-1]
            # s = str(item)[:self.width-1] if len(str(item)) > self.width-1 else str(item)
            color = colors.get_colorpair(self.default_color)
            if self.current == idx:
                if self.is_selected:
                    color = colors.get_colorpair('black-white')
                else:
                    color = colors.get_colorpair(self.highlight_color)
            self.textinpt.addstr(idx, 0, s, color)
        if self.is_selected:
            self.borderbox.bkgd(' ', curses.A_BOLD)
        else:
            self.borderbox.bkgd(' ', curses.A_DIM)
        self.borderbox.border()
        self.borderbox.refresh()
        self.textinpt.refresh()

        curses.curs_set(prior)
        curses.setsyx(cursr_y, cursr_x)
        curses.doupdate()
项目:notex    作者:adiultra    | 项目源码 | 文件源码
def box_init(self):
        """Clear the main screen and redraw the box and/or title

        """
        # Touchwin seems to save the underlying screen and refreshes it (for
        # example when the help popup is drawn and cleared again)
        self.scr.touchwin()
        self.scr.refresh()
        self.stdscr.clear()
        self.stdscr.refresh()
        if self.box is True:
            self.boxscr.clear()
            self.boxscr.box()
            if self.title:
                addstr(self.boxscr, 1, 1, self.title, curses.A_BOLD)
                addstr(self.boxscr, self.title_help, curses.A_STANDOUT)
            self.boxscr.refresh()
        elif self.title:
            self.boxscr.clear()
            addstr(self.boxscr, 0, 0, self.title, curses.A_BOLD)
            addstr(self.boxscr, self.title_help, curses.A_STANDOUT)
            self.boxscr.refresh()
项目:huhamhire-hosts    作者:jiangsile    | 项目源码 | 文件源码
def sub_selection_dialog_items(self, pos, i_pos, screen):
        """
        Draw items in `Selection Dialog`.

        :param pos: Index of selected item in `Configure Setting` frame.
        :type pos: int
        :param i_pos: Index of selected item in `Selection Dialog`.
        :type i_pos: int
        :param screen: A **WindowObject** which represents the selection
            dialog.
        :type screen: WindowObject
        """
        # Set local variable
        normal = curses.A_NORMAL
        select = normal + curses.A_BOLD
        for p, item in enumerate(self.settings[pos][2]):
            item_str = item if pos else item["tag"]
            screen.addstr(1 + p, 2, item_str,
                          select if p == i_pos else normal)
        screen.refresh()
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def setTitle( self, title ):
            self.decoration.setText( 1, 1, title.center( self.dimensions[WIDTH]-2 ), curses.A_BOLD )

    #-------------------------------------------------------------------------#
#    class TitleWindow( Window ):
    #-------------------------------------------------------------------------#
#        """Title Window"""
#        def __init__( self, x, y, width, height ):
#            NCursesUI.Window.__init__( self, x, y, width, height )
#            version = bb.__version__
#            title = "BitBake %s" % version
#            credit = "(C) 2003-2007 Team BitBake"
#            #self.win.hline( 2, 1, curses.ACS_HLINE, width-2 )
#            self.win.border()
#            self.setText( 1, 1, title.center( self.dimensions[WIDTH]-2 ), curses.A_BOLD )
#            self.setText( 1, 2, credit.center( self.dimensions[WIDTH]-2 ), curses.A_BOLD )

    #-------------------------------------------------------------------------#
项目:aws-ec2rescue-linux    作者:awslabs    | 项目源码 | 文件源码
def _draw_footer(self, footer_window):
        """
        Given a footer window and a list of items, draw the items in the footer and highlight the selected item.

        Parameters:
            footer_window (WindowObject): the window the footer will be drawn in
        """
        for item in self.footer_items:
            if self.footer_items.index(item) == self.current_column:
                # Highlight the item that is currently selected
                footer_window.addstr(1,
                                     self.footer_items.index(item) * 10 + 1,
                                     item,
                                     curses.color_pair(1) | curses.A_BOLD)
            else:
                footer_window.addstr(1,
                                     self.footer_items.index(item) * 10 + 1,
                                     item)
项目:copycat    作者:LSaldyt    | 项目源码 | 文件源码
def depict_workspace_object(self, w, row, column, o, maxImportance, description_structures):
        if maxImportance != 0.0 and o.relativeImportance == maxImportance:
            attr = curses.A_BOLD
        else:
            attr = curses.A_NORMAL
        w.addstr(row, column, str(o), attr)
        column += len(str(o))
        if o.descriptions:
            w.addstr(row, column, ' (', curses.A_NORMAL)
            column += 2
            for i, d in enumerate(o.descriptions):
                if i != 0:
                    w.addstr(row, column, ', ', curses.A_NORMAL)
                    column += 2
                s, attr = self.slipnode_name_and_attr(d.descriptor)
                if d not in description_structures:
                    s = '[%s]' % s
                w.addstr(row, column, s, attr)
                column += len(s)
            w.addstr(row, column, ')', curses.A_NORMAL)
            column += 1
        return column
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def strng2():
    treescrn2.attrset(curses.A_BOLD | curses.A_BLINK)
    set_color(treescrn2, curses.COLOR_WHITE)

    treescrn2.addch(5, 14, ord('\''))
    treescrn2.addch(5, 13, ord(':'))
    treescrn2.addch(5, 12, ord('.'))
    treescrn2.addch(5, 11, ord(','))
    treescrn2.addch(6, 10, ord('\''))
    treescrn2.addch(6, 9, ord(':'))

    treescrn2.attroff(curses.A_BOLD | curses.A_BLINK)
    unset_color(treescrn2)

    treescrn2.refresh()
    w_del_msg.refresh()
    return
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def strng3():
    treescrn2.attrset(curses.A_BOLD | curses.A_BLINK)
    set_color(treescrn2, curses.COLOR_WHITE)

    treescrn2.addch(7, 16, ord('\''))
    treescrn2.addch(7, 15, ord(':'))
    treescrn2.addch(7, 14, ord('.'))
    treescrn2.addch(7, 13, ord(','))
    treescrn2.addch(8, 12, ord('\''))
    treescrn2.addch(8, 11, ord(':'))
    treescrn2.addch(8, 10, ord('.'))
    treescrn2.addch(8, 9, ord(','))

    treescrn2.attroff(curses.A_BOLD | curses.A_BLINK)
    unset_color(treescrn2)

    treescrn2.refresh()
    w_del_msg.refresh()
    return
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def strng4():
    treescrn2.attrset(curses.A_BOLD | curses.A_BLINK)
    set_color(treescrn2, curses.COLOR_WHITE)

    treescrn2.addch(9, 17, ord('\''))
    treescrn2.addch(9, 16, ord(':'))
    treescrn2.addch(9, 15, ord('.'))
    treescrn2.addch(9, 14, ord(','))
    treescrn2.addch(10, 13, ord('\''))
    treescrn2.addch(10, 12, ord(':'))
    treescrn2.addch(10, 11, ord('.'))
    treescrn2.addch(10, 10, ord(','))
    treescrn2.addch(11, 9, ord('\''))
    treescrn2.addch(11, 8, ord(':'))
    treescrn2.addch(11, 7, ord('.'))
    treescrn2.addch(11, 6, ord(','))
    treescrn2.addch(12, 5, ord('\''))

    treescrn2.attroff(curses.A_BOLD | curses.A_BLINK)
    unset_color(treescrn2)

    treescrn2.refresh()
    w_del_msg.refresh()
    return
项目: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)
项目:solent    作者:solent-eng    | 项目源码 | 文件源码
def get_curses_colour_enum_closest_to_cpair(cpair):
    if cpair in MAP_CONST_COLOURS_TO_CPAIR:
        return curses.color_pair(MAP_CONST_COLOURS_TO_CPAIR[cpair])|curses.A_BOLD
    else:
        choice_cpair = None
        for (avail_cpair, curses_pair_id) in MAP_CONST_COLOURS_TO_CPAIR.items():
            if choice_cpair == None:
                choice_cpair = avail_cpair
                continue
            # Locate the closest to the desired cpair that is not larger than
            # it
            if avail_cpair > cpair:
                continue
            elif avail_cpair > choice_cpair:
                choice_cpair = avail_cpair
        return avail_cpair|curses.A_BOLD
项目:connect4    作者:guglielmilo    | 项目源码 | 文件源码
def addString(y, x, string, string_color=color.BLACK, bold=False):
    if x == position.CENTER:
        x = width/2 - len(string)/2
    options = 0
    if curses.can_change_color():
        # tokens special cases color
        if string == 'X':
            options = curses.color_pair(color.RED) if not bold else curses.color_pair(color.RED_H) | curses.A_BOLD
        elif string == 'O':
            options = curses.color_pair(color.YELLOW) if not bold else curses.color_pair(color.YELLOW_H) | curses.A_BOLD
        else:
            options = curses.color_pair(string_color)
    if bold:
        options |= curses.A_BOLD
    stdscr.addstr(y, x, string, options)
    stdscr.refresh()

# main display
项目:ci_edit    作者:google    | 项目源码 | 文件源码
def get(colorType, delta=0):
  global cache__
  if type(colorType) == type(0):
    colorIndex = colorType
  else:
    colorIndex = app.prefs.color[colorType]
  colorIndex = min(colors - 1, colorIndex + delta)
  #colorIndex = colorIndex % colors
  r = cache__.get(colorIndex)
  if r is not None:
    return r
  color = curses.color_pair(colorIndex)
  if colorType in ('error', 'misspelling'):
    color |= curses.A_BOLD | curses.A_REVERSE
  cache__[colorIndex] = color
  return color
项目:vpn-fetch    作者:Flynston    | 项目源码 | 文件源码
def set_title(self, args):
        if len(args) > 2:
            args[2] = args[2].ljust(15)
        str_arg = ' -> '.join(args[:-1])+' -> '

        color_arg = args[-1]

        width_margin = int(0.3*self.width)

        text_width = self.width - width_margin - 3
        if len(str_arg+color_arg) > text_width:
            left_width = text_width-len(color_arg)
            str_arg = '~'+str_arg[-left_width:] 



        self.win.erase()    
        self.win.addstr(self.height//2, width_margin+1, str_arg)
        self.win.addstr(self.height//2, width_margin+len(str_arg)+1, 
                                        color_arg, curses.A_BOLD)
        self.win.refresh()
项目: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()
项目:defuse_division    作者:lelandbatey    | 项目源码 | 文件源码
def select(self):
        self.borderbox.bkgd(' ', curses.A_BOLD)
        self.textinpt.bkgd(' ', colors.get_colorpair('black-white'))
        self.refresh()
项目:defuse_division    作者:lelandbatey    | 项目源码 | 文件源码
def select(self):
        '''
        Not only selects this textbox, but turns on the cursor and moves it to
        the correct possition within this textbox.
        '''
        self.borderbox.bkgd(' ', curses.A_BOLD)
        self.textinpt.bkgd(' ', colors.get_colorpair(self.default_color))
        curses.curs_set(1)
        self.textinpt.move(0, self.keypos)
        self.refresh()
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def display_header(scr):
    write(scr, 3, 0,  'Slot',  curses.A_BOLD)
    write(scr, 3, 5,  'Host',  curses.A_BOLD)
    write(scr, 3, 25, 'State', curses.A_BOLD)
    write(scr, 3, 45, 'Filename', curses.A_BOLD)
    #'%-4s %-20s %-15s %-40s%s' % ('Slot', 'Remote Host', 'State', 'Filename', ' '*(maxX-83)), curses.A_BOLD)
项目:botany    作者:jifunks    | 项目源码 | 文件源码
def draw_default(self):
        # draws default menu
        clear_bar = " " * (int(self.maxx*2/3))
        self.screen.addstr(2, 2, self.title, curses.A_STANDOUT) # Title for this menu
        self.screen.addstr(4, 2, self.subtitle, curses.A_BOLD) #Subtitle for this menu
        # clear menu on screen
        for index in range(len(self.options)+1):
            self.screen.addstr(5+index, 4, clear_bar, curses.A_NORMAL)
        # display all the menu items, showing the 'pos' item highlighted
        for index in range(len(self.options)):
            textstyle = self.normal
            if index == self.selected:
                textstyle = self.highlighted
            self.screen.addstr(5+index ,4, clear_bar, curses.A_NORMAL)
            self.screen.addstr(5+index ,4, "%d - %s" % (index+1, self.options[index]), textstyle)

        self.screen.addstr(11, 2, clear_bar, curses.A_NORMAL)
        self.screen.addstr(12, 2, clear_bar, curses.A_NORMAL)
        self.screen.addstr(11, 2, "plant: ", curses.A_DIM)
        self.screen.addstr(11, 9, self.plant_string, curses.A_NORMAL)
        self.screen.addstr(12, 2, "score: ", curses.A_DIM)
        self.screen.addstr(12, 9, self.plant_ticks, curses.A_NORMAL)

        # display fancy water gauge
        if not self.plant.dead:
            water_gauge_str = self.water_gauge()
            self.screen.addstr(5,14, water_gauge_str, curses.A_NORMAL)
        else:
            self.screen.addstr(5,13, clear_bar, curses.A_NORMAL)
            self.screen.addstr(5,13, " (   RIP   )", curses.A_NORMAL)

        # draw cute ascii from files
        self.draw_plant_ascii(self.plant)
项目:bittyband    作者:yam655    | 项目源码 | 文件源码
def refresh_status(self, *, no_refresh = False):
        max_y, max_x = self.stdscr.getmaxyx()
        self.stdscr.hline(max_y - 2, 0, "=", max_x)
        self.display_time(no_refresh=True)
        self.display_line(no_refresh=True)
        self.stdscr.chgat(max_y - 2, 0, curses.A_BOLD)
        if not no_refresh:
            self.stdscr.refresh()
项目:bittyband    作者:yam655    | 项目源码 | 文件源码
def display_time(self, text = None, *, no_refresh=False):
        if text == self.time and not no_refresh:
            return
        max_y, max_x = self.stdscr.getmaxyx()
        if text is not None:
            self.time = "[{}]".format(text)
        if self.time is not None:
            self.stdscr.addstr(max_y - 2, max_x - len(self.time), self.time)
        if not no_refresh:
            self.stdscr.chgat(max_y - 2, max_x - len(self.time), curses.A_BOLD)
            self.stdscr.refresh()
项目:bittyband    作者:yam655    | 项目源码 | 文件源码
def display_line(self, text = None, *, no_refresh=False):
        if text == self.line and not no_refresh:
            return
        max_y, max_x = self.stdscr.getmaxyx()
        if text is not None:
            self.line = "@{}".format(text)
        if self.line is not None:
            self.stdscr.addstr(max_y - 2, max_x - len(self.line) - len(self.time) - 1, self.line)
        if not no_refresh:
            self.stdscr.chgat(max_y - 2, max_x - len(self.line) - len(self.time) - 1, curses.A_BOLD)
            self.stdscr.refresh()
项目:mitogen    作者:dw    | 项目源码 | 文件源码
def paint(self):
        self.stdscr.erase()
        self.stdscr.addstr(0, 0, time.ctime())

        all_procs = []
        for host in self.hosts:
            all_procs.extend(host.procs.itervalues())

        all_procs.sort(key=(lambda proc: -proc.pcpu))

        self.stdscr.addstr(1, 0, self.format % {
            'hostname': 'HOST',
            'pid': 'PID',
            'ppid': 'PPID',
            'pcpu': '%CPU',
            'rss': 'RSS',
            'command': 'COMMAND',
        })
        for i, proc in enumerate(all_procs):
            if (i+3) >= self.height:
                break
            if proc.new:
                self.stdscr.attron(curses.A_BOLD)
            else:
                self.stdscr.attroff(curses.A_BOLD)
            self.stdscr.addstr(2+i, 0, self.format % dict(
                vars(proc),
                command=proc.command[:self.width-36]
            ))

        self.stdscr.refresh()
项目:led    作者:rec    | 项目源码 | 文件源码
def main(screen):
    screen.clear()
    screen_y, screen_x = screen.getmaxyx()
    screen.addstr(0, 0, str(screen.getmaxyx()))
    curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
    global DIR
    DIR = dir(screen)
    while True:
        c = screen.getch()
        screen.addstr(2, 2, str(c) + '   ', curses.color_pair(1) |
                      curses.A_BLINK | curses.A_BOLD)
        if c == 'q' or c == ord('q'):
            break
项目:led    作者:rec    | 项目源码 | 文件源码
def main(screen):
    screen.clear()
    screen_y, screen_x = screen.getmaxyx()
    screen.move(1, 1)
    screen.addstr(str(screen.getmaxyx()))
    curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
    while True:
        c = screen.getch()
        screen.move(2, 2)
        # screen.addstr(str(c), curses.A_BLINK | curses.A_BOLD)
        # screen.addstr(str(c), curses.color_pair(1))
        screen.addstr(str(c), curses.color_pair(1) | curses.A_BLINK)
        if c == 'q' or c == ord('q'):
            break
项目:huhamhire-hosts    作者:jiangsile    | 项目源码 | 文件源码
def banner(self):
        """
        Draw the banner in the TUI window.
        """
        screen = self._stdscr.subwin(2, 80, 0, 0)
        screen.bkgd(' ', curses.color_pair(1))
        # Set local variable
        title = curses.A_NORMAL
        title += curses.A_BOLD
        normal = curses.color_pair(4)
        # Print title
        screen.addstr(0, 0, self.__title.center(79), title)
        screen.addstr(1, 0, "Setup".center(10), normal)
        screen.refresh()
项目: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()
项目: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)
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def __init__( self, x, y, width, height, fg=curses.COLOR_BLACK, bg=curses.COLOR_WHITE ):
            self.win = curses.newwin( height, width, y, x )
            self.dimensions = ( x, y, width, height )
            """
            if curses.has_colors():
                color = 1
                curses.init_pair( color, fg, bg )
                self.win.bkgdset( ord(' '), curses.color_pair(color) )
            else:
                self.win.bkgdset( ord(' '), curses.A_BOLD )
            """
            self.erase()
            self.setScrolling()
            self.win.noutrefresh()
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def setTitle( self, title ):
            title = "BitBake %s" % bb.__version__
            self.decoration.setText( 2, 1, title, curses.A_BOLD )
            self.decoration.setText( self.StatusPosition - 8, 1, "Status:", curses.A_BOLD )
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def setStatus(self, status):
            while len(status) < MAXSTATUSLENGTH:
                status = status + " "
            self.decoration.setText( self.StatusPosition, 1, status, curses.A_BOLD )


    #-------------------------------------------------------------------------#
项目:grbl-stream    作者:fragmuffin    | 项目源码 | 文件源码
def render(self, strong=False):
        addstr_params = [self.row, self.col, '[{}]'.format(self.label)]
        if strong:
            addstr_params.append(curses.A_BOLD)
        self.window.addstr(*addstr_params)
项目:grbl-stream    作者:fragmuffin    | 项目源码 | 文件源码
def render(self, strong=False):
        (y, x) = self.window.getmaxyx()
        label_str = " {} ".format(self._label)
        addstr_params = [
            self.row, self.label_col, " {} ".format(self._label),
            curses.color_pair(self.color_index) if curses.has_colors() else 0
        ]

        # heading attributes
        attrs = curses.color_pair(self.color_index) if curses.has_colors() else 0
        if strong:
            attrs |= curses.A_BOLD

        self.window.hline(0, 0, curses.ACS_HLINE, x)
        self.window.addstr(self.row, self.label_col, " {} ".format(self._label), attrs)
项目:aws-ec2rescue-linux    作者:awslabs    | 项目源码 | 文件源码
def _draw_menu(self, screen):
        """
        Given a menu window, draw the rows including the header and the scrollable rows representing menu items.

        Parameters:
            screen (WindowObject): the window that will be drawn to
        """
        # Add the header
        screen.addstr(0, int((curses.COLS - 6) / 2 - len(self.header) / 2),
                      self.header,
                      curses.A_BOLD)

        # Add each item to the menu
        for row in range(1 + (self.max_displayed_rows * (self.current_page - 1)),
                         self.max_displayed_rows + 1 +
                         (self.max_displayed_rows * (self.current_page - 1))):
            # Pad or truncate the module name to 40 characters
            row_item_name = "{:40}".format(str(self._items[row - 1])[:40])
            # Truncate the row's string to the drawable width
            display_str = str(row_item_name + "  " + self._items[row - 1].row_right)[:curses.COLS - 6]
            # Draw the row
            if row + (self.max_displayed_rows * (self.current_page - 1)) == \
                self.current_row + \
                    (self.max_displayed_rows * (self.current_page - 1)):
                # Highlight the item that is currently selected
                screen.addstr(row - (self.max_displayed_rows * (self.current_page - 1)),
                              1,
                              display_str.rstrip(),
                              curses.color_pair(1) | curses.A_BOLD)
            else:
                screen.addstr(row - (self.max_displayed_rows * (self.current_page - 1)),
                              1,
                              display_str)

            # Stop printing items when the end of the drawable space is reached
            if row == self.num_rows:
                break
项目:copycat    作者:LSaldyt    | 项目源码 | 文件源码
def slipnode_name_and_attr(self, slipnode):
        if slipnode.activation == 100:
            return (slipnode.name.upper(), curses.A_STANDOUT)
        if slipnode.activation > 50:
            return (slipnode.name.upper(), curses.A_BOLD)
        else:
            return (slipnode.name.lower(), curses.A_NORMAL)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def star():
    treescrn2.attrset(curses.A_BOLD | curses.A_BLINK)
    set_color(treescrn2, curses.COLOR_YELLOW)

    treescrn2.addch(0, 12, ord('*'))
    treescrn2.standend()

    unset_color(treescrn2)
    treescrn2.refresh()
    w_del_msg.refresh()
    return
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def strng1():
    treescrn2.attrset(curses.A_BOLD | curses.A_BLINK)
    set_color(treescrn2, curses.COLOR_WHITE)

    treescrn2.addch(3, 13, ord('\''))
    treescrn2.addch(3, 12, ord(':'))
    treescrn2.addch(3, 11, ord('.'))

    treescrn2.attroff(curses.A_BOLD | curses.A_BLINK)
    unset_color(treescrn2)

    treescrn2.refresh()
    w_del_msg.refresh()
    return
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def mkpanel(color, rows, cols, tly, tlx):
    win = curses.newwin(rows, cols, tly, tlx)
    pan = panel.new_panel(win)
    if curses.has_colors():
        if color == curses.COLOR_BLUE:
            fg = curses.COLOR_WHITE
        else:
            fg = curses.COLOR_BLACK
        bg = color
        curses.init_pair(color, fg, bg)
        win.bkgdset(ord(' '), curses.color_pair(color))
    else:
        win.bkgdset(ord(' '), curses.A_BOLD)

    return pan
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def next_j(j):
    if j == 0:
        j = 4
    else:
        j -= 1

    if curses.has_colors():
        z = randrange(0, 3)
        color = curses.color_pair(z)
        if z:
            color = color | curses.A_BOLD
        stdscr.attrset(color)

    return j
项目:ascii_qgis    作者:NathanW2    | 项目源码 | 文件源码
def render_map(self):
        y, x = scr.getmaxyx()
        x -= 30

        self.mapwin.clear()
        self.mapwin.box()
        self.mapwin.addstr(0, 2, self.title, curses.A_BOLD)

        height, width = self.mapwin.getmaxyx()
        # Only render the image if we have a open project
        if not self.settings and project:
            self.settings = project.map_settings

        if project:
            settings = self.settings
            data = generate_layers_ascii(self.settings, width, height)
            for row, rowdata in enumerate(data, start=1):
                if row >= height:
                    break

                for col, celldata in enumerate(rowdata, start=1):
                    if col >= width - 1:
                        break

                    value, color = celldata[0], celldata[1]
                    if value == ' ':
                        color = 8
                    if not ascii_mode_enabled:
                        value = ' '

                    if not color_mode_enabled:
                        color = 0

                    self.mapwin.addstr(row, col, value, curses.color_pair(color))

        self.mapwin.refresh()
项目:youtube_watcher    作者:Sjc1000    | 项目源码 | 文件源码
def create_list(self, get_input=True):
        self.screen.clear()
        self.height, self.width = self.screen.getmaxyx()
        self.screen.addstr(self.title.center(self.width),
                           curses.color_pair(1) | curses.A_BOLD)
        self.screen.addstr(self.comment.center(self.width))
        self.draw_items()
        if not get_input:
            return None
        return self.screen.getch()
项目: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
项目:trtop    作者:aol    | 项目源码 | 文件源码
def _print_totals(self, totals, row):
        row += 1
        self._print_line(row, 0, 'Totals:', color=curses.A_BOLD)
        self._print_line(row, 2, "{0} ({1:.2f})".format(totals['syn_count'], totals['syn_rate']), color=curses.A_BOLD)
        self._print_line(row, 6, "{0} ({1:.2f})".format(totals['est_count'], totals['est_rate']), color=curses.A_BOLD)
        self._print_line(row, 8, str(totals['rst_count']), color=curses.A_BOLD)

        row += 1
        self._print_line(row, 0, "")
        return row + 1
项目:YATE    作者:GarethNelson    | 项目源码 | 文件源码
def draw_status(self):
       self.scr.addstr(self.y+1,self.x+1,' '*(self.w-2),curses.color_pair(TOPSTATUS))
       self.scr.addstr(self.y+2,self.x+1,' '*(self.w-2),curses.color_pair(TOPSTATUS))
       self.scr.addstr(self.y+1,self.x+2,'Connection status: ',curses.color_pair(TOPSTATUS))
       if self.client.is_connected():
          self.scr.addstr(self.y+1,self.x+21,'Online ',curses.color_pair(TOPSTATUS_ONLINE)|curses.A_BOLD)
          self.scr.addstr(self.y+1,self.x+28,'Status: %s' % self.get_status_str(),curses.color_pair(TOPSTATUS)|curses.A_BOLD)
          self.scr.addstr(self.y+2,self.x+2,'[Q quit] [V voxel view] [L log view] [H health view] [I inventory view] [/ enter command] [wasd manual move]',curses.color_pair(TOPSTATUS))
       else:
          self.scr.addstr(self.y+1,self.x+21,'Offline',curses.color_pair(TOPSTATUS_OFFLINE)|curses.A_BOLD)
          self.scr.addstr(self.y+2,self.x+2,'Press C to connect and Q to quit',curses.color_pair(TOPSTATUS))
项目:py_wsjtx    作者:teabreakninja    | 项目源码 | 文件源码
def add_cq(self, the_text, colour, loc, country, info):
        self.main_win.addstr("CQ CALLED BY ")
        self.main_win.addstr("{}".format(the_text), curses.color_pair(colour)|curses.A_BOLD)
        self.main_win.addstr(" [{}] {}\n".format(loc, country))
        self.main_win.addstr("  [Call:{}, & Band:{}, Country:{}, & Band:{}]\n".format(
            self.convert(info["call"]),
            self.convert(info["call_band"]),
            self.convert(info["country"]),
            self.convert(info["country_band"])
        ))
        self.main_win.refresh()
        self.stdscr.refresh()
项目: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)
项目:satori-rtm-sdk-python    作者:satori-com    | 项目源码 | 文件源码
def render_chat(users, history, screen, x, y, w, h):
    for (i, a) in enumerate(history[-h:]):
        buffer = []
        if 'user' in a:
            if a['user'] in users:
                user_attr = curses.A_BOLD
            else:
                user_attr = curses.A_NORMAL
            if a['message'].startswith('/me '):
                text = '* {0} {1}'.format(a['user'], a['message'][4:])
                buffer = [
                    ('* ', curses.A_NORMAL),
                    (a['user'], user_attr),
                    (u' {0}'.format(a['message'][4:]), curses.A_NORMAL)]
            else:
                buffer = [
                    (a['user'], user_attr),
                    (u'> {0}'.format(a['message']), curses.A_NORMAL)]
        else:
            buffer = [(u'* {0}'.format(a), curses.A_NORMAL)]
        x_ = x + 1
        for (text, attr) in buffer:
            if not isinstance(text, six.binary_type):
                text = text.encode('utf8')
            screen.addstr(y + 1 + i, x_, text, attr)
            x_ += len(text.decode('utf8'))
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def getStats(scr):
    curses.init_pair(9,  curses.COLOR_WHITE,  curses.COLOR_BLACK)
    curses.init_pair(10, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    curses.init_pair(11, curses.COLOR_RED,    curses.COLOR_BLACK)
    curses.init_pair(12, curses.COLOR_GREEN,  curses.COLOR_BLACK)
    (maxY, maxX) = scr.getmaxyx()
    while 1:
        try:
            display_time(scr)
            display_loadavg(scr)
            display_header(scr)
            #write(scr, 3, 0, '%-4s %-20s %-15s %-40s%s' % ('Slot', 'Remote Host', 'State', 'Filename', ' '*(maxX-83)), curses.A_BOLD)
            cnt = 5
            try:
                for i in os.listdir(DISTCC_DIR+'/state'):
                    data = struct.unpack('@iLL128s128siiP', open(DISTCC_DIR+'/state/'+i).readline().strip())
                    file = data[3].split('\x00')[0] or 'None'
                    host = data[4].split('\x00')[0] or 'None'
                    slot = int(data[5])
                    stte = states[int(data[6])]
                    scr.move(cnt,0)
                    scr.clrtoeol()
                    if 'None' not in (file, host):
                        write(scr, cnt, 0, '%s' % slot, curses.color_pair(9))
                        write(scr, cnt, 5, '%s' % host, curses.color_pair(9))
                        if int(data[6]) in (2,3):
                            write(scr, cnt, 25, '%s ' % (stte), curses.color_pair(10))
                        elif int(data[6]) in (0,1):
                            write(scr, cnt, 25, '%s ' % (stte), curses.color_pair(11))
                        elif int(data[6]) in (4,5):
                            write(scr, cnt, 25, '%s ' % (stte), curses.color_pair(12))
                        elif int(data[6]) in (6,7):
                            write(scr, cnt, 25, '%s ' % (stte), curses.color_pair(12)|curses.A_BOLD)
                        else: write(scr, cnt, 25, '%s ' % (stte))
                        write(scr, cnt, 45, '%s' % file, curses.color_pair(9))
                        cnt += 1
            except struct.error: pass
            except IOError: pass
            scr.refresh()
            time.sleep(0.75)
            scr.erase()
            scr.move(0,0)
        except KeyboardInterrupt:
            sys.exit(-1)
项目:new    作者:atlj    | 项目源码 | 文件源码
def create(liste):
    screen = curses.initscr()
    curses.start_color()
    curses.init_pair(1,curses.COLOR_RED, curses.COLOR_WHITE)
    s = curses.color_pair(1)
    h = curses.A_NORMAL
    pos = 0

    while 1:
        curses.noecho()
        screen.clear()
        screen.border(0)
        screen.keypad(True)
        screen.addstr(1,2,"(w)Yukari/Up (s)Asagi/Down (e)Sec", curses.A_BOLD)
        a = 0
        b = 4
        c = 3
        for oge in liste:
            if int(a/15)<1:
                if pos == a:
                    screen.addstr(b, 4, "".join(liste[a]), s)
                else:
                    screen.addstr(b, 4, "".join(liste[a]), h)
            else:
                c = c + 1
                if pos == a:
                    screen.addstr(c, 23, "".join(liste[a]), s)
                else:
                    screen.addstr(c, 23, "".join(liste[a]), h)


            a = a + 1
            b = b + 1
        screen.refresh()
        try:
            inp = screen.getkey(1,1)

            if inp == 'e':
                screen.refresh()
                curses.echo()
                screen.keypad(False)
                curses.endwin()
                break
            if inp == 'w':
                if pos > 0:
                    pos = pos - 1
                else:
                    pos = len(liste)-1
            if inp== 's':
                if pos < len(liste)-1:
                    pos = pos + 1
                else:
                    pos=0
        except Exception as e:
            pass
    return pos
项目:hurt    作者:io-digital    | 项目源码 | 文件源码
def update_ui_worker():
    global main_start, total_seconds, _timeout, hits, workers, status, test_number, total_seconds, test_start, \
        test_stop, requests_handled, test_seconds, _tolerance, _url, break_out

    while True:

        rc = utils.render_result_codes(result_codes, timeout_count, connection_error_count)

        if not q.empty() and main_start:
            total_seconds = time.time()-main_start

        screen.addstr(1, 2, 'PAIN TOLERANCE on %s' % _url, curses.color_pair(3)|curses.A_BOLD)

        screen.addstr(3, 2, 'Status: %s                             ' % status)

        screen.addstr(5, 2, 'Trying %s hits with %s workers          ' % (hits, workers))
        screen.addstr(6, 2, 'Timeout: %s seconds                     ' % (_timeout,))
        screen.addstr(6, 40, 'Tolerance: %s errors                   ' % (_tolerance,))

        screen.addstr(7, 2, 'Active Workers: %s       ' % (threading.active_count() - 2))
        screen.addstr(7, 40, 'Queue: %s        ' % q.qsize())

        if test_start is None:
            test_seconds = 0

        else:
            if test_stop is None:
                test_seconds = time.time() - test_start
            else:
                test_seconds = test_stop - test_start

        screen.addstr(9, 2, 'Test Seconds: %.2f         ' % test_seconds)
        screen.addstr(9, 40, 'Requests handled: %s      ' % requests_handled)

        if result_codes and test_seconds and '200 OK' in result_codes:
            screen.addstr(10, 2, 'Requests per second: %.2f      ' % (int(result_codes['200 OK']) / test_seconds), )

        if durations:
            screen.addstr(10, 40, 'Average Request: %.2f seconds     ' % (reduce(lambda x, y: x + y, durations) / len(durations)))

        screen.addstr(12, 2, rc)

        screen.refresh()
        time.sleep(0.1)