python类init_pair()的实例源码

TextEditor.py 文件源码 项目:HTP 作者: nklose 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, file):
        self.file = file
        self.scr = curses.initscr()
        self.scr.border()
        self.scr_height, self.scr_width = self.scr.getmaxyx()
        self.text_win = curses.newwin(self.scr_height - 1, self.scr_width, 1, 0)
        self.file_text = file.content
        if self.file_text != None:
            self.text_win.addstr(self.file_text)
        curses.noecho()
        #curses.start_color()
        #curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN)

        if self.file.exists:
            self.start_editor()
        else:
            curses.endwin()
            gc.error('An error occurred while editing this file.')
ChatSession.py 文件源码 项目:HTP 作者: nklose 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, username):
        os.environ.setdefault('ESCDELAY', '25') # shorten esc delay
        self.username = username

        # set up IRC
        self.channel = "##HTP"

        # set up curses
        self.scr = curses.initscr()
        self.disconnect = False
        curses.start_color()
        self.scr_height, self.scr_width = self.scr.getmaxyx()
        self.chatbar = curses.newwin(5, self.scr_height - 1, 5, 10)
        self.msg_text = ''
        self.logfile = '../data/irc.txt'
        self.log_text = []

        # curses color config
        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_GREEN)

        # start the client
        try:
            curses.wrapper(self.start_loop())
        except Exception as e:
            self.scr.addstr(2, 0, str(e), curses.A_REVERSE)

    # client game loop
curses_colors.py 文件源码 项目:defuse_division 作者: lelandbatey 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def colors_init():
    """
    Initializes all color pairs possible into the dictionary CURSES_COLORPAIRS.
    Thus, getting an attribute for a black foreground and a green background
    would look like:
        >>> curses_color.colors_init()
        >>> green_black_attr = curses_color.CURSES_COLORPAIRS['black-green']
        >>> stdscr.addstr(0, 0, "test", curses.color_pair(green_black_attr))
    """
    if len(CURSES_COLORPAIRS): return
    assert curses.has_colors(
    ), "Curses wasn't configured to support colors. Call curses.start_color()"
    start_number = 120
    for fg in BASE_CURSES_COLORS.keys():
        for bg in BASE_CURSES_COLORS.keys():
            pair_num = len(CURSES_COLORPAIRS) + start_number
            curses.init_pair(pair_num, BASE_CURSES_COLORS[fg],
                             BASE_CURSES_COLORS[bg])
            pair_name = "{}-{}".format(fg, bg)
            CURSES_COLORPAIRS[pair_name] = pair_num
pyStationInfoEdit.py 文件源码 项目:Parallel.GAMIT 作者: demiangomez 项目源码 文件源码 阅读 23 收藏 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()
captiv.py 文件源码 项目:captiv8 作者: wraith-wireless 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def initcolors():
    """ initialize color pallet """
    curses.start_color()
    if not curses.has_colors():
        raise RuntimeError("Sorry. Terminal does not support colors")

    # setup colors on black background
    for i in range(1,9):
        curses.init_pair(i,i,BLACK)
        CPS[i] = curses.color_pair(i)

    # have to individually set up special cases
    curses.init_pair(BUTTON,WHITE,GRAY)     # white on gray for buttons
    CPS[BUTTON] = curses.color_pair(BUTTON)
    curses.init_pair(HLITE,BLACK,GREEN)     # black on Green for highlight aps,stas
    CPS[HLITE] = curses.color_pair(HLITE)
    curses.init_pair(ERR,WHITE,RED)         # white on red
    CPS[ERR] = curses.color_pair(ERR)
    curses.init_pair(WARN,BLACK,YELLOW)     # white on yellow
    CPS[WARN] = curses.color_pair(WARN)
    curses.init_pair(NOTE,WHITE,GREEN)      # white on red
    CPS[NOTE] = curses.color_pair(NOTE)
browseRF.py 文件源码 项目:pyfeld 作者: scjurgen 项目源码 文件源码 阅读 23 收藏 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()
cursescolors.py 文件源码 项目:Qaf 作者: jonathanabennett 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def main(stdscr):
    curses.start_color()
    curses.use_default_colors()
    for i in range(0, curses.COLORS):
        curses.init_pair(i + 1, i, -1)
    try:
        for i in range(0, 255):
            stdscr.addstr(str(i), curses.color_pair(i))
            stdscr.addstr(" ")
    except curses.ERR:
        # End of screen reached
        pass
    stdscr.getch()
