python类COLOR_RED的实例源码

pyStationInfoEdit.py 文件源码 项目:Parallel.GAMIT 作者: demiangomez 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, stdscreen):

        curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_RED, curses.COLOR_WHITE)
        curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)

        global screen
        screen = stdscreen
        self.screen = stdscreen
        curses.curs_set(0)

        main_menu_items = get_records()

        main_menu_items += [{'field': 'Insert new station information record', 'function': selection_main_menu}]

        main_menu = Menu(cnn, main_menu_items, self.screen, 'Station information new/edit/delete - %s.%s' % (stn['NetworkCode'], stn['StationCode']))

        main_menu.display()
browseRF.py 文件源码 项目:pyfeld 作者: scjurgen 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        self.selected_index_stack = [0]
        self.returnString = ""
        self.play_in_room = None
        self.dir = DirBrowse()
        self.selected_index = 0
        self.selected_column = 0
        self.window = curses.initscr()
        curses.start_color()
        curses.noecho()
        curses.cbreak()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE)
        curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_RED)
        curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLUE)

        self.window.keypad(1)
        self.draw_ui()
curses_interface.py 文件源码 项目:gdax-trader 作者: mcardillo55 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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...")
base_manager.py 文件源码 项目:logviewer 作者: romuloceccon 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, curses, curses_window):
        curses.start_color()

        curses.curs_set(0)
        curses_window.nodelay(1)

        curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_MAGENTA, 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_CYAN, curses.COLOR_BLACK)
        curses.init_pair(6, curses.COLOR_BLUE, curses.COLOR_BLACK)

        self._curses = curses
        self._curses_window = curses_window

        self._stack = list()
color_stream_handler.py 文件源码 项目:danmu.fm 作者: twocucao 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, use_colors):
        logging.Handler.__init__(self)
        self.use_colors = use_colors

        # Initialize environment
        curses.setupterm()

        # Get the foreground color attribute for this environment
        self.fcap = curses.tigetstr('setaf')

        # Get the normal attribute
        self.COLOR_NORMAL = curses.tigetstr('sgr0').decode("utf-8")

        # Get + Save the color sequences
        self.COLOR_INFO = curses.tparm(self.fcap, curses.COLOR_GREEN).decode("utf-8")
        self.COLOR_ERROR = curses.tparm(self.fcap, curses.COLOR_RED).decode("utf-8")
        self.COLOR_WARNING = curses.tparm(self.fcap, curses.COLOR_YELLOW).decode("utf-8")
        self.COLOR_DEBUG = curses.tparm(self.fcap, curses.COLOR_BLUE).decode("utf-8")
cursesutil.py 文件源码 项目:webnuke 作者: bugbound 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_screen(self):
        self.screen = curses.initscr()

        curses.start_color()
        curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)

        if self.x == 0:
            starty, startx = self.screen.getmaxyx()
            self.x = startx
            self.y = starty

        resize = curses.is_term_resized(self.y, self.x)

        # Action in loop if resize is True:
        if resize is True:
            y, x = self.screen.getmaxyx()
            self.screen.clear()
            curses.resizeterm(self.y, self.x)
            self.screen.refresh()


        self.show_header()

        return self.screen
