PyDocs

Command-line interface libraries

curses

not Androidnot iOSnot WASI

curses

The main package for curses support for Python.  Normally used by importing
the package, and perhaps a particular module inside it.

   import curses
   from curses import textpad
   curses.initscr()
   ...
Symbols in curses

a

A_ALTCHARSET
Alternate character set mode
A_ATTRIBUTES
Bit-mask to extract attributes
A_BLINK
Blink mode
A_BOLD
Bold mode
A_CHARTEXT
Bit-mask to extract a character
A_COLOR
Bit-mask to extract color-pair field information
A_DIM
Dim mode
A_HORIZONTAL
Horizontal highlight
A_INVIS
Invisible or blank mode
A_ITALIC
Italic mode
A_LEFT
Left highlight
A_LOW
Low highlight
A_NORMAL
Normal attribute
A_PROTECT
Protected mode
A_REVERSE
Reverse background and foreground colors
A_RIGHT
Right highlight
A_STANDOUT
Standout mode
A_TOP
Top highlight
A_UNDERLINE
Underline mode
A_VERTICAL
Vertical highlight
ACS_BBSS
alternate name for upper-right corner
ACS_BLOCK
solid square block
ACS_BOARD
board of squares
ACS_BSBS
alternate name for horizontal line
ACS_BSSB
alternate name for upper-left corner
ACS_BSSS
alternate name for top tee
ACS_BTEE
bottom tee
ACS_CKBOARD
checker board (stipple)
ACS_DARROW
arrow pointing down
ACS_DEGREE
degree symbol
ACS_GEQUAL
greater-than-or-equal-to
ACS_HLINE
horizontal line
ACS_LANTERN
lantern symbol
ACS_LARROW
left arrow
ACS_LEQUAL
less-than-or-equal-to
ACS_LLCORNER
lower-left corner
ACS_LRCORNER
lower-right corner
ACS_LTEE
left tee
ACS_NEQUAL
not-equal sign
ACS_PI
letter pi
ACS_PLMINUS
plus-or-minus sign
ACS_PLUS
big plus sign
ACS_RARROW
right arrow
ACS_RTEE
right tee
ACS_S1
scan line 1
ACS_S3
scan line 3
ACS_S7
scan line 7
ACS_S9
scan line 9
ACS_SBBS
alternate name for lower-right corner
ACS_SBSB
alternate name for vertical line
ACS_SBSS
alternate name for right tee
ACS_SSBB
alternate name for lower-left corner
ACS_SSBS
alternate name for bottom tee
ACS_SSSB
alternate name for left tee
ACS_SSSS
alternate name for crossover or big plus
ACS_STERLING
pound sterling
ACS_TTEE
top tee
ACS_UARROW
up arrow
ACS_ULCORNER
upper-left corner
ACS_URCORNER
upper-right corner
ACS_VLINE
vertical line
assume_default_colors
Allow use of default values for colors on terminals supporting this feature.

b

baudrate
Return the output speed of the terminal in bits per second.
beep
Emit a short attention sound.
BUTTON_ALT
Alt was down during button state change
BUTTON_CTRL
Control was down during button state change
BUTTON_SHIFT
Shift was down during button state change
BUTTONn_CLICKED
Mouse button n clicked
BUTTONn_DOUBLE_CLICKED
Mouse button n double clicked
BUTTONn_PRESSED
Mouse button n pressed
BUTTONn_RELEASED
Mouse button n released
BUTTONn_TRIPLE_CLICKED
Mouse button n triple clicked

c

can_change_color
Return True if the programmer can change the colors displayed by the terminal.
cbreak
Enter cbreak mode.
color_content
Return the red, green, and blue (RGB) components of the specified color.
COLOR_CYAN
Cyan (light greenish blue)
COLOR_MAGENTA
Magenta (purplish red)
color_pair
Return the attribute value for displaying text in the specified color.
COLOR_PAIRS
The maximum number of color pairs the terminal can support.
COLORS
The maximum number of colors the terminal can support.
COLS
The width of the screen, that is, the number of columns.
curs_set
Set the cursor state.

d

def_prog_mode
Save the current terminal mode as the "program" mode.
def_shell_mode
Save the current terminal mode as the "shell" mode.
delay_output
Insert a pause in output.
doupdate
Update the physical screen to match the virtual screen.

e

echo
Enter echo mode.
endwin
De-initialize the library, and return terminal to normal status.
erasechar
Return the user's current erase character.
ERR
Some curses routines that return an integer, such as getch(), return ERR upon failure.
error
Exception raised when a curses library function returns an error.

f

filter
Restrict screen updates to the current line.
flash
Flash the screen.
flushinp
Flush all input buffers.

g

get_escdelay
Gets the curses ESCDELAY setting.
get_tabsize
Gets the curses TABSIZE setting.
getmouse
Retrieve the queued mouse event.
getsyx
Return the current coordinates of the virtual screen cursor.
getwin
Read window related data stored in the file by an earlier putwin() call.

h

halfdelay
Enter half-delay mode.
has_colors
Return True if the terminal can display colors; otherwise, return False.
has_extended_color_support
Return True if the module supports extended colors; otherwise, return False.
has_ic
Return True if the terminal has insert- and delete-character capabilities.
has_il
Return True if the terminal has insert- and delete-line capabilities.
has_key
Return True if the current terminal type recognizes a key with that value.

i

init_color
Change the definition of a color.
init_pair
Change the definition of a color-pair.
initscr
Initialize the library.
intrflush
Control flushing of the output buffer when an interrupt key is pressed.
is_term_resized
Return True if resize_term() would modify the window structure, False otherwise.
isendwin
Return True if endwin() has been called.

k

