当前位置: 首页>>代码示例>>Python>>正文


Python curses.color_pair方法代码示例

本文整理汇总了Python中curses.color_pair方法的典型用法代码示例。如果您正苦于以下问题:Python curses.color_pair方法的具体用法?Python curses.color_pair怎么用?Python curses.color_pair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在curses的用法示例。


在下文中一共展示了curses.color_pair方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print_char

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def print_char(self, char, color_code, row=None, col=None):
        """
        Print one char to the screen with coloration.

        In compat_debug this will just append the char to stdout. This checks for silent mode
        :param char: The character to print
        :param color_code: The colorcode 1234 = RGYB
        :param row: The y pos used with curses
        :param col: The x pos used with curses
        """

        if self.silent:
            return 42

        if self.compat_debug:
            if not color_code:
                # Zero is the regular print, but the code 33 will draw black over black and we dont want that
                print(char, end='')
            else:
                print('\033[0;3', color_code, 'm', char, '\033[0m', sep='', end='')
        else:
            self.win_program.addstr(row, col, char, curses.color_pair(color_code)) 
开发者ID:aaronjanse,项目名称:asciidots,代码行数:24,代码来源:__main__.py

示例2: init_head

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def init_head(self):
        title = "BaiduFM"
        try:
            user_counts = self.api.get_fm_user_counts()
            user_name = ' / ' + (user_counts['user_name'] or "Visitor")
            total_listen = "Listen: %s" % user_counts['counts']['total_listen']
            like_songs = "Like: %s" % user_counts['counts']['like_songs']
            dislike_songs = "Dislike: %s" % user_counts['counts']['dislike_songs']
            if user_counts['user_name'] and self.login_channel:
                self.login_channel.extend(self.channels)
                self.channels, self.login_channel = self.login_channel, None
        except Exception as e:
            fm_log(logger, "INIT HEAD: %s", str(e.args))
            return

        len_x = len(title)
        self.head_win.addstr(0, 0, title, curses.color_pair(1))
        self.head_win.addstr(0, len_x, user_name, curses.color_pair(2))
        len_x += len(user_name) + 2
        self.head_win.addstr(0, len_x, total_listen, curses.color_pair(3))
        len_x += len(total_listen) + 2
        self.head_win.addstr(0, len_x, like_songs, curses.color_pair(4))
        len_x += len(like_songs) + 2
        self.head_win.addstr(0, len_x, dislike_songs, curses.color_pair(5))
        self.head_win.noutrefresh() 
开发者ID:tdoly,项目名称:baidufm-py,代码行数:27,代码来源:fm_cli.py

示例3: draw

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def draw(self):
        i = 0
        while i < self.height:
            if self.win_y + i < len(self.token_lines):
                self.print_line(i)
            else:
                # force to clear the entire line
                self.screen.move(i, 0)
            self.screen.clrtoeol()
            i += 1

        # Print the scroll cursor on the right. It uses utf-8 block characters.

        y = self.get_y_scroll()
        i = y % 8
        y = y // 8

        self.screen.insstr(y, self.width - 1,
            self.cursor_position_utf8[i],
            color_pair(COLOR_SCROLL_CURSOR))

        if i != 0 and y + 1 < self.height:
            self.screen.insstr(y + 1, self.width - 1,
                self.cursor_position_utf8[i],
                color_pair(COLOR_SCROLL_CURSOR) | A_REVERSE) 
开发者ID:plasma-disassembler,项目名称:plasma,代码行数:27,代码来源:listbox.py

示例4: _screen_draw_text_line

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def _screen_draw_text_line(self, row, line, attr=curses.A_NORMAL, color=None):
    """Render a line of text on the screen.

    Args:
      row: (int) Row index.
      line: (str) The line content.
      attr: curses font attribute.
      color: (str) font foreground color name.

    Raises:
      TypeError: If row is not of type int.
    """

    if not isinstance(row, int):
      raise TypeError("Invalid type in row")

    if len(line) > self._max_x:
      line = line[:self._max_x]

    color_pair = (self._default_color_pair if color is None else
                  self._color_pairs[color])

    self._stdscr.addstr(row, 0, line, color_pair | attr)
    self._screen_refresh() 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:curses_ui.py

