Skip to content

Instantly share code, notes, and snippets.

@lqc
Created December 5, 2009 19:09
Show Gist options
  • Save lqc/249812 to your computer and use it in GitHub Desktop.
Save lqc/249812 to your computer and use it in GitHub Desktop.
import curses
import sys
scr = curses.initscr()
curses.start_color()
print >> sys.stderr, curses.can_change_color()
# init additional 8 colors
for i in xrange(0, 255):
intesity = (1000*i/255)
try:
curses.init_color(i, intesity, 0, 0)
except:
print >> sys.stderr, "Failed to init color %d" % i
# init color pairs
for i in xrange(1, 255):
try:
curses.init_pair(i, i, 0)
except:
print >> sys.stderr, "Failed to initialize pair #%d" % i
pass
for i in xrange(0, 255):
try:
scr.addstr( str(i)+ ' ', curses.color_pair(i) )
except:
pass
scr.getch()
curses.endwin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment