[Python-bugs-list] [ python-Bugs-412086 ] curses module is missing some color vars

noreply@sourceforge.net noreply@sourceforge.net
Wed, 28 Mar 2001 20:07:15 -0800


Bugs item #412086, was updated on 2001-03-28 20:07
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=412086&group_id=5470

Category: Python Library
Group: None
Status: Open
Priority: 5
Submitted By: Peter Wilson (pabw)
Assigned to: Nobody/Anonymous (nobody)
Summary: curses module is missing some color vars

Initial Comment:
The _curses modules doesn't define COLORS or COLOR_PAIRS until after start_color() is called.

Adding a start_color() wrapper to curses/__init__.py along the same lines as the wrapper around initscr() fixes this.
(And I don't knowof or use any other variables that get dynamically added...)

def start_color():
    import _curses, curses  
    # This import is from the initscr() wrapper
    val = _curses.start_color()

    if _curses.__dict__.has_key('COLOR_PAIRS'):
        curses.COLOR_PAIRS = _curses.COLOR_PAIRS
    if _curses.__dict__.has_key('COLORS'):
        curses.COLORS = _curses.COLORS

    return val

-------

# Or, it's simple avoid the import in a function-level scope...
# If this version is used, then the initscr() wrapper should probably be changed to match.

import sys

def start_color():
    # If this code gets called, then these modules are guaranteed to exist:
    curses = sys.module['curses']
    _curses = sys.module['_curses']

    val = _curses.start_color()
    
    if _curses.__dict__.has_key('COLOR_PAIRS'):
        curses.COLOR_PAIRS = _curses.COLOR_PAIRS
    if _curses.__dict__.has_key('COLORS'):
        curses.COLORS = _curses.COLORS

    return val


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=412086&group_id=5470