menu_screen.py 文件源码 项目:botany 作者: jifunks 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def define_colors(self):
        # set curses color pairs manually
        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_BLACK)
        curses.init_pair(5, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
        curses.init_pair(6, curses.COLOR_YELLOW, curses.COLOR_BLACK)
        curses.init_pair(7, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(8, curses.COLOR_CYAN, curses.COLOR_BLACK)
tetris_game.py 文件源码 项目:reinforcement_learning 作者: andreweskeclarke 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init_colors(self):
        curses.start_color()
        curses.use_default_colors()
        colors = [ curses.COLOR_BLUE,
                   curses.COLOR_CYAN,
                   curses.COLOR_GREEN,
                   curses.COLOR_MAGENTA,
                   curses.COLOR_RED,
                   curses.COLOR_WHITE,
                   curses.COLOR_YELLOW ]
        curses.init_pair(0, curses.COLOR_WHITE, curses.COLOR_BLACK)
        for i, c in enumerate(colors):
            curses.init_pair(i + 1, c, curses.COLOR_BLACK)
paint-it.py 文件源码 项目:paint-it 作者: plainspooky 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, arena_size):
        self.arena_size = arena_size
        self.max_moves = int(25*(2*arena_size*COLORS)/(28*6))
        self.screen = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        try:
            curses.curs_set(False)
        except curses.error:
            pass
        self.screen.nodelay(True)
        self.window_size = self.screen.getmaxyx()

        if self.window_size[0] < self.arena_size+4 or self.window_size[1] < self.arena_size*2:
            print('Your screen is too short!')
            exit()

        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_GREEN)
        curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_CYAN)
        curses.init_pair(4, curses.COLOR_WHITE, curses.COLOR_RED)
        curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_MAGENTA)
        curses.init_pair(6, curses.COLOR_WHITE, curses.COLOR_YELLOW)
        curses.init_pair(7, curses.COLOR_WHITE, curses.COLOR_WHITE)

        self.offset_x = int((self.window_size[1]-2*self.arena_size)/2)
        self.offset_y = int((self.window_size[0]-self.arena_size)/2)
        self.moves_position=[ self.offset_y+self.arena_size+1, self.offset_x+self.arena_size-5 ]

        self.arena_initialize()

        self.screen.addstr( self.offset_y-2, self.offset_x, self.title, curses.color_pair(0))
        self.screen.addstr( self.offset_y-2, self.offset_x+2*self.arena_size-17, "Press '?' to help", curses.color_pair(0))
pfserver.py 文件源码 项目:pyfeld 作者: scjurgen 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self):
        self.notification_count = 0
        self.window = curses.initscr()
        curses.start_color()
        curses.noecho()
        curses.cbreak()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE)
        curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_WHITE, curses.COLOR_RED)
        curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLUE)

        self.window.keypad(1)
        self.draw_ui()
gui.py 文件源码 项目:sandsifter 作者: xoreaxeaxeax 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
Curses.py 文件源码 项目:led 作者: rec 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def main(screen):
    screen.clear()
    screen_y, screen_x = screen.getmaxyx()
    screen.addstr(0, 0, str(screen.getmaxyx()))
    curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
    global DIR
    DIR = dir(screen)
    while True:
        c = screen.getch()
        screen.addstr(2, 2, str(c) + '   ', curses.color_pair(1) |
                      curses.A_BLINK | curses.A_BOLD)
        if c == 'q' or c == ord('q'):
            break
Display.py 文件源码 项目:led 作者: rec 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def main(screen):
    screen.clear()
    screen_y, screen_x = screen.getmaxyx()
    screen.move(1, 1)
    screen.addstr(str(screen.getmaxyx()))
    curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
    while True:
        c = screen.getch()
        screen.move(2, 2)
        # screen.addstr(str(c), curses.A_BLINK | curses.A_BOLD)
        # screen.addstr(str(c), curses.color_pair(1))
        screen.addstr(str(c), curses.color_pair(1) | curses.A_BLINK)
        if c == 'q' or c == ord('q'):
            break
interpreter.py 文件源码 项目:AsciiDots-Java 作者: LousyLynx 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, ticks, silent, debug, compat_debug, debug_lines, autostep_debug, head):
        super().__init__()

        self.ticks = ticks
        self.silent = silent
        self.debug = debug
        self.compat_debug = compat_debug
        self.debug_lines = debug_lines
        self.autostep_debug = autostep_debug
        self.head = head

        self.tick_number = 0

        self.output_count = 0

        if self.debug and not self.compat_debug:
            self.logging_loc = 0
            self.logging_x = 1

            self.stdscr = curses.initscr()

            curses.start_color()

            curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
            curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
            curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
            curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_BLACK)

            curses.noecho()

            curses.curs_set(False)

            self.win_program = curses.newwin(self.debug_lines, curses.COLS - 1, 0, 0)

            self.logging_pad = curses.newpad(1000, curses.COLS - 1)

            def signal_handler(signal, frame):
                    self.on_finish()
                    sys.exit(0)

            signal.signal(signal.SIGINT, signal_handler)
