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


Python curses.COLORS属性代码示例

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


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

示例1: initscr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def initscr():
    import _curses, curses
    # we call setupterm() here because it raises an error
    # instead of calling exit() in error cases.
    setupterm(term=_os.environ.get("TERM", "unknown"),
              fd=_sys.__stdout__.fileno())
    stdscr = _curses.initscr()
    for key, value in _curses.__dict__.items():
        if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
            setattr(curses, key, value)

    return stdscr

# This is a similar wrapper for start_color(), which adds the COLORS and
# COLOR_PAIRS variables which are only available after start_color() is
# called. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:__init__.py

示例2: stdscr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def stdscr():
    with patch('curses.initscr'),               \
            patch('curses.echo'),               \
            patch('curses.flash'),              \
            patch('curses.endwin'),             \
            patch('curses.newwin'),             \
            patch('curses.noecho'),             \
            patch('curses.cbreak'),             \
            patch('curses.doupdate'),           \
            patch('curses.nocbreak'),           \
            patch('curses.curs_set'),           \
            patch('curses.init_pair'),          \
            patch('curses.color_pair'),         \
            patch('curses.has_colors'),         \
            patch('curses.start_color'),        \
            patch('curses.use_default_colors'):
        out = MockStdscr(nlines=40, ncols=80, x=0, y=0)
        curses.initscr.return_value = out
        curses.newwin.side_effect = lambda *args: out.derwin(*args)
        curses.color_pair.return_value = 23
        curses.has_colors.return_value = True
        curses.ACS_VLINE = 0
        curses.COLORS = 256
        curses.COLOR_PAIRS = 256
        yield out 
开发者ID:michael-lazar,项目名称:rtv,代码行数:27,代码来源:conftest.py

