0001 """curses 0002 0003 The main package for curses support for Python. Normally used by importing 0004 the package, and perhaps a particular module inside it. 0005 0006 import curses 0007 from curses import textpad 0008 curses.initwin() 0009 ... 0010 0011 """ 0012 0013 __revision__ = "$Id: __init__.py,v 1.5 2004/07/18 06:14:41 tim_one Exp $" 0014 0015 from _curses import * 0016 from curses.wrapper import wrapper 0017 0018 # Some constants, most notably the ACS_* ones, are only added to the C 0019 # _curses module's dictionary after initscr() is called. (Some 0020 # versions of SGI's curses don't define values for those constants 0021 # until initscr() has been called.) This wrapper function calls the 0022 # underlying C initscr(), and then copies the constants from the 0023 # _curses module to the curses package's dictionary. Don't do 'from 0024 # curses import *' if you'll be needing the ACS_* constants. 0025 0026 def initscr(): 0027 import _curses, curses 0028 stdscr = _curses.initscr() 0029 for key, value in _curses.__dict__.items(): 0030 if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): 0031 setattr(curses, key, value) 0032 0033 return stdscr 0034 0035 # This is a similar wrapper for start_color(), which adds the COLORS and 0036 # COLOR_PAIRS variables which are only available after start_color() is 0037 # called. 0038 0039 def start_color(): 0040 import _curses, curses 0041 retval = _curses.start_color() 0042 if hasattr(_curses, 'COLORS'): 0043 curses.COLORS = _curses.COLORS 0044 if hasattr(_curses, 'COLOR_PAIRS'): 0045 curses.COLOR_PAIRS = _curses.COLOR_PAIRS 0046 return retval 0047 0048 # Import Python has_key() implementation if _curses doesn't contain has_key() 0049 0050 try: 0051 has_key 0052 except NameError: 0053 from has_key import has_key 0054
Generated by PyXR 0.9.4