ui.py 文件源码 项目:WxNeteaseMusic 作者: yaphone 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        self.screen = curses.initscr()
        self.screen.timeout(100)  # the screen refresh every 100ms
        # charactor break buffer
        curses.cbreak()
        self.screen.keypad(1)
        self.netease = NetEase()

        curses.start_color()
        if Config().get_item('curses_transparency'):
            curses.use_default_colors()
            curses.init_pair(1, curses.COLOR_GREEN, -1)
            curses.init_pair(2, curses.COLOR_CYAN, -1)
            curses.init_pair(3, curses.COLOR_RED, -1)
            curses.init_pair(4, curses.COLOR_YELLOW, -1)
        else:
            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_YELLOW, curses.COLOR_BLACK)
        # term resize handling
        size = terminalsize.get_terminal_size()
        self.x = max(size[0], 10)
        self.y = max(size[1], 25)
        self.startcol = int(float(self.x) / 5)
        self.indented_startcol = max(self.startcol - 3, 0)
        self.update_space()
        self.lyric = ''
        self.now_lyric = ''
        self.tlyric = ''
        self.storage = Storage()
        self.config = Config()
        self.newversion = False
render.py 文件源码 项目:Halite 作者: shummie 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setup_colors():
    """Setup the colors for each player. Entry 8 is reserved for
    zero-strength unowned squares.
    """
    curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
    curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_RED)
    curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_BLUE)
    curses.init_pair(4, curses.COLOR_BLACK, curses.COLOR_GREEN)
    curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
    curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_CYAN)
    curses.init_pair(7, curses.COLOR_BLACK, curses.COLOR_YELLOW)
    curses.init_pair(8, curses.COLOR_WHITE, curses.COLOR_BLACK)
ascii_qgis.py 文件源码 项目:ascii_qgis 作者: NathanW2 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def init_colors():
    """
    Init the colors for the screen
    """
    curses.use_default_colors()

    # Colors we use for messages, etc
    curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_CYAN, curses.COLOR_BLACK)
    curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    curses.init_pair(5, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_WHITE)
    curses.init_pair(7, curses.COLOR_RED, curses.COLOR_BLACK)
    curses.init_pair(8, curses.COLOR_WHITE, curses.COLOR_WHITE)
    colors['white'] = curses.color_pair(1)
    colors['green'] = curses.color_pair(2)
    colors['cyan'] = curses.color_pair(3)
    colors['yellow'] = curses.color_pair(4)
    colors['green-black'] = curses.color_pair(5)
    colors['black-white'] = curses.color_pair(6)
    colors['red'] = curses.color_pair(7)
    colors['white-white'] = curses.color_pair(8)

    # Allocate colour ranges here for the ma display.
    maprange = 10
    for i in range(curses.COLORS - maprange):
        curses.init_pair(i + maprange, 0, i)
curses_console.py 文件源码 项目:solent 作者: solent-eng 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def screen_curses_init():
    #
    # number of milliseconds to wait after reading an escape character, to
    # distinguish between an individual escape character entered on the
    # keyboard from escape sequences sent by cursor and function keys (see
    # curses(3X).
    os.putenv("ESCDELAY", "0") # was 25
    #
    global STDSCR
    STDSCR = curses.initscr()
    curses.noecho()
    curses.cbreak()
    #
    if not curses.has_colors():
        raise Exception("Need colour support to run.")
    curses.raw()
    #
    curses.start_color()
    #
    # This is what allows us to use -1 for default when we initialise
    # the pairs
    curses.use_default_colors()
    #
    curses.init_pair(PROFILE_GREY       , curses.COLOR_WHITE    , -1)
    curses.init_pair(PROFILE_WHITE      , curses.COLOR_WHITE    , -1)
    curses.init_pair(PROFILE_RED        , curses.COLOR_RED      , -1)
    curses.init_pair(PROFILE_VERMILION  , curses.COLOR_RED      , -1)
    curses.init_pair(PROFILE_ORANGE     , curses.COLOR_RED      , -1)
    curses.init_pair(PROFILE_AMBER      , curses.COLOR_YELLOW   , -1)
    curses.init_pair(PROFILE_YELLOW     , curses.COLOR_YELLOW   , -1)
    curses.init_pair(PROFILE_CHARTREUSE , curses.COLOR_GREEN    , -1)
    curses.init_pair(PROFILE_GREEN      , curses.COLOR_GREEN    , -1)
    curses.init_pair(PROFILE_TEAL       , curses.COLOR_CYAN     , -1)
    curses.init_pair(PROFILE_BLUE       , curses.COLOR_BLUE     , -1)
    curses.init_pair(PROFILE_VIOLET     , curses.COLOR_MAGENTA  , -1)
    curses.init_pair(PROFILE_PURPLE     , curses.COLOR_MAGENTA  , -1)
    curses.init_pair(PROFILE_MAGENTA    , curses.COLOR_MAGENTA  , -1)
    curses.init_pair(PROFILE_BLACK_INFO , curses.COLOR_BLACK    , curses.COLOR_WHITE)
    curses.init_pair(PROFILE_ALARM,       curses.COLOR_RED      , curses.COLOR_WHITE)
