Note:
A character means a C character (an
ASCII code), rather then a Python character (a string of length 1).
(This note is true whenever the documentation mentions a character.)
The builtin ord() is handy for conveying strings to codes.
Paint character ch at (y, x) with attributes
attr, overwriting any character previously painter at that
location. By default, the character position and attributes are the
current settings for the window object.
Sets the background property of the window to the character ch,
with attributes attr. The change is then applied to every
character position in that window:
The attribute of every character in the window is
changed to the new background attribute.
Wherever the former background character appears,
it is changed to the new background character.
Sets the window's background. A window's background consists of a
character and any combination of attributes. The attribute part of
the background is combined (OR'ed) with all non-blank characters that
are written into the window. Both the character and attribute parts
of the background are combined with the blank characters. The
background becomes a property of the character and moves with the
character through any scrolling and insert/delete line/character
operations.
Draw a border around the edges of the window. Each parameter specifies
the character to use for a specific part of the border; see the table
below for more details. The characters can be specified as integers
or as one-character strings.
Note:
A 0 value for any parameter will cause the
default character to be used for that parameter. Keyword parameters
can not be used. The defaults are listed in this table:
An abbreviation for ``derive window'', derwin() is the same
as calling subwin(), except that begin_y and
begin_x are relative to the origin of the window, rather than
relative to the entire screen. Returns a window object for the
derived window.
Tests whether the given pair of screen-relative character-cell
coordinates are enclosed by the given window, returning true or
false. It is useful for determining what subset of the screen
windows enclose the location of a mouse event.
Get a character. Note that the integer returned does not have to
be in ASCII range: function keys, keypad keys and so on return numbers
higher than 256. In no-delay mode, an exception is raised if there is
no input.
Get a character, returning a string instead of an integer, as
getch() does. Function keys, keypad keys and so on return a
multibyte string containing the key name. In no-delay mode, an
exception is raised if there is no input.
Returns the beginning coordinates of this window relative to its
parent window into two integer variables y and x. Returns
-1,-1 if this window has no parent.
If flag is false, curses no longer considers using the hardware
insert/delete character feature of the terminal; if flag is
true, use of character insertion and deletion is enabled. When curses
is first initialized, use of character insert/delete is enabled by
default.
If flag is true, any change in the window image
automatically causes the window to be refreshed; you no longer
have to call refresh() yourself. However, it may
degrade performance considerably, due to repeated calls to
wrefresh. This option is disabled by default.
Inserts nlines lines into the specified window above the current
line. The nlines bottom lines are lost. For negative
nlines, delete nlines lines starting with the one under
the cursor, and move the remaining lines up. The bottom nlines
lines are cleared. The current cursor position remains the same.
Insert a character string (as many characters as will fit on the line)
before the character under the cursor, up to n characters.
If n is zero or negative,
the entire string is inserted.
All characters to the right of
the cursor are shifted right, with the the rightmost characters on the
line being lost. The cursor position does not change (after moving to
y, x, if specified).
Insert a character string (as many characters as will fit on the line)
before the character under the cursor. All characters to the right of
the cursor are shifted right, with the the rightmost characters on the
line being lost. The cursor position does not change (after moving to
y, x, if specified).
Returns a string of characters, extracted from the window starting at
the current cursor position, or at y, x if specified.
Attributes are stripped from the characters. If n is specified,
instr() returns return a string at most n characters
long (exclusive of the trailing NUL).
Returns true if the specified line was modified since the last call to
refresh(); otherwise returns false. Raises a
curses.error exception if line is not valid
for the given window.
If yes is 1, escape sequences generated by some keys (keypad,
function keys) will be interpreted by curses.
If yes is 0, escape sequences will be left as is in the input
stream.
If yes is 1, cursor is left where it is on update, instead of
being at ``cursor position.'' This reduces cursor movement where
possible. If possible the cursor will be made invisible.
If yes is 0, cursor will always be at ``cursor position'' after
an update.
Moves the window inside its parent window. The screen-relative
parameters of the window are not changed. This routine is used to
display different parts of the parent window at the same physical
position on the screen.
Mark for refresh but wait. This function updates the data structure
representing the desired state of the window, but does not force
an update of the physical screen. To accomplish that, call
doupdate().
Overlay the window on top of destwin. The windows need not be
the same size, only the overlapping region is copied. This copy is
non-destructive, which means that the current background character
does not overwrite the old contents of destwin.
To get fine-grained control over the copied region, the second form
of overlay() can be used. sminrow and smincol are
the upper-left coordinates of the source window, and the other variables
mark a rectangle in the destination window.
Overwrite the window on top of destwin. The windows need not be
the same size, in which case only the overlapping region is
copied. This copy is destructive, which means that the current
background character overwrites the old contents of destwin.
To get fine-grained control over the copied region, the second form
of overwrite() can be used. sminrow and smincol are
the upper-left coordinates of the source window, the other variables
mark a rectangle in the destination window.
Update the display immediately (sync actual screen with previous
drawing/deleting methods).
The 6 optional arguments can only be specified when the window is a
pad created with newpad(). The additional parameters are
needed to indicate what part of the pad and screen are involved.
pminrow and pmincol specify the upper left-hand corner of the
rectangle to be displayed in the pad. sminrow, smincol,
smaxrow, and smaxcol specify the edges of the rectangle to
be displayed on the screen. The lower right-hand corner of the
rectangle to be displayed in the pad is calculated from the screen
coordinates, since the rectangles must be the same size. Both
rectangles must be entirely contained within their respective
structures. Negative values of pminrow, pmincol,
sminrow, or smincol are treated as if they were zero.
Controls what happens when the cursor of a window is moved off the
edge of the window or scrolling region, either as a result of a
newline action on the bottom line, or typing the last character
of the last line. If flag is false, the cursor is left
on the bottom line. If flag is true, the window is
scrolled up one line. Note that in order to get the physical
scrolling effect on the terminal, it is also necessary to call
idlok().
Touches each location in the window that has been touched in any of
its ancestor windows. This routine is called by refresh(),
so it should almost never be necessary to call it manually.
Sets blocking or non-blocking read behavior for the window. If
delay is negative, blocking read is used, which will wait
indefinitely for input). If delay is zero, then non-blocking
read is used, and -1 will be returned by getch() if no input
is waiting. If delay is positive, then getch() will
block for delay milliseconds, and return -1 if there is still no
input at the end of that time.