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


Python curses.init_color方法代码示例

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


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

示例1: cleanup

# 需要导入模块: import curses [as 别名]
# 或者: from curses import init_color [as 别名]
def cleanup(gui, poll, injector, ts, tests, command_line, args):
    ts.run = False
    if gui:
        gui.stop()
    if poll:
        poll.stop()
    if injector:
        injector.stop()

    '''
    # doesn't work
    if gui:
        for (i, c) in enumerate(gui.orig_colors):
            curses.init_color(i, c[0], c[1], c[2])
    '''

    curses.nocbreak();
    curses.echo()
    curses.endwin()

    dump_artifacts(tests, injector, command_line)

    if args.save:
        with open(LAST, "w") as f:
            f.write(hexlify(cstr2py(tests.r.raw_insn)))

    sys.exit(0) 
开发者ID:Battelle,项目名称:sandsifter,代码行数:29,代码来源:sifter.py

示例2: init_colors

# 需要导入模块: import curses [as 别名]
# 或者: from curses import init_color [as 别名]
def init_colors(self):

        if curses.has_colors() and curses.can_change_color():
            curses.init_color(self.COLOR_BLACK, 0, 0, 0)
            curses.init_color(self.COLOR_WHITE, 1000, 1000, 1000)
            curses.init_color(self.COLOR_BLUE, 0, 0, 1000)
            curses.init_color(self.COLOR_RED, 1000, 0, 0)
            curses.init_color(self.COLOR_GREEN, 0, 1000, 0)

            for i in xrange(0, self.GRAYS):
                curses.init_color(
                        self.GRAY_BASE + i,
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1)
                        )
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.GRAY_BASE + i,
                        self.COLOR_BLACK
                        )

        else:
            self.COLOR_BLACK = curses.COLOR_BLACK
            self.COLOR_WHITE = curses.COLOR_WHITE
            self.COLOR_BLUE = curses.COLOR_BLUE
            self.COLOR_RED = curses.COLOR_RED
            self.COLOR_GREEN = curses.COLOR_GREEN

            for i in xrange(0, self.GRAYS):
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.COLOR_WHITE,
                        self.COLOR_BLACK
                        )

        curses.init_pair(self.BLACK, self.COLOR_BLACK, self.COLOR_BLACK)
        curses.init_pair(self.WHITE, self.COLOR_WHITE, self.COLOR_BLACK)
        curses.init_pair(self.BLUE, self.COLOR_BLUE, self.COLOR_BLACK)
        curses.init_pair(self.RED, self.COLOR_RED, self.COLOR_BLACK)
        curses.init_pair(self.GREEN, self.COLOR_GREEN, self.COLOR_BLACK) 
开发者ID:Battelle,项目名称:sandsifter,代码行数:43,代码来源:gui.py

示例3: set_curses_colors

# 需要导入模块: import curses [as 别名]
# 或者: from curses import init_color [as 别名]
def set_curses_colors():
        s = 1000 / 255
        for r, g, b in itertools.product(range(8), range(8), range(4)):
            index = r + 8 * (g + 8 * b)
            # Color 0 is black and can't be changed.
            # Pair 0 is white on black and can't be changed.
            if index:
                r, g, b = r << 5, g << 5, b << 6
                _curses.init_color(index, int(r * s), int(g * s), int(b * s))
                _curses.init_pair(index, index, 0) 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:12,代码来源:curses.py

示例4: define_colour_numbers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import init_color [as 别名]
def define_colour_numbers(self):
        if curses.can_change_color():
            for c in self._color_values:
                curses.init_color(c[0], *c[1]) 
开发者ID:hexway,项目名称:apple_bleee,代码行数:6,代码来源:npysThemeManagers.py

示例5: set_colours

# 需要导入模块: import curses [as 别名]
# 或者: from curses import init_color [as 别名]
def set_colours(colours):
    """
    Set curses colours.

    Arguments:
    colours: Dict with colour information.
    """
    crs.start_color()
    # Define colours.
    if colours['background'] == 'default':
        crs.use_default_colors()
        background = -1
    else:
        crs.init_color(0, *hex_to_rgb(colours['background']))
        background = 0
    crs.init_color(1, *hex_to_rgb(colours['foreground']))
    crs.init_color(2, *hex_to_rgb(colours['highlight']))
    crs.init_color(3, *hex_to_rgb(colours['content1']))
    crs.init_color(4, *hex_to_rgb(colours['content2']))

    # Define colour pairs.
    crs.init_pair(1, 1, background)
    crs.init_pair(2, 2, background)
    crs.init_pair(3, 3, background)
    crs.init_pair(4, 4, background)

    # Set colours.
    crs.start_color()
    common.w.main.bkgdset(' ', crs.color_pair(1))
    common.w.inbar.bkgdset(' ', crs.color_pair(1))
    common.w.infobar.bkgdset(' ', crs.color_pair(2))
    common.w.outbar.bkgdset(' ', crs.color_pair(4))

    common.w.refresh() 