ui.py 文件源码 项目:RasWxNeteaseMusic 作者: yaphone 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self):
        self.screen = curses.initscr()
        self.screen.timeout(100)  # the screen refresh every 100ms
        # charactor break buffer
        curses.cbreak()
        self.screen.keypad(1)
        self.netease = NetEase()

        curses.start_color()
        if Config().get_item('curses_transparency'):
            curses.use_default_colors()
            curses.init_pair(1, curses.COLOR_GREEN, -1)
            curses.init_pair(2, curses.COLOR_CYAN, -1)
            curses.init_pair(3, curses.COLOR_RED, -1)
            curses.init_pair(4, curses.COLOR_YELLOW, -1)
        else:
            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_YELLOW, curses.COLOR_BLACK)
        # term resize handling
        size = terminalsize.get_terminal_size()
        self.x = max(size[0], 10)
        self.y = max(size[1], 25)
        self.startcol = int(float(self.x) / 5)
        self.indented_startcol = max(self.startcol - 3, 0)
        self.update_space()
        self.lyric = ''
        self.now_lyric = ''
        self.tlyric = ''
        self.storage = Storage()
        self.config = Config()
        self.newversion = False
reporter.py 文件源码 项目:trtop 作者: aol 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _init_screen(self):
        screen = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
        screen.border(0)
        return screen
yate_console.py 文件源码 项目:YATE 作者: GarethNelson 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init_color_pairs(self):
       curses.init_pair(TOPSTATUS,TOPSTATUS_FG,TOPSTATUS_BG)
       curses.init_pair(TOPSTATUS_ONLINE,curses.COLOR_GREEN,TOPSTATUS_BG)
       curses.init_pair(TOPSTATUS_OFFLINE,curses.COLOR_RED,TOPSTATUS_BG)
       # create some color pairs for voxel types in a hacky way
       for item in dir(yateproto):
           if item.startswith('YATE_VOXEL_'):
              curses.init_pair(VOXEL_COLOR_PAIR + getattr(yateproto,item), curses.COLOR_WHITE,voxel_colors[getattr(yateproto,item)])
_term.py 文件源码 项目:deb-python-rjsmin 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        """ Initialization """
        dict.__init__(self, {
            'NORMAL': '',
            'BOLD': '',
            'ERASE': '\n',
            'RED': '',
            'YELLOW': '',
            'GREEN': '',
        })
        try:
            import curses as _curses
        except ImportError:
            # fixup if a submodule of curses failed.
            if 'curses' in _sys.modules:
                del _sys.modules['curses']
        else:
            try:
                _curses.setupterm()
            except (TypeError, _curses.error):
                pass
            else:
                def make_color(color):
                    """ Make color control string """
                    seq = _curses.tigetstr('setaf')
                    if seq is not None:
                        seq = _curses.tparm(seq, color)
                    return seq

                self['NORMAL'] = _curses.tigetstr('sgr0')
                self['BOLD'] = _curses.tigetstr('bold')

                erase = _curses.tigetstr('el1')
                if erase is not None:
                    self['ERASE'] = erase + _curses.tigetstr('cr')

                self['RED'] = make_color(_curses.COLOR_RED)
                self['YELLOW'] = make_color(_curses.COLOR_YELLOW)
                self['GREEN'] = make_color(_curses.COLOR_GREEN)
