本文整理汇总了Python中curses.start_color方法的典型用法代码示例。如果您正苦于以下问题:Python curses.start_color方法的具体用法?Python curses.start_color怎么用?Python curses.start_color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curses
的用法示例。
在下文中一共展示了curses.start_color方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def __init__(self, enable=True):
self.enable = enable
if not self.enable:
return
self.logger = logging.getLogger('trader-logger')
self.stdscr = curses.initscr()
self.pad = curses.newpad(23, 120)
self.order_pad = curses.newpad(10, 120)
self.timestamp = ""
self.last_order_update = 0
curses.start_color()
curses.noecho()
curses.cbreak()
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN)
curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_RED)
self.stdscr.keypad(1)
self.pad.addstr(1, 0, "Waiting for a trade...")
示例2: init_curses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def init_curses():
window = curses.initscr()
curses.noecho() # prevents user input from being echoed
curses.curs_set(0) # make cursor invisible
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK)
window.timeout(50)
window.keypad(1) # interpret arrow keys, etc
return window
示例3: wrapper_fork
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def wrapper_fork(call_function, reset=True):
pid = os.fork()
if pid:
# Parent
os.waitpid(pid, 0)
if reset:
external_reset()
else:
locale.setlocale(locale.LC_ALL, '')
_SCREEN = curses.initscr()
try:
curses.start_color()
except:
pass
_SCREEN.keypad(1)
curses.noecho()
curses.cbreak()
curses.def_prog_mode()
curses.reset_prog_mode()
return_code = call_function(_SCREEN)
_SCREEN.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
sys.exit(0)
示例4: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def __init__(self):
#curses.use_default_colors()
self.define_colour_numbers()
self._defined_pairs = {}
self._names = {}
try:
self._max_pairs = curses.COLOR_PAIRS - 1
do_color = True
except AttributeError:
# curses.start_color has failed or has not been called
do_color = False
# Disable all color use across the application
disableColor()
if do_color and curses.has_colors():
self.initialize_pairs()
self.initialize_names()
示例5: init_curses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def init_curses(self):
"""Setup the curses"""
self.window = curses.initscr()
self.height, self.width = self.window.getmaxyx()
if self.width < 60:
self.too_small = True
return
self.window.keypad(True)
# self.window.nodelay(True)
curses.noecho()
curses.curs_set(False)
curses.cbreak()
curses.start_color()
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_CYAN)
示例6: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def __init__(self, scanner):
self.scanner = scanner
self.screen = curses.initscr()
curses.noecho()
curses.cbreak()
self.screen.keypad(1)
self.screen.scrollok(True)
self.x, self.y = self.screen.getmaxyx()
curses.start_color()
curses.use_default_colors()
try:
self.screen.curs_set(0)
except:
try:
self.screen.curs_set(1)
except:
pass
示例7: _init_curses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def _init_curses(self):
self.stdscr = curses.initscr()
self.stdscr.keypad(1)
curses.noecho()
curses.cbreak()
curses.curs_set(0)
curses.start_color()
try:
curses.init_pair(1, curses.COLOR_BLACK, 197) # 接近机核主题的颜色
except:
# 树莓派 windows无法使用机核like色
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_RED)
curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK)
self.stdscr.bkgd(curses.color_pair(2))
self.stdscr.timeout(100)
self.stdscr.refresh()
示例8: setup
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def setup(self):
curses.start_color()
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
curses.cbreak()
curses.echo()
lines, cols = self.stdscr.getmaxyx()
self.logwin = self.stdscr.subwin(lines - 2, cols, 0, 0)
self.sepwin = self.stdscr.subwin(1, cols, lines - 2, 0)
self.cmdwin = self.stdscr.subwin(1, cols, lines - 1, 0)
self.logwin.scrollok(True)
self.sepwin.bkgd(curses.color_pair(1))
self.sepwin.refresh()
示例9: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def __init__(self, hosts):
self.stdscr = curses.initscr()
curses.start_color()
self.height, self.width = self.stdscr.getmaxyx()
curses.cbreak()
curses.noecho()
self.stdscr.keypad(1)
self.hosts = hosts
self.format = (
'%(hostname)10.10s '
'%(pid)7.7s '
'%(ppid)7.7s '
'%(pcpu)6.6s '
'%(rss)5.5s '
'%(command)20s'
)
示例10: setup_curses
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def setup_curses():
"""Setup terminal/curses state."""
window = curses.initscr()
curses.noecho()
window = curses.newwin(
WINDOW_HEIGHT + (VERT_PADDING * 2),
WINDOW_WIDTH + (HORIZ_PADDING * 2),
WINDOW_TOP - VERT_PADDING,
WINDOW_LEFT - HORIZ_PADDING,
)
curses.start_color()
global _COLOR_PAIRS
_COLOR_PAIRS = {}
for i, (k, v) in enumerate(COLOR_MAP.items(), 1):
curses.init_pair(i, v, curses.COLOR_BLACK)
_COLOR_PAIRS[k] = curses.color_pair(i)
return window
示例11: _initialize_colors
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def _initialize_colors(self):
"""Function for initialzing curses colors. Called when CUI is first created.
"""
# Start colors in curses
curses.start_color()
curses.init_pair(WHITE_ON_BLACK, curses.COLOR_WHITE, curses.COLOR_BLACK)
curses.init_pair(BLACK_ON_GREEN, curses.COLOR_BLACK, curses.COLOR_GREEN)
curses.init_pair(BLACK_ON_WHITE, curses.COLOR_BLACK, curses.COLOR_WHITE)
curses.init_pair(WHITE_ON_RED, curses.COLOR_WHITE, curses.COLOR_RED)
curses.init_pair(YELLOW_ON_BLACK, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(RED_ON_BLACK, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(CYAN_ON_BLACK, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(MAGENTA_ON_BLACK, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
curses.init_pair(GREEN_ON_BLACK, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(BLUE_ON_BLACK, curses.COLOR_BLUE, curses.COLOR_BLACK)
示例12: _init_screen
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def _init_screen() -> 'curses._CursesWindow':
# set the escape delay so curses does not pause waiting for sequences
if sys.version_info >= (3, 9): # pragma: no cover
curses.set_escdelay(25)
else: # pragma: no cover
os.environ.setdefault('ESCDELAY', '25')
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
# <enter> is not transformed into '\n' so it can be differentiated from ^J
curses.nonl()
# ^S / ^Q / ^Z / ^\ are passed through
curses.raw()
stdscr.keypad(True)
with contextlib.suppress(curses.error):
curses.start_color()
curses.use_default_colors()
return stdscr
示例13: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [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()
示例14: start
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def start(self, no_delay):
self.window = curses.initscr()
curses.start_color()
curses.use_default_colors()
curses.noecho()
curses.cbreak()
curses.curs_set(0)
self.window.nodelay(no_delay)
self.init_colors()
self.window.bkgd(curses.color_pair(self.WHITE))
locale.setlocale(locale.LC_ALL, '') # set your locale
self.code = locale.getpreferredencoding()
示例15: setup
# 需要导入模块: import curses [as 别名]
# 或者: from curses import start_color [as 别名]
def setup(self, stdscr):
fm_log(logger, 'init baidufm fm cli')
self.stdscr = stdscr
# init color
curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_BLACK)
curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
curses.init_pair(7, curses.COLOR_BLACK, curses.COLOR_GREEN)
curses.init_pair(8, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
curses.init_pair(9, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(10, curses.COLOR_RED, curses.COLOR_BLACK)
curses.start_color()
for i in range(0, curses.COLORS):
if i < 10:
continue
curses.init_pair(i + 1, curses.COLOR_BLACK, i)
self.player = choose_player()(self.footer, self.event)
self.stdscr.nodelay(0)
self.setup_and_draw_screen()
self.run()