开发者ID:christopher-dG,项目名称:gpymusic,代码行数:36,代码来源:start.py

示例6: init_color

# 需要导入模块: import curses [as 别名]
# 或者: from curses import init_color [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

示例7: init_colors

# 需要导入模块: import curses [as 别名]
# 或者: from curses import init_color [as 别名]
def init_colors(self):
        if curses.has_colors() and curses.can_change_color():
            curses.init_color(self.COLOR_BLACK, 0, 0, 0)
            curses.init_color(self.COLOR_WHITE, 1000, 1000, 1000)
            curses.init_color(self.COLOR_BLUE, 0, 0, 1000)
            curses.init_color(self.COLOR_RED, 1000, 0, 0)
            curses.init_color(self.COLOR_GREEN, 0, 1000, 0)

            # this will remove flicker, but gives boring colors
            '''
            self.COLOR_BLACK = curses.COLOR_BLACK
            self.COLOR_WHITE = curses.COLOR_WHITE
            self.COLOR_BLUE = curses.COLOR_BLUE
            self.COLOR_RED = curses.COLOR_RED
            self.COLOR_GREEN = curses.COLOR_GREEN
            '''

            for i in xrange(0, self.GRAYS):
                curses.init_color(
                        self.GRAY_BASE + i,
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1)
                        )
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.GRAY_BASE + i,
                        self.COLOR_BLACK
                        )

        else:
            self.COLOR_BLACK = curses.COLOR_BLACK
            self.COLOR_WHITE = curses.COLOR_WHITE
            self.COLOR_BLUE = curses.COLOR_BLUE
            self.COLOR_RED = curses.COLOR_RED
            self.COLOR_GREEN = curses.COLOR_GREEN

            for i in xrange(0, self.GRAYS):
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.COLOR_WHITE,
                        self.COLOR_BLACK
                        )

        curses.init_pair(self.BLACK, self.COLOR_BLACK, self.COLOR_BLACK)
        curses.init_pair(self.WHITE, self.COLOR_WHITE, self.COLOR_BLACK)
        curses.init_pair(self.BLUE, self.COLOR_BLUE, self.COLOR_BLACK)
        curses.init_pair(self.RED, self.COLOR_RED, self.COLOR_BLACK)
        curses.init_pair(self.GREEN, self.COLOR_GREEN, self.COLOR_BLACK) 
开发者ID:Battelle,项目名称:sandsifter,代码行数:51,代码来源:sifter.py

示例8: setUpCurses

# 需要导入模块: import curses [as 别名]
# 或者: from curses import init_color [as 别名]
def setUpCurses(self, cursesScreen):
        self.cursesScreen = cursesScreen
        curses.mousemask(-1)
        curses.mouseinterval(0)
        # Enable mouse tracking in xterm.
        sys.stdout.write('\033[?1002;h')
        #sys.stdout.write('\033[?1005;h')
        curses.meta(1)
        # Access ^c before shell does.
        curses.raw()
        # Enable Bracketed Paste Mode.
        sys.stdout.write('\033[?2004;h')
        # Push the escape codes out to the terminal. (Whether this is needed
        # seems to vary by platform).
        sys.stdout.flush()
        try:
            curses.start_color()
            if not curses.has_colors():
                userMessage("This terminal does not support color.")
                self.quitNow()
            else:
                curses.use_default_colors()
        except curses.error as e:
            app.log.error(e)
        app.log.startup(u"curses.COLORS", curses.COLORS)
        if 0:
            assert curses.COLORS == 256
            assert curses.can_change_color() == 1
            assert curses.has_colors() == 1
            app.log.detail("color_content:")
            for i in range(0, curses.COLORS):
                app.log.detail("color", i, ": ", curses.color_content(i))
            for i in range(16, curses.COLORS):
                curses.init_color(i, 500, 500, i * 787 % 1000)
            app.log.detail("color_content, after:")
            for i in range(0, curses.COLORS):
                app.log.detail("color", i, ": ", curses.color_content(i))
        if 1:
            #rows, cols = self.cursesScreen.getmaxyx()
            cursesWindow = self.cursesScreen
            cursesWindow.leaveok(1)  # Don't update cursor position.
            cursesWindow.scrollok(0)
            cursesWindow.timeout(10)
            cursesWindow.keypad(1)
            app.window.mainCursesWindow = cursesWindow 
开发者ID:google,项目名称:ci_edit,代码行数:47,代码来源:ci_program.py


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