game.py 文件源码 项目:Qaf 作者: jonathanabennett 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def colorize(self):
        curses.use_default_colors()
        curses.init_pair(1, 7, -1)
        curses.init_pair(2, -1, 7)
        curses.init_pair(3, -1, 0)
        curses.init_pair(4, 2, -1)
        curses.init_pair(5, 3, -1)
        curses.init_pair(6, 3, -1)
        curses.init_pair(7, 6, -1)
        curses.init_pair(8, 5, -1)
        self.color_palette = {}
        self.color_palette["Player"] = 0
        self.color_palette["NPC"] = 1
        self.color_palette["dark_wall"] = 2
        self.color_palette["dark_floor"] = 3
        self.color_palette["goblinoid"] = 4
        self.color_palette["troll"] = 5
        self.color_palette['canine'] = 6
        self.color_palette['elf'] = 7
        self.color_palette['dwarf'] = 8
colors.py 文件源码 项目:melomaniac 作者: sdispater 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self):
        self._colors = {
            'white': curses.color_pair(self.PAIRS['white']),
            'black': curses.color_pair(self.PAIRS['white']) | curses.A_REVERSE,
            'red': curses.color_pair(self.PAIRS['red']),
            'blue': curses.color_pair(self.PAIRS['blue']),
            'green': curses.color_pair(self.PAIRS['green']),
            'green_reverse': (curses.color_pair(self.PAIRS['green'])
                              | curses.A_REVERSE),
            'cyan': curses.color_pair(self.PAIRS['cyan']),
            'cyan_reverse': (curses.color_pair(self.PAIRS['cyan'])
                             | curses.A_REVERSE),
            'yellow': curses.color_pair(self.PAIRS['yellow']),
            'yellow_reverse': (curses.color_pair(self.PAIRS['yellow'])
                               | curses.A_REVERSE),
            'magenta': curses.color_pair(self.PAIRS['magenta']),
            'magenta_reverse': (curses.color_pair(self.PAIRS['magenta'])
                                | curses.A_REVERSE),
        }

        curses.start_color()
        curses.use_default_colors()
        for definition, (color, background) in self.DEFINITION.items():
            curses.init_pair(definition, color, background)
pairs.py 文件源码 项目:cursebox 作者: Tenchi2xh 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __getitem__(self, pair):
        fg, bg = pair
        assert isinstance(fg, int) and -1 <= fg < 256
        assert isinstance(bg, int) and -1 <= bg < 256

        if pair in self.pair_numbers:
            # If pair is stored, retrieve it.
            return curses.color_pair(self.pair_numbers[pair])
        elif self.counter < MAX_PAIRS:
            # If we still haven't filled our queue, add the new pair.
            curses.init_pair(self.counter, fg, bg)
            self.pair_numbers[pair] = self.counter
            self.counter += 1
            return curses.color_pair(self.counter - 1)
        else:
            # If the queue is full, pop the oldest one out
            # and use its pair number to create the new one.
            _, oldest = self.pair_numbers.popitem(last=False)
            curses.init_pair(oldest, fg, bg)
            self.pair_numbers[pair] = oldest
            return curses.color_pair(oldest)
curses_interface.py 文件源码 项目:gdax-trader 作者: mcardillo55 项目源码 文件源码 阅读 23 收藏 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 项目源码 文件源码 阅读 26 收藏 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()
console.py 文件源码 项目:flux_line_bot 作者: blesscat 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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()
alarm.py 文件源码 项目:Utils 作者: disconsis 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def countdown(stdscr, end_time, font, fg_color, bg_color, msg=None):
    stdscr.clear()
    curses.curs_set(False)
    curses.init_pair(1, fg_color, bg_color)

    now = datetime.datetime.now()
    timefmt = '%I:%M %p' if now.day == end_time.day else '%I:%M %p, %d %b'
    stdscr.addstr(0, 0, 'Alarm set for: ' + end_time.strftime(timefmt))
    stdscr.refresh()

    win = None
    while now < end_time:
        time_left = str(end_time - now).split('.')[0]
        win = center(stdscr, time_left, font, curses.color_pair(1), win)
        sleep(1)
        now = datetime.datetime.now()

    alert(stdscr, args, win)