stocks.py 文件源码 项目:pystocker 作者: coffeeandscripts 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def print_stock_data(col, row, data, title, scr_main, scr_strip, cursor_row, change_amount, scr_dim):

    scr_strip.addstr(0, col+10, title)

    data_length = len(str(data))
    spaces_length = 9 - data_length
    n = 0

    if col+10+18 > scr_dim[1]:
        spaces_length = spaces_length + scr_dim[1] - col-10-9

    while n < spaces_length:
        data = data + " "
        n = n + 1
    curses.start_color()
    curses.init_pair(8, curses.COLOR_BLACK, curses.COLOR_RED)
    curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_GREEN)
    curses.init_pair(10, curses.COLOR_BLACK, curses.COLOR_YELLOW)
    curses.init_pair(11, curses.COLOR_RED, curses.COLOR_BLACK)
    curses.init_pair(12, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(13, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    if cursor_row == 1:
        if change_amount == -1:
            scr_main.addstr(row, col, data, curses.color_pair(8))
        elif change_amount == 1:
            scr_main.addstr(row, col, data, curses.color_pair(9))
        else:
            scr_main.addstr(row, col, data, curses.color_pair(10))
    else:
        if change_amount == -1:
            scr_main.addstr(row, col, data, curses.color_pair(11))
        elif change_amount == 1:
            scr_main.addstr(row, col, data, curses.color_pair(12))
        else:
            scr_main.addstr(row, col, data, curses.color_pair(13))
permanents.py 文件源码 项目:pystocker 作者: coffeeandscripts 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def print_permanents(scr_top, perm, row, col, perm_data, scr_dim):

    if perm == "GC=F":
        perm = "Gold"
    elif perm == "SI=F":
        perm = "Silver"
    elif perm == "HG=F":
        perm = "Copper"
    elif perm == "CL=F":
        perm = "Crude"
    elif perm[-2:] == "=X":
        perm = perm[0:3] + "/" + perm[3:6]
    elif perm[0] == "^":
        perm = perm[1:]

    curses.start_color()

    curses.init_pair(20, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(21, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    curses.init_pair(22, curses.COLOR_RED, curses.COLOR_BLACK)

    try:
        printing_perm = str(perm) + "=" + str(perm_data["price"])
    except:
        printing_perm = str(perm) + "=N/A"

    perm_length = len(printing_perm) + 1

    if perm_length+col < scr_dim[1]:
        if perm_data["change"] != "N/A":
            if float(perm_data["change"]) >= 0.5:
                scr_top.addstr(1+row, col, str(printing_perm), curses.color_pair(20))
            if float(perm_data["change"]) <= -0.5:
                scr_top.addstr(1+row, col, str(printing_perm), curses.color_pair(22))
            else:
                scr_top.addstr(1+row, col, str(printing_perm), curses.color_pair(21))
        else:
            scr_top.addstr(1+row, col, str(printing_perm))

    return perm_length
ui.py 文件源码 项目:NEmusicbox 作者: PyCN 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self):
        self.screen = curses.initscr()
        self.screen.timeout(100)  # the screen refresh every 100ms
        # charactor break buffer
        curses.cbreak()
        self.screen.keypad(1)
        self.netease = NetEase()

        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_YELLOW, curses.COLOR_BLACK)
        # term resize handling
        size = terminalsize.get_terminal_size()
        self.x = max(size[0], 10)
        self.y = max(size[1], 25)
        self.startcol = int(float(self.x) / 5)
        self.indented_startcol = max(self.startcol - 3, 0)
        self.update_space()
        self.lyric = ''
        self.now_lyric = ''
        self.tlyric = ''
        self.storage = Storage()
        self.config = Config()
        self.newversion = False
render.py 文件源码 项目:HaliteBot 作者: jheilema-nerdery 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def setup_colors():
    """Setup the colors for each player. Entry 8 is reserved for
    zero-strength unowned squares.
    """
    curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
    curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_RED)
    curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_BLUE)
    curses.init_pair(4, curses.COLOR_BLACK, curses.COLOR_GREEN)
    curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
    curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_CYAN)
    curses.init_pair(7, curses.COLOR_BLACK, curses.COLOR_YELLOW)
    curses.init_pair(8, curses.COLOR_WHITE, curses.COLOR_BLACK)