示例3: setup

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [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() 
开发者ID:tdoly,项目名称:baidufm-py,代码行数:29,代码来源:fm_cli.py

示例4: start_color

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def start_color():
    import _curses, curses
    retval = _curses.start_color()
    if hasattr(_curses, 'COLORS'):
        curses.COLORS = _curses.COLORS
    if hasattr(_curses, 'COLOR_PAIRS'):
        curses.COLOR_PAIRS = _curses.COLOR_PAIRS
    return retval

# Import Python has_key() implementation if _curses doesn't contain has_key() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:__init__.py

示例5: setup

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def setup(stdscr):
    # curses
    curses.use_default_colors()
    curses.start_color()
    curses.use_default_colors()
    for i in range(0, curses.COLORS):
        curses.init_pair(i + 1, i, -1)
    curses.curs_set(False)
    stdscr.timeout(0)

    # prepare input thread mechanisms
    curses_lock = Lock()
    input_queue = Queue()
    quit_event = Event()
    return (curses_lock, input_queue, quit_event) 
开发者ID:trehn,项目名称:termtrack,代码行数:17,代码来源:curses.py

示例6: check_theme

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def check_theme(theme):
        """
        Check if the given theme is compatible with the terminal
        """
        terminal_colors = curses.COLORS if curses.has_colors() else 0

        if theme.required_colors > terminal_colors:
            return False
        elif theme.required_color_pairs > curses.COLOR_PAIRS:
            return False
        else:
            return True 
开发者ID:tildeclub,项目名称:ttrv,代码行数:14,代码来源:terminal.py

示例7: set_theme

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def set_theme(self, theme=None):
        """
        Check that the terminal supports the provided theme, and applies
        the theme to the terminal if possible.

        If the terminal doesn't support the theme, this falls back to the
        default theme. The default theme only requires 8 colors so it
        should be compatible with any terminal that supports basic colors.
        """

        terminal_colors = curses.COLORS if curses.has_colors() else 0
        default_theme = Theme(use_color=bool(terminal_colors))

        if theme is None:
            theme = default_theme

        elif theme.required_color_pairs > curses.COLOR_PAIRS:
            _logger.warning(
                'Theme `%s` requires %s color pairs, but $TERM=%s only '
                'supports %s color pairs, switching to default theme',
                theme.name, theme.required_color_pairs, self._term,
                curses.COLOR_PAIRS)
            theme = default_theme

        elif theme.required_colors > terminal_colors:
            _logger.warning(
                'Theme `%s` requires %s colors, but $TERM=%s only '
                'supports %s colors, switching to default theme',
                theme.name, theme.required_colors, self._term,
                curses.COLORS)
            theme = default_theme

        theme.bind_curses()
        self.theme = theme

        # Apply the default color to the whole screen
        self.stdscr.bkgd(str(' '), self.attr('Normal')) 
开发者ID:tildeclub,项目名称:ttrv,代码行数:39,代码来源:terminal.py

示例8: start

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def start(self):
        """
        Initialize the screen and input mode.
        """
        assert self._started == False

        self.s = curses.initscr()
        self.has_color = curses.has_colors()
        if self.has_color:
            curses.start_color()
            if curses.COLORS < 8:
                # not colourful enough
                self.has_color = False
        if self.has_color:
            try:
                curses.use_default_colors()
                self.has_default_colors=True
            except _curses.error:
                self.has_default_colors=False
        self._setup_colour_pairs()
        curses.noecho()
        curses.meta(1)
        curses.halfdelay(10) # use set_input_timeouts to adjust
        self.s.keypad(0)
        
        if not self._signal_keys_set:
            self._old_signal_keys = self.tty_signal_keys()

        super(Screen, self).start() 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:31,代码来源:curses_display.py

示例9: init_color

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def init_color(self, color: Color) -> None:
        if curses.can_change_color():
            n = min(self.colors.values(), default=256) - 1
            self.colors[color] = n
            curses.init_color(n, *_color_to_curses(color))
        elif curses.COLORS >= 256:
            self.colors[color] = color_kd.nearest(color, color_kd.make_256())
        else:
            self.colors[color] = -1 
开发者ID:asottile,项目名称:babi,代码行数:11,代码来源:color_manager.py

示例10: _curses_start_color

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def _curses_start_color(self):
        curses.COLORS = self._n_colors 
开发者ID:asottile,项目名称:babi,代码行数:4,代码来源:conftest.py

示例11: stdscr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def stdscr():
    with mock.patch('curses.initscr'), \
            mock.patch('curses.echo'), \
            mock.patch('curses.flash'), \
            mock.patch('curses.endwin'), \
            mock.patch('curses.newwin'), \
            mock.patch('curses.newpad'), \
            mock.patch('curses.noecho'), \
            mock.patch('curses.cbreak'), \
            mock.patch('curses.doupdate'), \
            mock.patch('curses.nocbreak'), \
            mock.patch('curses.curs_set'), \
            mock.patch('curses.init_pair'), \
            mock.patch('curses.color_pair'), \
            mock.patch('curses.has_colors'), \
            mock.patch('curses.start_color'), \
            mock.patch('curses.use_default_colors'):
        result = MockStdscr(nlines=24, ncols=100, x=0, y=0)
        curses.initscr.return_value = result
        curses.newwin.side_effect = lambda *args: result.derwin(*args)
        curses.color_pair.return_value = 1
        curses.has_colors.return_value = True
        curses.ACS_VLINE = 0
        curses.ACS_HLINE = 0
        curses.COLORS = 16
        curses.COLOR_PAIRS = 16
        yield result 
开发者ID:xgi,项目名称:castero,代码行数:29,代码来源:conftest.py

示例12: color_number

# 需要导入模块: import curses [as 别名]
# 或者: from curses import COLORS [as 别名]
def color_number(self, color: str) -> int:
        """Convert color string to valid color number"""
        if color in self.COLOR_NAMES:
            return self.COLOR_NAMES[color]
        if color.isnumeric() and int(color) < curses.COLORS:
            return int(color)
        return -1 
开发者ID:xgi,项目名称:castero,代码行数:9,代码来源:display.py


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