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


Python curses.A_BLINK属性代码示例

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


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

示例1: _screen_color_init

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_BLINK [as 别名]
def _screen_color_init(self):
    """Initialization of screen colors."""
    curses.start_color()
    curses.use_default_colors()
    self._color_pairs = {}
    color_index = 0

    # Prepare color pairs.
    for fg_color in self._FOREGROUND_COLORS:
      for bg_color in self._BACKGROUND_COLORS:
        color_index += 1
        curses.init_pair(color_index, self._FOREGROUND_COLORS[fg_color],
                         self._BACKGROUND_COLORS[bg_color])

        color_name = fg_color
        if bg_color != "transparent":
          color_name += "_on_" + bg_color

        self._color_pairs[color_name] = curses.color_pair(color_index)

    # Try getting color(s) available only under 256-color support.
    try:
      color_index += 1
      curses.init_pair(color_index, 245, -1)
      self._color_pairs[cli_shared.COLOR_GRAY] = curses.color_pair(color_index)
    except curses.error:
      # Use fall-back color(s):
      self._color_pairs[cli_shared.COLOR_GRAY] = (
          self._color_pairs[cli_shared.COLOR_GREEN])

    # A_BOLD or A_BLINK is not really a "color". But place it here for
    # convenience.
    self._color_pairs["bold"] = curses.A_BOLD
    self._color_pairs["blink"] = curses.A_BLINK
    self._color_pairs["underline"] = curses.A_UNDERLINE

    # Default color pair to use when a specified color pair does not exist.
    self._default_color_pair = self._color_pairs[cli_shared.COLOR_WHITE] 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:40,代码来源:curses_ui.py

示例2: _screen_init

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_BLINK [as 别名]
def _screen_init(self):
    """Screen initialization.

    Creates curses stdscr and initialize the color pairs for display.
    """

    self._stdscr = curses.initscr()
    self._command_window = None

    # Prepare color pairs.
    curses.start_color()

    self._color_pairs = {}
    color_index = 0

    for fg_color in self._FOREGROUND_COLORS:
      for bg_color in self._BACKGROUND_COLORS:

        color_index += 1
        curses.init_pair(color_index, self._FOREGROUND_COLORS[fg_color],
                         self._BACKGROUND_COLORS[bg_color])

        color_name = fg_color
        if bg_color != "black":
          color_name += "_on_" + bg_color

        self._color_pairs[color_name] = curses.color_pair(color_index)

    # A_BOLD or A_BLINK is not really a "color". But place it here for
    # convenience.
    self._color_pairs["bold"] = curses.A_BOLD
    self._color_pairs["blink"] = curses.A_BLINK
    self._color_pairs["underline"] = curses.A_UNDERLINE

    # Default color pair to use when a specified color pair does not exist.
    self._default_color_pair = self._color_pairs["white"] 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:38,代码来源:curses_ui.py

示例3: getstr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_BLINK [as 别名]
def getstr(w, y, x):
    window = curses.newwin(1, w, y, x)

    result = ""
    window.addstr("> ", curses.A_BOLD + curses.A_BLINK)
    window.refresh()
    window.keypad(True)

    while True:
        try:
            character = -1
            while (character < 0):
                character = window.getch()
        except:
            break

        if character == curses.KEY_ENTER or character == ord('\n'):
            break

        elif character == curses.KEY_BACKSPACE or character == 127:
            if len(result):
                window.move(0, len(result)+1)
                window.delch()
                result = result[:-1]
                continue

        elif (137 > character > 31 and len(result) < w-3): # ascii range TODO: unicode
                result += chr(character)
                window.addstr(chr(character))

    window.addstr(0, 0, "> ", curses.A_BOLD + curses.color_pair(3))
    window.refresh()

    window.keypad(False)
    return result 
开发者ID:esotericnonsense,项目名称:bitcoind-ncurses,代码行数:37,代码来源:getstr.py

示例4: _setattr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_BLINK [as 别名]
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) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:38,代码来源:curses_display.py

示例5: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_BLINK [as 别名]
def main(argv):
    """ The main top entry point and loop."""

    options, args = parse_cmdline(argv)
    CONFIGURATION['refresh_interval'] = float(options.delay)

    try:
        screen = curses.initscr()
        init_screen()
        atexit.register(curses.endwin)
        screen.keypad(1)     # parse keypad control sequences

        # Curses colors
        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN) # header
        curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_CYAN)  # focused header / line
        curses.init_pair(3, curses.COLOR_WHITE, -1)  # regular
        curses.init_pair(4, curses.COLOR_CYAN,  -1)  # tree

        #height,width = screen.getmaxyx()
        #signal.signal(signal.SIGINT, signal_handler)
        #screen.addstr(height - 1, 0, "position string", curses.A_BLINK)

        while True:
            #screen.timeout(0)
            processes = get_all_process()
            memory = get_memswap_info()
            display(screen, header(processes, memory), True)

            sleep_start = time.time()
            #while CONFIGURATION['pause_refresh'] or time.time() < sleep_start + CONFIGURATION['refresh_interval']:
            while CONFIGURATION['pause_refresh'] or time.time() < sleep_start + CONFIGURATION['refresh_interval']:
                if CONFIGURATION['pause_refresh']:
                    to_sleep = -1
                else:
                    to_sleep = int((sleep_start + CONFIGURATION['refresh_interval'] - time.time())*1000)

                ret = event_listener(screen, to_sleep)
                if ret == 2:
                    display(screen, header(processes, memory), True)

    except KeyboardInterrupt:
        pass
    finally:
        do_finish() 
开发者ID:soarpenguin,项目名称:python-scripts,代码行数:46,代码来源:top.py


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