當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。