示例5: draw_window

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def draw_window(state, window):
    window.clear()
    window.refresh()
    win_header = curses.newwin(2, 76, 0, 0)

    unit = 'BTC'
    if 'testnet' in state:
        if state['testnet']:
            unit = 'TNC'

    if 'wallet' in state:
        if 'balance' in state:
            balance_string = "balance: " + "%0.8f" % state['balance'] + " " + unit
            if 'unconfirmedbalance' in state:
                if state['unconfirmedbalance'] != 0:
                    balance_string += " (+" + "%0.8f" % state['unconfirmedbalance'] + " unconf)"
            window.addstr(0, 1, balance_string, curses.A_BOLD)

        draw_transactions(state)

    else:
        win_header.addstr(0, 1, "no wallet information loaded", curses.A_BOLD + curses.color_pair(3))
        win_header.addstr(1, 1, "loading... (is -disablewallet on?)", curses.A_BOLD)

    win_header.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:27,代码来源:wallet.py

示例6: draw_transactions

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def draw_transactions(state):
    window_height = state['y'] - 3
    win_transactions = curses.newwin(window_height, 76, 2, 0)

    win_transactions.addstr(0, 1, "transactions:                               (UP/DOWN: scroll, ENTER: view)", curses.A_BOLD + curses.color_pair(5))

    offset = state['wallet']['offset']

    for index in range(offset, offset+window_height-1):
        if index < len(state['wallet']['view_string']):
                condition = (index == offset+window_height-2) and (index+1 < len(state['wallet']['view_string']))
                condition = condition or ( (index == offset) and (index > 0) )

                if condition:
                    win_transactions.addstr(index+1-offset, 1, "...")
                else:
                    win_transactions.addstr(index+1-offset, 1, state['wallet']['view_string'][index])

                if index == (state['wallet']['cursor']*4 + 1):
                    win_transactions.addstr(index+1-offset, 1, ">", curses.A_REVERSE + curses.A_BOLD)

    win_transactions.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:24,代码来源:wallet.py

示例7: draw_window

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def draw_window(state):
    win_footer = curses.newwin(1, 76, state['y']-1, 0)

    color = curses.color_pair(1)
    if 'testnet' in state:
        if state['testnet']:
            color = curses.color_pair(2)

    win_footer.addstr(0, 1, "ncurses", color + curses.A_BOLD)

    x = 10
    for mode_string in g.modes:
        modifier = curses.A_BOLD
        if state['mode'] == mode_string:
            modifier += curses.A_REVERSE
        win_footer.addstr(0, x, mode_string[0].upper(), modifier + curses.color_pair(5)) 
        win_footer.addstr(0, x+1, mode_string[1:], modifier)
        x += len(mode_string) + 2

    win_footer.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:22,代码来源:footer.py

示例8: draw_window

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def draw_window(state, window):
    window.clear()
    window.refresh()

    win_header = curses.newwin(3, 75, 0, 0)

    if 'peerinfo' in state:
        win_header.addstr(0, 1, "connected peers: " + str(len(state['peerinfo'])).ljust(10) + "                             (UP/DOWN: scroll)", curses.A_BOLD)
        win_header.addstr(2, 1, "  Node IP              Version        Recv      Sent         Time  Height", curses.A_BOLD + curses.color_pair(5))
        draw_peers(state)

    else:
        win_header.addstr(0, 1, "no peer information loaded", curses.A_BOLD + curses.color_pair(3))
        win_header.addstr(1, 1, "loading...", curses.A_BOLD)

    win_header.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:18,代码来源:peers.py

示例9: draw_window

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def draw_window(state, window):
    window.clear()
    window.refresh()

    win_header = curses.newwin(3, 75, 0, 0)

    if 'chaintips' in state:
        win_header.addstr(0, 1, "chain tips: " + str(len(state['chaintips'])).ljust(10) + "                 (UP/DOWN: scroll, F: refresh)", curses.A_BOLD)
        win_header.addstr(1, 1, "key: Active/Invalid/HeadersOnly/ValidFork/ValidHeaders", curses.A_BOLD)
        win_header.addstr(2, 1, "height length status 0-prefix hash", curses.A_BOLD + curses.color_pair(5))
        draw_tips(state)

    else:
        win_header.addstr(0, 1, "no chain tip information loaded", curses.A_BOLD + curses.color_pair(3))
        win_header.addstr(1, 1, "loading... (press F to try again)", curses.A_BOLD)

    win_header.refresh() 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:19,代码来源:forks.py

示例10: findPair

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def findPair(self, caller, request='DEFAULT'):
        if not curses.has_colors() or npysGlobalOptions.DISABLE_ALL_COLORS:
            return False

        if request=='DEFAULT':
            request = caller.color
        # Locate the requested colour pair.  Default to default if not found.
        try:
            pair = self._defined_pairs[self._names[request]]
        except:
            pair = self._defined_pairs[self._names['DEFAULT']]

        # now make the actual attribute
        color_attribute = curses.color_pair(pair[0])
        
        return color_attribute 
