Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 289d9d4

Browse files
committed
Add wrapper for initscr() to copy the ACS_ and LINES,COLS bindings
1 parent 99a5621 commit 289d9d4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lib/curses/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,20 @@
1515
from _curses import *
1616
from curses.wrapper import wrapper
1717

18+
# Some constants, most notably the ACS_* ones, are only added to the C
19+
# _curses module's dictionary after initscr() is called. (Some
20+
# versions of SGI's curses don't define values for those constants
21+
# until initscr() has been called.) This wrapper function calls the
22+
# underlying C initscr(), and then copies the constants from the
23+
# _curses module to the curses package's dictionary. Don't do 'from
24+
# curses import *' if you'll be needing the ACS_* constants.
25+
26+
def initscr():
27+
import _curses, curses
28+
stdscr = _curses.initscr()
29+
for key, value in _curses.__dict__.items():
30+
if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
31+
setattr(curses, key, value)
32+
33+
return stdscr
1834

0 commit comments

Comments
 (0)