Python curses.COLOR_RED Examples
The following are 30
code examples of curses.COLOR_RED().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
curses
, or try the search function
.
Example #1
Source File: interface.py From bitcoind-ncurses with MIT License | 8 votes |
def init_curses(): window = curses.initscr() curses.noecho() # prevents user input from being echoed curses.curs_set(0) # make cursor invisible 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_MAGENTA, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK) window.timeout(50) window.keypad(1) # interpret arrow keys, etc return window
Example #2
Source File: CLI.py From email_hack with MIT License | 7 votes |
def init_curses(self): """Setup the curses""" self.window = curses.initscr() self.height, self.width = self.window.getmaxyx() if self.width < 60: self.too_small = True return self.window.keypad(True) # self.window.nodelay(True) curses.noecho() curses.curs_set(False) curses.cbreak() curses.start_color() curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_CYAN)
Example #3
Source File: gcore_box.py From gaycore with MIT License | 6 votes |
def _init_curses(self): self.stdscr = curses.initscr() self.stdscr.keypad(1) curses.noecho() curses.cbreak() curses.curs_set(0) curses.start_color() try: curses.init_pair(1, curses.COLOR_BLACK, 197) # 接近机核主题的颜色 except: # 树莓派 windows无法使用机核like色 curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_RED) curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK) self.stdscr.bkgd(curses.color_pair(2)) self.stdscr.timeout(100) self.stdscr.refresh()
Example #4
Source File: ui.py From scorer.py with GNU General Public License v2.0 | 6 votes |
def main(stdscr, matches): curses.curs_set(False) selected = 0 curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK) while True: printGames(stdscr, matches, selected) event = stdscr.getch() if event == ord("\n"): logging.info("Enter key pressed") return selected elif event == curses.KEY_UP: logging.info("Up key pressed") if selected != 0: selected -= 1 printGames(stdscr, matches, selected) elif event == curses.KEY_DOWN: logging.info("Down key pressed") if selected != len(matches) - 1: selected += 1 printGames(stdscr, matches, selected)
Example #5
Source File: ColorStreamHandler.py From emailhunter-clone with MIT License | 6 votes |
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') # Get + Save the color sequences self.COLOR_INFO = curses.tparm(self.fcap, curses.COLOR_GREEN) self.COLOR_ERROR = curses.tparm(self.fcap, curses.COLOR_RED) self.COLOR_WARNING = curses.tparm(self.fcap, curses.COLOR_YELLOW) self.COLOR_DEBUG = curses.tparm(self.fcap, curses.COLOR_BLUE)
Example #6
Source File: test_theme.py From rtv with MIT License | 6 votes |
def test_theme_from_file(): with _ephemeral_directory() as dirname: with NamedTemporaryFile(mode='w+', dir=dirname) as fp: with pytest.raises(ConfigError): Theme.from_file(fp.name, 'installed') fp.write('[theme]\n') fp.write('Unknown = - -\n') fp.write('Upvote = - red\n') fp.write('Downvote = ansi_255 default bold\n') fp.write('NeutralVote = #000000 #ffffff bold+reverse\n') fp.flush() theme = Theme.from_file(fp.name, 'installed') assert theme.source == 'installed' assert 'Unknown' not in theme.elements assert theme.elements['Upvote'] == ( -1, curses.COLOR_RED, curses.A_NORMAL) assert theme.elements['Downvote'] == ( 255, -1, curses.A_BOLD) assert theme.elements['NeutralVote'] == ( 16, 231, curses.A_BOLD | curses.A_REVERSE)
Example #7
Source File: app.py From toot with GNU General Public License v3.0 | 6 votes |
def setup_palette(class_): curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_GREEN, 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_CYAN, curses.COLOR_BLACK) curses.init_pair(7, curses.COLOR_MAGENTA, curses.COLOR_BLACK) curses.init_pair(8, curses.COLOR_WHITE, curses.COLOR_BLUE) curses.init_pair(9, curses.COLOR_WHITE, curses.COLOR_RED) class_.WHITE = curses.color_pair(1) class_.BLUE = curses.color_pair(2) class_.GREEN = curses.color_pair(3) class_.YELLOW = curses.color_pair(4) class_.RED = curses.color_pair(5) class_.CYAN = curses.color_pair(6) class_.MAGENTA = curses.color_pair(7) class_.WHITE_ON_BLUE = curses.color_pair(8) class_.WHITE_ON_RED = curses.color_pair(9) class_.HASHTAG = class_.BLUE | curses.A_BOLD
Example #8
Source File: lcd.py From bitnodes-hardware with MIT License | 6 votes |
def show(self, screen): self.screen = screen curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) self.white = curses.color_pair(1) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) self.green = curses.color_pair(2) curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK) self.yellow = curses.color_pair(3) curses.init_pair(4, curses.COLOR_RED, curses.COLOR_BLACK) self.red = curses.color_pair(4) curses.curs_set(0) self.addstr(1, 1, 'BITNODES HARDWARE', self.white) self.addstr(1, 19, 'LOADING', self.yellow) while True: time.sleep(self.update())
Example #9
Source File: raspcloud.py From RaspberryCloud with GNU General Public License v3.0 | 6 votes |
def main(): screen = init_curses() y, x = screen.getmaxyx() # create green curses.init_pair(1, curses.COLOR_GREEN, -1) # create red curses.init_pair(2, curses.COLOR_RED, -1) # -1 is default bcgd color # create white curses.init_pair(3, curses.COLOR_WHITE, -1) # create cyan curses.init_pair(4, curses.COLOR_CYAN, -1) # create yellow curses.init_pair(5, curses.COLOR_YELLOW, -1) # create black on white curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_WHITE) # print the splash screen out! splash_screen(screen, y, x) # check and see if this program is being run by itself # if so call the main function
Example #10
Source File: __init__.py From py_cui with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _initialize_colors(self): """Function for initialzing curses colors. Called when CUI is first created. """ # Start colors in curses curses.start_color() curses.init_pair(WHITE_ON_BLACK, curses.COLOR_WHITE, curses.COLOR_BLACK) curses.init_pair(BLACK_ON_GREEN, curses.COLOR_BLACK, curses.COLOR_GREEN) curses.init_pair(BLACK_ON_WHITE, curses.COLOR_BLACK, curses.COLOR_WHITE) curses.init_pair(WHITE_ON_RED, curses.COLOR_WHITE, curses.COLOR_RED) curses.init_pair(YELLOW_ON_BLACK, curses.COLOR_YELLOW, curses.COLOR_BLACK) curses.init_pair(RED_ON_BLACK, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(CYAN_ON_BLACK, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(MAGENTA_ON_BLACK, curses.COLOR_MAGENTA, curses.COLOR_BLACK) curses.init_pair(GREEN_ON_BLACK, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(BLUE_ON_BLACK, curses.COLOR_BLUE, curses.COLOR_BLACK)
Example #11
Source File: termdown.py From termdown with GNU General Public License v3.0 | 6 votes |
def setup(stdscr): # curses curses.use_default_colors() curses.init_pair(1, curses.COLOR_RED, -1) curses.init_pair(2, curses.COLOR_RED, curses.COLOR_RED) curses.init_pair(3, curses.COLOR_GREEN, -1) curses.init_pair(4, -1, curses.COLOR_RED) try: curses.curs_set(False) except curses.error: # fails on some terminals pass stdscr.timeout(0) # prepare input thread mechanisms curses_lock = Lock() input_queue = Queue() quit_event = Event() return (curses_lock, input_queue, quit_event)
Example #12
Source File: worldmap.py From EasY_HaCk with Apache License 2.0 | 5 votes |
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
Example #13
Source File: ui.py From NetEase-MusicBox with MIT License | 5 votes |
def __init__(self): self.screen = curses.initscr() # 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)
Example #14
Source File: tui.py From wifiphisher with GNU General Public License v3.0 | 5 votes |
def gather_info(self, screen, info): """ Get the information from pywifiphisher and print them out :param self: A TuiMain object :param screen: A curses window object :param info: A namedtuple of printing information :type self: TuiMain :type screen: _curses.curses.window :type info: namedtuple :return: None :rtype: None """ # setup curses try: curses.curs_set(0) except curses.error: pass screen.nodelay(True) curses.init_pair(1, curses.COLOR_BLUE, screen.getbkgd()) curses.init_pair(2, curses.COLOR_YELLOW, screen.getbkgd()) curses.init_pair(3, curses.COLOR_RED, screen.getbkgd()) self.blue_text = curses.color_pair(1) | curses.A_BOLD self.yellow_text = curses.color_pair(2) | curses.A_BOLD self.red_text = curses.color_pair(3) | curses.A_BOLD while True: # catch the exception when screen size is smaller than # the text length is_done = self.display_info(screen, info) if is_done: return
Example #15
Source File: trailing_whitespace.py From babi with MIT License | 5 votes |
def _trailing_ws(self, line: str) -> HLs: if not line: return () i = len(line) while i > 0 and line[i - 1].isspace(): i -= 1 if i == len(line): return () else: pair = self._color_manager.raw_color_pair(-1, curses.COLOR_RED) attr = curses.color_pair(pair) return (HL(x=i, end=len(line), attr=attr),)
Example #16
Source File: graphics.py From costar_plan with Apache License 2.0 | 5 votes |
def __init__(self): self.stdscr = curses.initscr() curses.start_color() curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) self.bottom_row = 0
Example #17
Source File: screenControl.py From PathPicker with MIT License | 5 votes |
def printProvidedCommandWarning(self, yStart, xStart): self.colorPrinter.addstr(yStart, xStart, 'Oh no! You already provided a command so ' + 'you cannot enter command mode.', self.colorPrinter.getAttributes(curses.COLOR_WHITE, curses.COLOR_RED, 0)) self.colorPrinter.addstr( yStart + 1, xStart, 'The command you provided was "%s" ' % self.flags.getPresetCommand()) self.colorPrinter.addstr( yStart + 2, xStart, 'Press any key to go back to selecting paths.')
Example #18
Source File: format.py From PathPicker with MIT License | 5 votes |
def updateDecoratedMatch(self, maxLen=None): '''Update the cached decorated match formatted string, and dirty the line, if needed''' if self.hovered and self.selected: attributes = (curses.COLOR_WHITE, curses.COLOR_RED, FormattedText.BOLD_ATTRIBUTE) elif self.hovered: attributes = (curses.COLOR_WHITE, curses.COLOR_BLUE, FormattedText.BOLD_ATTRIBUTE) elif self.selected: attributes = (curses.COLOR_WHITE, curses.COLOR_GREEN, FormattedText.BOLD_ATTRIBUTE) elif not self.allInput: attributes = (0, 0, FormattedText.UNDERLINE_ATTRIBUTE) else: attributes = (0, 0, 0) decoratorText = self.getDecorator() # we may not be connected to a controller (during processInput, # for example) if self.controller: self.controller.dirtyLine(self.index) plainText = decoratorText + self.getMatch() if maxLen and len(plainText + str(self.beforeText)) > maxLen: # alright, we need to chop the ends off of our # decorated match and glue them together with our # truncation decorator. We subtract the length of the # before text since we consider that important too. spaceAllowed = maxLen - len(self.TRUNCATE_DECORATOR) \ - len(decoratorText) \ - len(str(self.beforeText)) midPoint = int(spaceAllowed / 2) beginMatch = plainText[0:midPoint] endMatch = plainText[-midPoint:len(plainText)] plainText = beginMatch + self.TRUNCATE_DECORATOR + endMatch self.decoratedMatch = FormattedText( FormattedText.getSequenceForAttributes(*attributes) + plainText)
Example #19
Source File: menu_screen.py From botany with ISC License | 5 votes |
def define_colors(self): # TODO: implement colors # 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)
Example #20
Source File: cursesgui.py From ham2mon with GNU General Public License v3.0 | 5 votes |
def setup_screen(screen): """Sets up screen """ # Set screen to getch() is non-blocking screen.nodelay(1) # Define some colors 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_CYAN, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_MAGENTA, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK) # Add border screen.border(0)
Example #21
Source File: evilmaid.py From EvilAbigail with GNU General Public License v2.0 | 5 votes |
def __init__(self): """ Setup the main screen, progress bars and logging box """ self.screen = curses.initscr() curses.curs_set(0) 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_MAGENTA, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_BLUE, curses.COLOR_BLACK) curses.init_pair(6, curses.COLOR_YELLOW, curses.COLOR_BLACK) self.height, self.width = self.screen.getmaxyx() self.screen.border() self.preptotal() self.prepcurrent() self.preplog() self.banner() self.sig() self.drives = len(glob.glob("/dev/sd?1")) self.donedrives = 0 self.prevprogress = 0 self.loglines = [] self.idx = 1
Example #22
Source File: predator_prey_env.py From IC3Net with MIT License | 5 votes |
def init_curses(self): self.stdscr = curses.initscr() curses.start_color() curses.use_default_colors() curses.init_pair(1, curses.COLOR_RED, -1) curses.init_pair(2, curses.COLOR_YELLOW, -1) curses.init_pair(3, curses.COLOR_CYAN, -1) curses.init_pair(4, curses.COLOR_GREEN, -1)
Example #23
Source File: traffic_junction_env.py From IC3Net with MIT License | 5 votes |
def init_curses(self): self.stdscr = curses.initscr() curses.start_color() curses.use_default_colors() curses.init_pair(1, curses.COLOR_RED, -1) curses.init_pair(2, curses.COLOR_YELLOW, -1) curses.init_pair(3, curses.COLOR_CYAN, -1) curses.init_pair(4, curses.COLOR_GREEN, -1) curses.init_pair(5, curses.COLOR_BLUE, -1)
Example #24
Source File: ui.py From musicbox with MIT License | 5 votes |
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) curses.start_color() if Config().get("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.post_lyric = "" self.now_lyric_index = 0 self.tlyric = "" self.storage = Storage() self.config = Config() self.newversion = False
Example #25
Source File: monitor.py From foe-bot with MIT License | 5 votes |
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
Example #26
Source File: cursesDisplay.py From cbpro-trader with GNU General Public License v3.0 | 5 votes |
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...")
Example #27
Source File: fm_cli.py From baidufm-py with MIT License | 5 votes |
def setup(self, stdscr): fm_log(logger, 'init baidufm fm cli') self.stdscr = stdscr # init color 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_GREEN, curses.COLOR_BLACK) curses.init_pair(10, curses.COLOR_RED, curses.COLOR_BLACK) curses.start_color() for i in range(0, curses.COLORS): if i < 10: continue curses.init_pair(i + 1, curses.COLOR_BLACK, i) self.player = choose_player()(self.footer, self.event) self.stdscr.nodelay(0) self.setup_and_draw_screen() self.run()
Example #28
Source File: gui.py From sandsifter with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #29
Source File: sifter.py From sandsifter with BSD 3-Clause "New" or "Revised" License | 4 votes |
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)
Example #30
Source File: top.py From python-alerta-client with Apache License 2.0 | 4 votes |
def main(self, stdscr): self.screen = stdscr curses.use_default_colors() curses.init_pair(1, curses.COLOR_RED, -1) curses.init_pair(2, curses.COLOR_MAGENTA, -1) curses.init_pair(3, curses.COLOR_YELLOW, -1) curses.init_pair(4, curses.COLOR_BLUE, -1) curses.init_pair(5, curses.COLOR_CYAN, -1) curses.init_pair(6, curses.COLOR_GREEN, -1) curses.init_pair(7, curses.COLOR_WHITE, curses.COLOR_BLACK) COLOR_RED = curses.color_pair(1) COLOR_MAGENTA = curses.color_pair(2) COLOR_YELLOW = curses.color_pair(3) COLOR_BLUE = curses.color_pair(4) COLOR_CYAN = curses.color_pair(5) COLOR_GREEN = curses.color_pair(6) COLOR_BLACK = curses.color_pair(7) self.SEVERITY_MAP = { 'security': ['Sec', COLOR_BLACK], 'critical': ['Crit', COLOR_RED], 'major': ['Majr', COLOR_MAGENTA], 'minor': ['Minr', COLOR_YELLOW], 'warning': ['Warn', COLOR_BLUE], 'indeterminate': ['Ind ', COLOR_CYAN], 'cleared': ['Clr', COLOR_GREEN], 'normal': ['Norm', COLOR_GREEN], 'ok': ['Ok', COLOR_GREEN], 'informational': ['Info', COLOR_GREEN], 'debug': ['Dbug', COLOR_BLACK], 'trace': ['Trce', COLOR_BLACK], 'unknown': ['Unkn', COLOR_BLACK] } self.screen.keypad(1) self.screen.nodelay(1) while True: self.update() event = self.screen.getch() if 0 < event < 256: self._key_press(chr(event)) else: if event == curses.KEY_RESIZE: self.update() time.sleep(2)