我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用curses.COLOR_MAGENTA。
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()
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)
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)
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)
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))
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)
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)
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
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)
def run(self): """ """ self.setup() # Clear screen self.screen.clear() # curses.start_color() curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_MAGENTA, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(6, curses.COLOR_WHITE, curses.COLOR_BLACK) while True: # session.expire_all() # TODO: Add some standard header to the top? (like interval time etc) # self.render() # self.increment.reset() # self.screen.refresh() # time.sleep(self.interval) self.running += self.interval return
def init_ui(): check_size() begin_x = 1 begin_y = 1 height = 40 width = 160 left_win_width = 28 middle_win_width = 80 right_win_width = width - left_win_width - middle_win_width - 4 win = newwin(height, width, begin_y, begin_x) win.border(0, 0, 0, 0, 0, 0, 0, 0) win.addstr("So You Have an Idea") win.refresh() left_win = win.subwin(height-5, left_win_width, 2, 2) left_win.border(0, 0, 0, 0, 0, 0, 0, 0) left_win.refresh() left_win = left_win.derwin(height-7, left_win_width-2, 1, 1) middle_win = win.subwin(height-5, middle_win_width, 2, left_win_width+2) middle_win.border(0, 0, 0, 0, 0, 0, 0, 0) for x in range(6, 20, 2): middle_win.addstr(x, middle_win_width-1, ">") middle_win.refresh() middle_win = middle_win.derwin(height-7, middle_win_width-2, 1, 1) right_win = win.subwin(height-5, right_win_width, 2, left_win_width + middle_win_width + 2) right_win.border(0, 0, 0, 0, 0, 0, 0, 0) for x in range(7, 21, 2): right_win.addstr(x, 0, "<") right_win.refresh() right_win = right_win.derwin(height-7, right_win_width-2, 1, 1) bottom_win = win.subwin(3, width-4, height-3, 2) bottom_win.border(0, 0, 0, 0, 0, 0, 0, 0) bottom_win.refresh() bottom_win = bottom_win.derwin(1, 114, 1, 1) left_win.refresh() middle_win.refresh() right_win.refresh() bottom_win.refresh() 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_BLUE, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_MAGENTA, curses.COLOR_BLACK) return left_win, middle_win, right_win, bottom_win, win