cursesutil.py 文件源码 项目:webnuke 作者: bugbound 项目源码 文件源码 阅读 31 收藏 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
curses_display.py 文件源码 项目:Adwear 作者: Uberi 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _setup_colour_pairs(self):
        """
        Initialize all 63 color pairs based on the term:
        bg * 8 + 7 - fg
        So to get a color, we just need to use that term and get the right color
        pair number.
        """
        if not self.has_color:
            return

        for fg in xrange(8):
            for bg in xrange(8):
                # leave out white on black
                if fg == curses.COLOR_WHITE and \
                   bg == curses.COLOR_BLACK:
                    continue

                curses.init_pair(bg * 8 + 7 - fg, fg, bg)
interactive.py 文件源码 项目:fingerpi 作者: zafartahirov 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def processmenu(screen, menu, parent=None, status_bottom = 'Uninitialized...'):
    curses.init_pair(1,curses.COLOR_BLACK, curses.COLOR_WHITE)
    curses.curs_set(0)
    status_mid = ''
    optioncount = len(menu['options'])
    exitmenu = False
    # response = None
    while not exitmenu: #Loop until the user exits the menu
        getin = runmenu(screen, menu, parent, status_mid, status_bottom)
        if getin == optioncount:
            exitmenu = True
        elif menu['options'][getin]['type'] == COMMAND:
            screen.clear() #clears previous screen
            status_mid, status_bottom = processrequest(menu['options'][getin], screen) # Add additional space
            ## Show the updated status
            screen.clear() #clears previous screen on key press and updates display based on pos
        elif menu['options'][getin]['type'] == MENU:
            screen.clear() #clears previous screen on key press and updates display based on pos
            processmenu(screen, menu['options'][getin], menu, status_bottom) # display the submenu, and make sure the status is persistent
            screen.clear() #clears previous screen on key press and updates display based on pos
        elif menu['options'][getin]['type'] == EXITMENU:
            exitmenu = True
menu_screen.py 文件源码 项目:botany 作者: jifunks 项目源码 文件源码 阅读 23 收藏 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)
skin.py 文件源码 项目:slacky 作者: mathiasbc 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def set_color_pairs():
    # based on the colors of pyradio
    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_BLACK, curses.COLOR_GREEN)
tui.py 文件源码 项目:awesome-finder 作者: mingrammer 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def init_curses(self):
        """Setup the curses"""
        self.window = curses.initscr()
        self.window.keypad(True)

        curses.noecho()
        curses.cbreak()

        curses.start_color()
        curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_CYAN)

        self.current = curses.color_pair(2)
cryptop.py 文件源码 项目:cryptop 作者: huwwp 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def conf_scr():
    '''Configure the screen and colors/etc'''
    curses.curs_set(0)
    curses.start_color()
    curses.use_default_colors()
    text, banner, banner_text, background = get_theme_colors()
    curses.init_pair(2, text, background)
    curses.init_pair(3, banner_text, banner)
    curses.halfdelay(10)
tetris_game.py 文件源码 项目:reinforcement_learning 作者: andreweskeclarke 项目源码 文件源码 阅读 27 收藏 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 项目源码 文件源码 阅读 30 收藏 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()
pick.py 文件源码 项目:xcode_archive 作者: zhipengbird 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def config_curses(self):
        # use the default colors of the terminal
        curses.use_default_colors ( )
        # hide the cursor
        curses.curs_set (0)
        # add some color for multi_select
        # @todo make colors configurable
        curses.init_pair (1, curses.COLOR_GREEN, curses.COLOR_WHITE)
gui.py 文件源码 项目:sandsifter 作者: xoreaxeaxeax 项目源码 文件源码 阅读 23 收藏 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 项目源码 文件源码 阅读 29 收藏 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 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def set(self, foreground=None, background=None):
        self.foreground = foreground or self.foreground
        self.background = background or self.background
        curses.init_pair(self.index, self.foreground, self.background)
Display.py 文件源码 项目:led 作者: rec 项目源码 文件源码 阅读 27 收藏 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
culour.py 文件源码 项目:culour 作者: shohamp 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _get_color(fg, bg):
    key = (fg, bg)
    if key not in COLOR_PAIRS_CACHE:
        # Use the pairs from 101 and after, so there's less chance they'll be overwritten by the user
        pair_num = len(COLOR_PAIRS_CACHE) + 101
        curses.init_pair(pair_num, fg, bg)
        COLOR_PAIRS_CACHE[key] = pair_num

    return COLOR_PAIRS_CACHE[key]


问题


面经


文章

微信
公众号

扫码关注公众号