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


Python curses.can_change_color方法代码示例

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


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

示例1: gray

# 需要导入模块: import curses [as 别名]
# 或者: from curses import can_change_color [as 别名]
def gray(self, scale):
        if curses.can_change_color():
            return curses.color_pair(self.GRAY_BASE + int(round(scale * (self.GRAYS - 1))))
        else:
            return curses.color_pair(self.WHITE) 
开发者ID:Battelle,项目名称:sandsifter,代码行数:7,代码来源:sifter.py

示例2: init_colors

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

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

示例4: init_color

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

示例5: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import can_change_color [as 别名]
def __init__(self, map_name='world', map_conf=None, window=None, encoding=None):
        if map_conf is None:
            map_conf = MAPS[map_name]
        self.map = map_conf['data']
        self.coords = map_conf['coords']
        self.corners = map_conf['corners']
        if window is None:
            window = curses.newwin(0, 0)
        self.window = window

        self.data = []
        self.data_timestamp = None

        # JSON contents _should_ be UTF8 (so, python internal unicode here...)
        if encoding is None:
            encoding = locale.getpreferredencoding()
        self.encoding = encoding

        # check if we can use transparent background or not
        if curses.can_change_color():
            curses.use_default_colors()
            background = -1
        else:
            background = curses.COLOR_BLACK

        tmp_colors = [
            ('red', curses.COLOR_RED, background),
            ('blue', curses.COLOR_BLUE, background),
            ('pink', curses.COLOR_MAGENTA, background)
        ]

        self.colors = {}
        if curses.has_colors():
            for i, (name, fgcolor, bgcolor) in enumerate(tmp_colors, 1):
                curses.init_pair(i, fgcolor, bgcolor)
                self.colors[name] = i 
开发者ID:sabri-zaki,项目名称:EasY_HaCk,代码行数:38,代码来源:worldmap.py

示例6: init_colors

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

示例7: debugDraw

# 需要导入模块: import curses [as 别名]
# 或者: from curses import can_change_color [as 别名]
def debugDraw(self, program, win):
        """Draw real-time debug information to the screen."""
        textBuffer = win.textBuffer
        self.writeLineRow = 0
        intent = u"noIntent"
        if hasattr(win, u"userIntent"):
            intent = win.userIntent
        color = program.color.get(u'debug_window')
        self.writeLine(
            u"   cRow %3d    cCol %2d goalCol %2d  %s" %
            (win.textBuffer.penRow, win.textBuffer.penCol,
             win.textBuffer.goalCol, intent), color)
        self.writeLine(
            u"   pRow %3d    pCol %2d chRow %4d" %
            (textBuffer.penRow, textBuffer.penCol,
             textBuffer.debugUpperChangedRow), color)
        self.writeLine(
            u" mkrRow %3d  mkrCol %2d sm %d" %
            (textBuffer.markerRow, textBuffer.markerCol,
             textBuffer.selectionMode), color)
        self.writeLine(
            u"scrlRow %3d scrlCol %2d lines %3d" %
            (win.scrollRow, win.scrollCol, textBuffer.parser.rowCount()), color)
        y, x = win.top, win.left
        maxRow, maxCol = win.rows, win.cols
        self.writeLine(
            u"y %2d x %2d maxRow %d maxCol %d baud %d color %d" %
            (y, x, maxRow, maxCol, curses.baudrate(),
             curses.can_change_color()), color)
        screenRows, screenCols = program.cursesScreen.getmaxyx()
        self.writeLine(
            u"scr rows %d cols %d mlt %f/%f pt %f" %
            (screenRows, screenCols, program.mainLoopTime,
             program.mainLoopTimePeak, textBuffer.parserTime), color)
        self.writeLine(
            u"ch %3s %s" % (program.ch, app.curses_util.cursesKeyName(
                program.ch) or u'UNKNOWN'), color)
        self.writeLine(u"win %r" % (win,), color)
        self.writeLine(u"foc %r" % (program.programWindow.focusedWindow,),
                       color)
        self.writeLine(u"tb %r" % (textBuffer,), color)
        (id, mouseCol, mouseRow, mouseZ, bState) = program.debugMouseEvent
        self.writeLine(
            u"mouse id %d, mouseCol %d, mouseRow %d, mouseZ %d" %
            (id, mouseCol, mouseRow, mouseZ), color)
        self.writeLine(
            u"bState %s %d" % (app.curses_util.mouseButtonName(bState), bState),
            color)
        self.writeLine(u"startAndEnd %r" % (textBuffer.startAndEnd(),), color) 
开发者ID:google,项目名称:ci_edit,代码行数:51,代码来源:debug_window.py

示例8: setUpCurses

# 需要导入模块: import curses [as 别名]
# 或者: from curses import can_change_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.can_change_color方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。