Website hosting service by Active-Venture.com
  

 Back to Index

6.14.2 Window Objects

Window objects, as returned by initscr() and newwin() above, have the following methods:

 
addch( [y, x,] ch[, attr])
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.

 
addnstr( [y, x,] str, n[, attr])
Paint at most n characters of the string str at (y, x) with attributes attr, overwriting anything previously on the display.
 
addstr( [y, x,] str[, attr])
Paint the string str at (y, x) with attributes attr, overwriting anything previously on the display.
 
attroff( attr)
Remove attribute attr from the ``background'' set applied to all writes to the current window.
 
attron( attr)
Add attribute attr from the ``background'' set applied to all writes to the current window.
 
attrset( attr)
Set the ``background'' set of attributes to attr. This set is initially 0 (no attributes).
 
bkgd( ch[, attr])
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.
 
bkgdset( ch[, attr])
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.
 
border( [ls[, rs[, ts[, bs[, tl[, tr[, bl[, br]]]]]]]])
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:

 
Parameter  Description  Default value 
ls Left side ACS_VLINE
rs Right side ACS_VLINE
ts Top ACS_HLINE
bs Bottom ACS_HLINE
tl Upper-left corner ACS_ULCORNER
tr Upper-right corner ACS_URCORNER
bl Bottom-left corner ACS_BLCORNER
br Bottom-right corner ACS_BRCORNER

 
box( [vertch, horch])
Similar to border(), but both ls and rs are vertch and both ts and bs are horch. The default corner characters are always used by this function.
 
clear( )
Like erase(), but also causes the whole window to be repainted upon next call to refresh().
 
clearok( yes)
If yes is 1, the next call to refresh() will clear the window completely.
 
clrtobot( )
Erase from cursor to the end of the window: all lines below the cursor are deleted, and then the equivalent of clrtoeol() is performed.
 
clrtoeol( )
Erase from cursor to the end of the line.
 
cursyncup( )
Updates the current cursor position of all the ancestors of the window to reflect the current cursor position of the window.
 
delch( [x, y])
Delete any character at (y, x).
 
deleteln( )
Delete the line under the cursor. All following lines are moved up by 1 line.
 
derwin( [nlines, ncols,] begin_y, begin_x)
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.
 
echochar( ch[, attr])
Add character ch with attribute attr, and immediately call refresh() on the window.
 
enclose( y, x)
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.
 
erase( )
Clear the window.
 
getbegyx( )
Return a tuple (y, x) of co-ordinates of upper-left corner.
 
getch( [x, y])
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, -1 is returned if there is no input.
 
getkey( [x, y])
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.
 
getmaxyx( )
Return a tuple (y, x) of the height and width of the window.
 
getparyx( )
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.
 
getstr( [x, y])
Read a string from the user, with primitive line editing capacity.
 
getyx( )
Return a tuple (y, x) of current cursor position relative to the window's upper-left corner.
 
hline( [y, x,] ch, n)
Display a horizontal line starting at (y, x) with length n consisting of the character ch.
 
idcok( flag)
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.
 
idlok( yes)
If called with yes equal to 1, curses will try and use hardware line editing facilities. Otherwise, line insertion/deletion are disabled.
 
immedok( flag)
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.
 
inch( [x, y])
Return the character at the given position in the window. The bottom 8 bits are the character proper, and upper bits are the attributes.
 
insch( [y, x,] ch[, attr])
Paint character ch at (y, x) with attributes attr, moving the line from position x right by one character.
 
insdelln( nlines)
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.
 
insertln( )
Insert a blank line under the cursor. All following lines are moved down by 1 line.
 
insnstr( [y, x,] str, n [, attr])
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 rightmost characters on the line being lost. The cursor position does not change (after moving to y, x, if specified).
 
insstr( [y, x, ] str [, attr])
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 rightmost characters on the line being lost. The cursor position does not change (after moving to y, x, if specified).
 
instr( [y, x][, n])
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).
 
is_linetouched( line)
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.
 
is_wintouched( )
Returns true if the specified window was modified since the last call to refresh(); otherwise returns false.
 
keypad( yes)
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.
 
leaveok( yes)
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.

 
move( new_y, new_x)
Move cursor to (new_y, new_x).
 
mvderwin( y, x)
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.
 
mvwin( new_y, new_x)
Move the window so its upper-left corner is at (new_y, new_x).
 
nodelay( yes)
If yes is 1, getch() will be non-blocking.
 
notimeout( yes)
If yes is 1, escape sequences will not be timed out.

If yes is 0, after a few milliseconds, an escape sequence will not be interpreted, and will be left in the input stream as is.

 
noutrefresh( )
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( destwin[, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])
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( destwin[, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])
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.

 
putwin( file)
Writes all data associated with the window into the provided file object. This information can be later retrieved using the getwin() function.
 
redrawln( beg, num)
Indicates that the num screen lines, starting at line beg, are corrupted and should be completely redrawn on the next refresh() call.
 
redrawwin( )
Touches the entire window, causing it to be completely redrawn on the next refresh() call.
 
refresh( [pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])
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.

 
scroll( [lines = 1])
Scroll the screen or scrolling region upward by lines lines.
 
scrollok( flag)
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().
 
setscrreg( top, bottom)
Set the scrolling region from line top to line bottom. All scrolling actions will take place in this region.
 
standend( )
Turn off the standout attribute. On some terminals this has the side effect of turning off all attributes.
 
standout( )
Turn on attribute A_STANDOUT.
 
subpad( [nlines, ncols,] begin_y, begin_x)
Return a sub-window, whose upper-left corner is at (begin_y, begin_x), and whose width/height is ncols/nlines.
 
subwin( [nlines, ncols,] begin_y, begin_x)
Return a sub-window, whose upper-left corner is at (begin_y, begin_x), and whose width/height is ncols/nlines.

By default, the sub-window will extend from the specified position to the lower right corner of the window.

 
syncdown( )
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.
 
syncok( flag)
If called with flag set to true, then syncup() is called automatically whenever there is a change in the window.
 
syncup( )
Touches all locations in ancestors of the window that have been changed in the window.
 
timeout( delay)
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.
 
touchline( start, count)
Pretend count lines have been changed, starting with line start.
 
touchwin( )
Pretend the whole window has been changed, for purposes of drawing optimizations.
 
untouchwin( )
Marks all lines in the window as unchanged since the last call to refresh().
 
vline( [y, x,] ch, n)
Display a vertical line starting at (y, x) with length n consisting of the character ch.

  

 

2002-2004 Active-Venture.com Webhosting Service

 

Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to http://python.org/doc/

 

Cheap domain name - Cheap domain name registration service including free domain hosting services   Domain registration - Domain registration, domain name transfer and domain search services