开发者ID:hexway,项目名称:apple_bleee,代码行数:18,代码来源:npysThemeManagers.py

示例11: init_layout

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def init_layout(self):
        """Initialize the each windows with their size and shape"""
        self.height, self.width = self.window.getmaxyx()

        # Title section
        self.window.addstr(0, 0, '[awesome-{}] Find awesome things!'.format(self.awesome_title), curses.color_pair(1))
        self.window.hline(1, 0, curses.ACS_HLINE, self.width)

        # Search result section
        self.result_window = curses.newwin(self.height - 4, self.width, 2, 0)
        self.result_window.keypad(True)

        # Search bar section
        self.window.hline(self.height - 2, 0, curses.ACS_HLINE, self.width)
        self.window.addch(self.height - 1, 0, '>')
        self.search_window = curses.newwin(1, self.width - 1, self.height - 1, 2)
        self.search_window.keypad(True)

        self.window.refresh() 
开发者ID:mingrammer,项目名称:awesome-finder,代码行数:21,代码来源:tui.py

示例12: display

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def display(self):
        """Display the found awesome content on result window"""
        self.result_window.erase()
        for idx, val in enumerate(self.matched_blocks[self.top:self.top + self.max_lines]):
            if val['type'] == 'category':
                # Highlight the current cursor line
                if idx == self.current:
                    self.result_window.addstr(idx, 0, shorten(val['line'], self.width, placeholder='...'),
                                              curses.color_pair(2))
                else:
                    self.result_window.addstr(idx, 0, shorten(val['line'], self.width, placeholder='...'),
                                              curses.color_pair(1))
            elif val['type'] == 'awesome':
                # Highlight the current cursor line
                if idx == self.current:
                    self.result_window.addstr(idx, 2, shorten(val['line'], self.width - 3, placeholder='...'),
                                              curses.color_pair(2))
                else:
                    self.result_window.addstr(idx, 2, shorten(val['line'], self.width - 3, placeholder='...'))
        self.result_window.refresh() 
开发者ID:mingrammer,项目名称:awesome-finder,代码行数:22,代码来源:tui.py

示例13: plot

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def plot(self, progress):
        """
        Actually fill the progress bars accordingly
        """
        if progress < self.prevprogress:
            self.donedrives += 1
        self.prevprogress = progress

        progress = progress + self.donedrives
        totalbar = int((progress/self.drives)*((self.width-2)/2))
        currentbar = int(progress*((self.width-2)/2)) % (self.width/2)

        self.preptotal()
        self.prepcurrent()

        self.totalbar.addstr(1, 1, "-"*(totalbar-2), curses.color_pair(2))
        self.currentbar.addstr(1, 1, "-"*(currentbar-2), curses.color_pair(2))

        self.refresh() 
开发者ID:AonCyberLabs,项目名称:EvilAbigail,代码行数:21,代码来源:evilmaid.py

示例14: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def __init__(self, ts, injector, tests, do_tick, disassembler=disas_capstone):
        self.ts = ts;
        self.injector = injector
        self.T = tests
        self.gui_thread = None
        self.do_tick = do_tick
        self.ticks = 0

        self.last_ins_count = 0
        self.delta_log = deque(maxlen=self.RATE_Q)
        self.time_log = deque(maxlen=self.RATE_Q)

        self.disas = disassembler

        self.stdscr = curses.initscr()
        curses.start_color()

        # doesn't work
        # self.orig_colors = [curses.color_content(x) for x in xrange(256)]

        curses.use_default_colors()
        curses.noecho()
        curses.cbreak()
        curses.curs_set(0)
        self.stdscr.nodelay(1)

        self.sx = 0
        self.sy = 0

        self.init_colors()

        self.stdscr.bkgd(curses.color_pair(self.WHITE))

        self.last_time = time.time() 
开发者ID:Battelle,项目名称:sandsifter,代码行数:36,代码来源:sifter.py

示例15: gray

# 需要导入模块: import curses [as 别名]
# 或者: from curses import color_pair [as 别名]
def gray(self, scale):
        if curses.can_change_color():
            return curses.color_pair(self.GRAY_BASE + int(round(scale * (self.GRAYS - 1))))
        else:
            return curses.color_pair(self.WHITE) 
开发者ID:Battelle,项目名称:sandsifter,代码行数:7,代码来源:sifter.py


注:本文中的curses.color_pair方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。