本文整理汇总了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]
示例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"]
示例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
示例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)
示例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()