_term.py 文件源码 项目:deb-python-rcssmin 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self):
        """ Initialization """
        dict.__init__(self, {
            'NORMAL': '',
            'BOLD': '',
            'ERASE': '\n',
            'RED': '',
            'YELLOW': '',
            'GREEN': '',
        })
        try:
            import curses as _curses
        except ImportError:
            # fixup if a submodule of curses failed.
            if 'curses' in _sys.modules:
                del _sys.modules['curses']
        else:
            try:
                _curses.setupterm()
            except (TypeError, _curses.error):
                pass
            else:
                def make_color(color):
                    """ Make color control string """
                    seq = _curses.tigetstr('setaf')
                    if seq is not None:
                        seq = _curses.tparm(seq, color)
                    return seq

                self['NORMAL'] = _curses.tigetstr('sgr0')
                self['BOLD'] = _curses.tigetstr('bold')

                erase = _curses.tigetstr('el1')
                if erase is not None:
                    self['ERASE'] = erase + _curses.tigetstr('cr')

                self['RED'] = make_color(_curses.COLOR_RED)
                self['YELLOW'] = make_color(_curses.COLOR_YELLOW)
                self['GREEN'] = make_color(_curses.COLOR_GREEN)
alarm.py 文件源码 项目:Utils 作者: disconsis 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def parse_args():
    parser = argparse.ArgumentParser()
    # parser.add_argument('-a', '--abs', action='store_true')
    parser.add_argument('abs_rel', choices=['at', 'after'])
    font_choices = [font.split('.')[0]
                    for font in os.listdir('/usr/share/figlet')
                    if font.split('.')[1] == 'tlf']
    parser.add_argument('-f', '--font', default=DEFAULT_FONT,
                        choices=font_choices)
    parser.add_argument('-m', '--msg', default=None)
    # parser.add_argument('-z', '--snooze', type=float, default=2)
    parser_volume = parser.add_mutually_exclusive_group()
    parser_song = parser_volume.add_argument_group()
    parser_song.add_argument('-d', '--dir', default=DEFAULT_MUSIC_DIR)
    parser_song.add_argument('--song', default=DEFAULT_SONG)
    parser_volume.add_argument('-ns', '--silent', action='store_true')
    parser.add_argument('-fg', choices=['black', 'red', 'green', 'yellow',
                                        'blue', 'magenta', 'cyan', 'white'],
                        default='white')
    parser.add_argument('-bg', choices=['black', 'red', 'green', 'yellow',
                                        'blue', 'magenta', 'cyan', 'white'],
                        default='black')
    parser.add_argument('time', nargs='+')
    args = parser.parse_args()
    args.abs = False if args.abs_rel == 'after' else True
    if not args.silent:
        args.song = validate_song(args)
    args.time = ' '.join(args.time)
    color_mapping = {
        'black': curses.COLOR_BLACK,
        'red': curses.COLOR_RED,
        'green': curses.COLOR_GREEN,
        'yellow': curses.COLOR_YELLOW,
        'blue': curses.COLOR_BLUE,
        'magenta': curses.COLOR_MAGENTA,
        'cyan': curses.COLOR_CYAN,
        'white': curses.COLOR_WHITE,
    }
    args.fg = color_mapping[args.fg]
    args.bg = color_mapping[args.bg]
    return args
WsjtxCurses.py 文件源码 项目:py_wsjtx 作者: teabreakninja 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def setup_colours(self):
        curses.start_color()
        # 0 - NOT_WORKED
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_RED)
        # 1 - WORKED_COUNTRY_AND_STATION
        curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
        # 2 - WORKED_COUNTRY_NOT_STATION
        curses.init_pair(3, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
        # 3 - WORKED_COUNTRY_DIFF_BAND
        curses.init_pair(4, curses.COLOR_CYAN, curses.COLOR_BLACK)
terminal.py 文件源码 项目:connect4 作者: guglielmilo 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def defineColors():
    curses.start_color()
    curses.use_default_colors()
    curses.init_pair(color.BLACK,    curses.COLOR_BLACK,  -1)
    curses.init_pair(color.GREY,     250,                 -1)
    curses.init_pair(color.RED,      curses.COLOR_RED,    -1)
    curses.init_pair(color.YELLOW,   143,                 -1)
    curses.init_pair(color.BLUE,     curses.COLOR_BLUE,   -1)
    # highlight text
    curses.init_pair(color.RED_H,    curses.COLOR_RED,    curses.COLOR_WHITE)
    curses.init_pair(color.YELLOW_H, curses.COLOR_YELLOW, curses.COLOR_WHITE)


问题


面经


文章

微信
公众号

扫码关注公众号