KEY_A1
Upper left of keypad
KEY_A3
Upper right of keypad
KEY_B2
Center of keypad
KEY_BACKSPACE
Backspace (unreliable)
KEY_BEG
Beg (beginning)
KEY_BREAK
Break key (unreliable)
KEY_BTAB
Back tab
KEY_C1
Lower left of keypad
KEY_C3
Lower right of keypad
KEY_CATAB
Clear all tabs
KEY_CLEAR
Clear screen
KEY_COMMAND
Cmd (command)
KEY_CTAB
Clear tab
KEY_DC
Delete character
KEY_DL
Delete line
KEY_DOWN
Down-arrow
KEY_EIC
Exit insert char mode
KEY_ENTER
Enter or send (unreliable)
KEY_EOL
Clear to end of line
KEY_EOS
Clear to end of screen
KEY_F0
Function keys.
KEY_Fn
Value of function key n
KEY_HOME
Home key (upward+left arrow)
KEY_IC
Insert char or enter insert mode
KEY_IL
Insert line
KEY_LEFT
Left-arrow
KEY_LL
Home down or bottom (lower left)
KEY_MAX
Maximum key value
KEY_MIN
Minimum key value
KEY_MOUSE
Mouse event has occurred
KEY_NPAGE
Next page
KEY_PPAGE
Previous page
KEY_PREVIOUS
Prev (previous)
KEY_REFERENCE
Ref (reference)
KEY_RESET
Reset or hard reset (unreliable)
KEY_RESIZE
Terminal resize event
KEY_RIGHT
Right-arrow
KEY_SBEG
Shifted Beg (beginning)
KEY_SCANCEL
Shifted Cancel
KEY_SCOMMAND
Shifted Command
KEY_SCOPY
Shifted Copy
KEY_SCREATE
Shifted Create
KEY_SDC
Shifted Delete char
KEY_SDL
Shifted Delete line
KEY_SEND
Shifted End
KEY_SEOL
Shifted Clear line
KEY_SEXIT
Shifted Exit
KEY_SF
Scroll 1 line forward
KEY_SFIND
Shifted Find
KEY_SHELP
Shifted Help
KEY_SHOME
Shifted Home
KEY_SIC
Shifted Input
KEY_SLEFT
Shifted Left arrow
KEY_SMESSAGE
Shifted Message
KEY_SMOVE
Shifted Move
KEY_SNEXT
Shifted Next
KEY_SOPTIONS
Shifted Options
KEY_SPREVIOUS
Shifted Prev
KEY_SPRINT
Shifted Print
KEY_SR
Scroll 1 line backward (reverse)
KEY_SREDO
Shifted Redo
KEY_SREPLACE
Shifted Replace
KEY_SRESET
Soft (partial) reset (unreliable)
KEY_SRIGHT
Shifted Right arrow
KEY_SRSUME
Shifted Resume
KEY_SSAVE
Shifted Save
KEY_SSUSPEND
Shifted Suspend
KEY_STAB
Set tab
KEY_SUNDO
Shifted Undo
KEY_UP
Up-arrow
keyname
Return the name of specified key.
killchar
Return the user's current line kill character.

l

LINES
The height of the screen, that is, the number of lines.
longname
Return the terminfo long name field describing the current terminal.

m

meta
Enable/disable meta keys.
mouseinterval
Set and retrieve the maximum time between press and release in a click.
mousemask
Set the mouse events to be reported, and return (availmask, oldmask).

n

napms
Sleep for specified time.
ncurses_version
A named tuple containing the three components of the ncurses library version: major, minor, and patch.
newpad
Create and return a pointer to a new pad data structure.
newwin
Return a new window.
nl
Enter newline mode.
nocbreak
Leave cbreak mode.
noecho
Leave echo mode.
nonl
Leave newline mode.
noqiflush
Disable queue flushing.
noraw
Leave raw mode.

o

OK
Some curses routines that return an integer, such as napms(), return OK upon success.

p

pair_content
Return a tuple (fg, bg) containing the colors for the requested color pair.
pair_number
Return the number of the color-pair set by the specified attribute value.
putp
Emit the value of a specified terminfo capability for the current terminal.

q

qiflush
Enable queue flushing.

r

raw
Enter raw mode.
reset_prog_mode
Restore the terminal to "program" mode, as previously saved by def_prog_mode().
reset_shell_mode
Restore the terminal to "shell" mode, as previously saved by def_shell_mode().
resetty
Restore terminal mode.
resize_term
Backend function used by resizeterm(), performing most of the work.
resizeterm
Resize the standard and current windows to the specified dimensions.

s

savetty
Save terminal mode.
set_escdelay
Sets the curses ESCDELAY setting.
set_tabsize
Sets the curses TABSIZE setting.
setsyx
Set the virtual screen cursor.
setupterm
Initialize the terminal.
start_color
Initializes eight basic colors and global variables COLORS and COLOR_PAIRS.

t

termattrs
Return a logical OR of all video attributes supported by the terminal.
termname
Return the value of the environment variable TERM, truncated to 14 characters.
tigetflag
Return the value of the Boolean capability.
tigetnum
Return the value of the numeric capability.
tigetstr
Return the value of the string capability.
tparm
Instantiate the specified byte string with the supplied parameters.
typeahead
Specify that the file descriptor fd be used for typeahead checking.

u

unctrl
Return a bytes object which is a printable representation of ch.
unget_wch
Push ch so the next get_wch() will return it.
ungetch
Push ch so the next getch() will return it.
ungetmouse
Push a KEY_MOUSE event onto the input queue.
update_lines_cols
Update the LINES and COLS module variables.
use_default_colors
Equivalent to assume_default_colors(-1, -1).
use_env
Use environment variables LINES and COLUMNS.

v

version
A bytes object representing the current version of the module.

w

window
A curses window.
wrapper
Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error.