Movatterモバイル変換


[0]ホーム

URL:


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:6.13.1 FunctionsUp:6.13 cursesNext:6.13.3 Constants

 
6.13.2 Window Objects

Window objects, as returned byinitscr() andnewwin() above, have thefollowing methods:

addch([y, x,] ch[, attr])
Note:Acharacter means a C character (anASCII code), rather then a Python character (a string of length 1).(This note is true whenever the documentation mentions a character.)The builtinord() is handy for conveying strings to codes.

Paint characterch at(y,x) with attributesattr, overwriting any character previously painter at thatlocation. By default, the character position and attributes are thecurrent settings for the window object.

addnstr([y, x,] str, n[, attr])
Paint at mostn characters of the stringstr at(y,x) with attributesattr, overwriting anything previously on the display.

addstr([y, x,] str[, attr])
Paint the stringstr at(y,x) with attributesattr, overwriting anything previously on the display.

attroff(attr)
Remove attributeattr from the ``background'' set applied to allwrites to the current window.

attron(attr)
Add attributeattr from the ``background'' set applied to allwrites to the current window.

attrset(attr)
Set the ``background'' set of attributes toattr. This set isinitially 0 (no attributes).

bkgd(ch[, attr])
Sets the background property of the window to the characterch,with attributesattr. The change is then applied to everycharacter position in that window:

bkgdset(ch[, attr])
Sets the window's background. A window's background consists of acharacter and any combination of attributes. The attribute part ofthe background is combined (OR'ed) with all non-blank characters thatare written into the window. Both the character and attribute partsof the background are combined with the blank characters. Thebackground becomes a property of the character and moves with thecharacter through any scrolling and insert/delete line/characteroperations.

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 tablebelow for more details. The characters can be specified as integersor as one-character strings.

Note:A0 value for any parameter will cause thedefault character to be used for that parameter. Keyword parameterscannot be used. The defaults are listed in this table:

Parameter Description Default value 
lsLeft sideACS_VLINE
rsRight sideACS_VLINE
tsTopACS_HLINE
bsBottomACS_HLINE
tlUpper-left cornerACS_ULCORNER
trUpper-right cornerACS_URCORNER
blBottom-left cornerACS_BLCORNER
brBottom-right cornerACS_BRCORNER

box([vertch, horch])
Similar toborder(), but bothls andrs arevertch and bothts and bs arehorch. The defaultcorner characters are always used by this function.

clear()
Likeerase(), but also causes the whole window to be repaintedupon next call torefresh().

clearok(yes)
Ifyes is 1, the next call torefresh()will clear the window completely.

clrtobot()
Erase from cursor to the end of the window: all lines below the cursorare deleted, and then the equivalent ofclrtoeol() is performed.

clrtoeol()
Erase from cursor to the end of the line.

cursyncup()
Updates the current cursor position of all the ancestors of the windowto 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 upby 1 line.

derwin([nlines, ncols,] begin_y, begin_x)
An abbreviation for ``derive window'',derwin() is the sameas callingsubwin(), except thatbegin_y andbegin_x are relative to the origin of the window, rather thanrelative to the entire screen. Returns a window object for thederived window.

echochar(ch[, attr])
Add characterch with attributeattr, and immediately callrefresh() on the window.

enclose(y, x)
Tests whether the given pair of screen-relative character-cellcoordinates are enclosed by the given window, returning true orfalse. It is useful for determining what subset of the screenwindows enclose the location of a mouse event.

erase()
Clear the window.

getbegyx()
Return a tuple(y,x) of co-ordinates of upper-leftcorner.

getch([x, y])
Get a character. Note that the integer returned doesnot have tobe in ASCII range: function keys, keypad keys and so on return numbershigher than 256. In no-delay mode, an exception is raised if there is no input.

getkey([x, y])
Get a character, returning a string instead of an integer, asgetch() does. Function keys, keypad keys and so on return amultibyte string containing the key name. In no-delay mode, anexception is raised if there is no input.

getmaxyx()
Return a tuple(y,x) of the height and width ofthe window.

getparyx()
Returns the beginning coordinates of this window relative to itsparent 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) withlengthn consisting of the characterch.

idcok(flag)
Ifflag is false, curses no longer considers using the hardwareinsert/delete character feature of the terminal; ifflag istrue, use of character insertion and deletion is enabled. When cursesis first initialized, use of character insert/delete is enabled bydefault.

idlok(yes)
If called withyes equal to 1,curses will try and usehardware line editing facilities. Otherwise, line insertion/deletionare disabled.

immedok(flag)
Ifflag is true, any change in the window imageautomatically causes the window to be refreshed; you no longerhave to callrefresh() yourself. However, it maydegrade performance considerably, due to repeated calls towrefresh. This option is disabled by default.

inch([x, y])
Return the character at the given position in the window. The bottom8 bits are the character proper, and upper bits are the attributes.

insch([y, x,] ch[, attr])
Paint characterch at(y,x) with attributesattr, moving the line from positionx right by onecharacter.

insdelln(nlines)
Insertsnlines lines into the specified window above the currentline. Thenlines bottom lines are lost. For negativenlines, deletenlines lines starting with the one underthe cursor, and move the remaining lines up. The bottomnlineslines are cleared. The current cursor position remains the same.

