dynamic or on-the-fly color changing in curses?

exarkun at divmod.com exarkun at divmod.com
Tue Nov 2 16:51:21 EST 2004


On Tue, 02 Nov 2004 21:43:13 GMT, Matt Garman <fake at not-real.bogus> wrote:
>I'd like to write a class or module in python that allows me to do
> on-the-fly color changing in the curses module.
> 
> [snip - curses examples]
> 
> But when I do that, all strings show up as green.  My assumption
> here is that all strings are assigned to color_pair(1), and when
> those strings are drawn, they assume the most recent definition of
> color_pair(1).  In other words, it appears you can't "recycle" color
> pair definitions.
> 
> So my second thought was to just pre-define every possible
> combination, but, at least on Linux, I'm limited to 63 unique
> colors, whereas I can create more than 63 color combinations
> (foreground, background, and attribute combinations).
> 
> Am I strictly limited to using at most curses.COLOR_PAIRS colors on
> a per-application basis?

  There are only 64 combinations (8 of which render the text unreadable), so being limited to 63 doesn't seem like that big of a drawback to me.

  Am I missing something?

  Jp



More information about the Python-list mailing list