insertln()
Insert a blank line under the cursor. All following lines are moveddown 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 ton characters. Ifn is zero or negative,the entire string is inserted.All characters to the right ofthe cursor are shifted right, with the the rightmost characters on theline being lost. The cursor position does not change (after moving toy,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 ofthe cursor are shifted right, with the the rightmost characters on theline being lost. The cursor position does not change (after moving toy,x, if specified).

instr([y, x][, n])
Returns a string of characters, extracted from the window starting atthe current cursor position, or aty,x if specified.Attributes are stripped from the characters. Ifn is specified,instr() returns return a string at mostn characterslong (exclusive of the trailing NUL).

is_linetouched(line)
Returns true if the specified line was modified since the last call torefresh(); otherwise returns false. Raises acurses.error exception ifline is not validfor the given window.

is_wintouched()
Returns true if the specified window was modified since the last call torefresh(); otherwise returns false.

keypad(yes)
Ifyes is 1, escape sequences generated by some keys (keypad, function keys) will be interpreted bycurses.Ifyes is 0, escape sequences will be left as is in the inputstream.

leaveok(yes)
Ifyes is 1, cursor is left where it is on update, instead ofbeing at ``cursor position.'' This reduces cursor movement wherepossible. If possible the cursor will be made invisible.

Ifyes is 0, cursor will always be at ``cursor position'' afteran 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-relativeparameters of the window are not changed. This routine is used todisplay different parts of the parent window at the same physicalposition on the screen.

mvwin(new_y, new_x)
Move the window so its upper-left corner is at(new_y,new_x).

nodelay(yes)
Ifyes is1,getch() will be non-blocking.

notimeout(yes)
Ifyes is1, escape sequences will not be timed out.

Ifyes is0, after a few milliseconds, an escape sequencewill not be interpreted, and will be left in the input stream as is.

noutrefresh()
Mark for refresh but wait. This function updates the data structurerepresenting the desired state of the window, but does not forcean update of the physical screen. To accomplish that, calldoupdate().

overlay(destwin[, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])
Overlay the window on top ofdestwin. The windows need not bethe same size, only the overlapping region is copied. This copy isnon-destructive, which means that the current background characterdoes not overwrite the old contents ofdestwin.

To get fine-grained control over the copied region, the second formofoverlay() can be used.sminrow andsmincol arethe upper-left coordinates of the source window, and the other variablesmark a rectangle in the destination window.

overwrite(destwin[, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])
Overwrite the window on top ofdestwin. The windows need not bethe same size, in which case only the overlapping region iscopied. This copy is destructive, which means that the currentbackground character overwrites the old contents ofdestwin.

To get fine-grained control over the copied region, the second formofoverwrite() can be used.sminrow andsmincol arethe upper-left coordinates of the source window, the other variablesmark a rectangle in the destination window.

putwin(file)
Writes all data associated with the window into the provided fileobject. This information can be later retrieved using thegetwin() function.

redrawln(beg, num)
Indicates that thenum screen lines, starting at linebeg,are corrupted and should be completely redrawn on the nextrefresh() call.

redrawwin()
Touches the entire window, causing it to be completely redrawn on thenextrefresh() call.

refresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])
Update the display immediately (sync actual screen with previousdrawing/deleting methods).

The 6 optional arguments can only be specified when the window is apad created withnewpad(). The additional parameters areneeded to indicate what part of the pad and screen are involved.pminrow andpmincol specify the upper left-hand corner of therectangle to be displayed in the pad.sminrow,smincol,smaxrow, andsmaxcol specify the edges of the rectangle tobe displayed on the screen. The lower right-hand corner of therectangle to be displayed in the pad is calculated from the screencoordinates, since the rectangles must be the same size. Bothrectangles must be entirely contained within their respectivestructures. Negative values ofpminrow,pmincol,sminrow, orsmincol are treated as if they were zero.

scroll([lines = 1])
Scroll the screen or scrolling region upward bylines lines.

scrollok(flag)
Controls what happens when the cursor of a window is moved off theedge of the window or scrolling region, either as a result of anewline action on the bottom line, or typing the last characterof the last line. Ifflag is false, the cursor is lefton the bottom line. Ifflag is true, the window isscrolled up one line. Note that in order to get the physicalscrolling effect on the terminal, it is also necessary to callidlok().

setscrreg(top, bottom)
Set the scrolling region from linetop to linebottom. Allscrolling actions will take place in this region.

standend()
Turn off the standout attribute. On some terminals this has theside effect of turning off all attributes.

standout()
Turn on attributeA_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 isncols/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 isncols/nlines.

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

syncdown()
Touches each location in the window that has been touched in any ofits ancestor windows. This routine is called byrefresh(),so it should almost never be necessary to call it manually.

syncok(flag)
If called withflag set to true, thensyncup() iscalled 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. Ifdelay is negative, blocking read is used (which will waitindefinitely for input). Ifdelay is zero, then non-blockingread is used, and -1 will be returned bygetch() if no inputis waiting. Ifdelay is positive, thengetch() willblock fordelay milliseconds, and return -1 if there is still noinput at the end of that time.

touchline(start, count)
Pretendcount lines have been changed, starting with linestart.

touchwin()
Pretend the whole window has been changed, for purposes of drawingoptimizations.

untouchwin()
Marks all lines in the window as unchanged since the last call torefresh().

vline([y, x,] ch, n)
Display a vertical line starting at(y,x) withlengthn consisting of the characterch.


Previous PageUp One LevelNext PagePython Library ReferenceContentsModule IndexIndex
Previous:6.13.1 FunctionsUp:6.13 cursesNext:6.13.3 Constants
Release 2.2.3, documentation updated on 30 May 2003.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2026 Movatter.jp