⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 curses-window-objects.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>6.12.2 Window Objects </title>
<META NAME="description" CONTENT="6.12.2 Window Objects ">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" HREF="node128.html" tppabs="http://www.python.org/doc/current/lib/node128.html">
<LINK REL="previous" href="curses-functions.html" tppabs="http://www.python.org/doc/current/lib/curses-functions.html">
<LINK REL="up" href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html">
<LINK REL="next" HREF="node128.html" tppabs="http://www.python.org/doc/current/lib/node128.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="curses-functions.html" tppabs="http://www.python.org/doc/current/lib/curses-functions.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A HREF="node128.html" tppabs="http://www.python.org/doc/current/lib/node128.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="curses-functions.html" tppabs="http://www.python.org/doc/current/lib/curses-functions.html">6.12.1 Functions</A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-curses.html" tppabs="http://www.python.org/doc/current/lib/module-curses.html">6.12 curses  </A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node128.html" tppabs="http://www.python.org/doc/current/lib/node128.html">6.12.3 Constants</A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H2>
<BR>
6.12.2 Window Objects 
</H2>

<P>
Window objects, as returned by <tt class="function">initscr()</tt> and
<tt class="function">newwin()</tt> above, have the
following methods:

<P>
<dl><dt><b><a name='l2h-1236'><tt class='method'>addch</tt></a></b> (<big>[</big><var>y, x,</var><big>]</big><var> ch</var><big>[</big><var>, attr</var><big>]</big>)
<dd>
<b>Note:</b> A <i>character</i> means a C character (i.e., 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 <tt class="function">ord()</tt> is handy for conveying strings to codes.

<P>
Paint character <var>ch</var> at <code>(<var>y</var>, <var>x</var>)</code> with attributes
<var>attr</var>, overwriting any character previously painter at that
location.  By default, the character position and attributes are the
current settings for the window object.
</dl>

<P>
<dl><dt><b><a name='l2h-1237'><tt class='method'>addnstr</tt></a></b> (<big>[</big><var>y, x,</var><big>]</big><var> str, n</var><big>[</big><var>, attr</var><big>]</big>)
<dd>
Paint at most <var>n</var> characters of the 
string <var>str</var> at <code>(<var>y</var>, <var>x</var>)</code> with attributes
<var>attr</var>, overwriting anything previously on the display.
</dl>

<P>
<dl><dt><b><a name='l2h-1238'><tt class='method'>addstr</tt></a></b> (<big>[</big><var>y, x,</var><big>]</big><var> str</var><big>[</big><var>, attr</var><big>]</big>)
<dd>
Paint the string <var>str</var> at <code>(<var>y</var>, <var>x</var>)</code> with attributes
<var>attr</var>, overwriting anything previously on the display.
</dl>

<P>
<dl><dt><b><a name='l2h-1239'><tt class='method'>attroff</tt></a></b> (<var>attr</var>)
<dd>
Remove attribute <var>attr</var> from the ``background'' set applied to all
writes to the current window.
</dl>

<P>
<dl><dt><b><a name='l2h-1240'><tt class='method'>attron</tt></a></b> (<var>attr</var>)
<dd>
Add attribute <var>attr</var> from the ``background'' set applied to all
writes to the current window.
</dl>

<P>
<dl><dt><b><a name='l2h-1241'><tt class='method'>attrset</tt></a></b> (<var>attr</var>)
<dd>
Set the ``background'' set of attributes to <var>attr</var>.  This set is
initially 0 (no attributes).
</dl>

<P>
<dl><dt><b><a name='l2h-1242'><tt class='method'>bkgd</tt></a></b> (<var>ch</var><big>[</big><var>, attr</var><big>]</big>)
<dd>
Sets the background property of the window to the character <var>ch</var>,
with attributes <var>attr</var>.  The change is then applied to every
character position in that window:

<UL>
<LI>The attribute of every character in the window  is
changed to the new background attribute.
</LI>
<LI>Wherever  the  former background character appears,
it is changed to the new background character.
</LI>
</UL>

<P>
</dl>

<P>
<dl><dt><b><a name='l2h-1243'><tt class='method'>bkgdset</tt></a></b> (<var>ch</var><big>[</big><var>, attr</var><big>]</big>)
<dd>
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.
</dl>

<P>
<dl><dt><b><a name='l2h-1244'><tt class='method'>border</tt></a></b> (<big>[</big><var>ls</var><big>[</big><var>, rs</var><big>[</big><var>, ts</var><big>[</big><var>,
                           bs</var><big>[</big><var>, tl</var><big>[</big><var>, tr</var><big>[</big><var>,
                           bl</var><big>[</big><var>, br</var><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big>)
<dd>
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 must be specified as integers;
using one-character strings will cause <tt class="exception">TypeError</tt> to be
raised.

<P>
<b>Note:</b> A <code>0</code> value for any parameter will cause the
default character to be used for that parameter.  Keyword parameters
can <i>not</i> be used.  The defaults are listed in this table:

<P>
<table border align="center" style="border-collapse: collapse">
  <thead>
    <tr>
      <th align="left"><b>Parameter</b>&nbsp;</th>
      <th align="left"><b>Description</b>&nbsp;</th>
      <th align="left"><b>Default value</b>&nbsp;</th>
    </thead>
  <tbody valign='baseline'>
    <tr><td align="left" valign="baseline"><var>ls</var></td>
        <td align="left">Left side</td>
        <td align="left"><tt class="constant">ACS_VLINE</tt></td>
    <tr><td align="left" valign="baseline"><var>rs</var></td>
        <td align="left">Right side</td>
        <td align="left"><tt class="constant">ACS_VLINE</tt></td>
    <tr><td align="left" valign="baseline"><var>ts</var></td>
        <td align="left">Top</td>
        <td align="left"><tt class="constant">ACS_HLINE</tt></td>
    <tr><td align="left" valign="baseline"><var>bs</var></td>
        <td align="left">Bottom</td>
        <td align="left"><tt class="constant">ACS_HLINE</tt></td>
    <tr><td align="left" valign="baseline"><var>tl</var></td>
        <td align="left">Upper-left corner</td>
        <td align="left"><tt class="constant">ACS_ULCORNER</tt></td>
    <tr><td align="left" valign="baseline"><var>tr</var></td>
        <td align="left">Upper-right corner</td>
        <td align="left"><tt class="constant">ACS_URCORNER</tt></td>
    <tr><td align="left" valign="baseline"><var>bl</var></td>
        <td align="left">Bottom-left corner</td>
        <td align="left"><tt class="constant">ACS_BLCORNER</tt></td>
    <tr><td align="left" valign="baseline"><var>br</var></td>
        <td align="left">Bottom-right corner</td>
        <td align="left"><tt class="constant">ACS_BRCORNER</tt></td></tbody>
</table>
</dl>

<P>
<dl><dt><b><a name='l2h-1245'><tt class='method'>box</tt></a></b> (<big>[</big><var>vertch, horch</var><big>]</big>)
<dd>
Similar to <tt class="method">border()</tt>, but both <var>ls</var> and <var>rs</var> are
<var>vertch</var> and both <var>ts</var> and bs are <var>horch</var>.  The default
corner characters are always used by this function.
</dl>

<P>
<dl><dt><b><a name='l2h-1246'><tt class='method'>clear</tt></a></b> ()
<dd>
Like <tt class="method">erase()</tt>, but also causes the whole window to be repainted
upon next call to <tt class="method">refresh()</tt>.
</dl>

<P>
<dl><dt><b><a name='l2h-1247'><tt class='method'>clearok</tt></a></b> (<var>yes</var>)
<dd>
If <var>yes</var> is 1, the next call to <tt class="method">refresh()</tt>
will clear the window completely.
</dl>

<P>
<dl><dt><b><a name='l2h-1248'><tt class='method'>clrtobot</tt></a></b> ()
<dd>
Erase from cursor to the end of the window: all lines below the cursor
are deleted, and then the equivalent of <tt class="method">clrtoeol()</tt> is performed.
</dl>

<P>
<dl><dt><b><a name='l2h-1249'><tt class='method'>clrtoeol</tt></a></b> ()
<dd>
Erase from cursor to the end of the line.
</dl>

<P>
<dl><dt><b><a name='l2h-1250'><tt class='method'>cursyncup</tt></a></b> ()
<dd>
Updates the current cursor position of all the ancestors of the window
to reflect the current cursor position of the window.
</dl>

<P>
<dl><dt><b><a name='l2h-1251'><tt class='method'>delch</tt></a></b> (<big>[</big><var>x, y</var><big>]</big>)
<dd>
Delete any character at <code>(<var>y</var>, <var>x</var>)</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-1252'><tt class='method'>deleteln</tt></a></b> ()
<dd>
Delete the line under the cursor. All following lines are moved up
by 1 line.
</dl>

<P>
<dl><dt><b><a name='l2h-1253'><tt class='method'>derwin</tt></a></b> (<big>[</big><var>nlines, ncols,</var><big>]</big><var> begin_y, begin_y</var>)
<dd>
An abbreviation for ``derive window'', <tt class="method">derwin()</tt> is the same
as calling <tt class="method">subwin()</tt>, except that <var>begin_y</var> and
<var>begin_x</var> are relative to the origin of the window, rather than
relative to the entire screen.  Returns a window object for the
derived window.
</dl>

<P>
<dl><dt><b><a name='l2h-1254'><tt class='method'>echochar</tt></a></b> (<var>ch</var><big>[</big><var>, attr</var><big>]</big>)
<dd>
Add character <var>ch</var> with attribute <var>attr</var>, and immediately 
call <tt class="method">refresh</tt> on the window.
</dl>

<P>
<dl><dt><b><a name='l2h-1255'><tt class='method'>enclose</tt></a></b> (<var>y, x</var>)
<dd>
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.
</dl>

<P>
<dl><dt><b><a name='l2h-1256'><tt class='method'>erase</tt></a></b> ()
<dd>
Clear the window.
</dl>

<P>
<dl><dt><b><a name='l2h-1257'><tt class='method'>getbegyx</tt></a></b> ()
<dd>
Return a tuple <code>(<var>y</var>, <var>x</var>)</code> of co-ordinates of upper-left
corner.
</dl>

<P>
<dl><dt><b><a name='l2h-1258'><tt class='method'>getch</tt></a></b> (<big>[</big><var>x, y</var><big>]</big>)
<dd>
Get a character. Note that the integer returned does <i>not</i> have to
be in ASCII range: function keys, keypad keys and so on return numbers
higher then 256. In no-delay mode, an exception is raised if there is 
no input.
</dl>

<P>
<dl><dt><b><a name='l2h-1259'><tt class='method'>getkey</tt></a></b> (<big>[</big><var>x, y</var><big>]</big>)
<dd>
Get a character, returning a string instead of an integer, as
<tt class="method">getch()</tt> 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.
</dl>

<P>
<dl><dt><b><a name='l2h-1260'><tt class='method'>getmaxyx</tt></a></b> ()
<dd>
Return a tuple <code>(<var>y</var>, <var>x</var>)</code> of the height and width of
the window.
</dl>

<P>
<dl><dt><b><a name='l2h-1261'><tt class='method'>getparyx</tt></a></b> ()
<dd>
Returns the beginning coordinates of this window relative to its
parent window into two integer variables y and x.  Returns
<code>-1,-1</code> if this window has no parent.
</dl>

<P>
<dl><dt><b><a name='l2h-1262'><tt class='method'>getstr</tt></a></b> (<big>[</big><var>x, y</var><big>]</big>)
<dd>
Read a string from the user, with primitive line editing capacity.
</dl>

<P>
<dl><dt><b><a name='l2h-1263'><tt class='method'>getyx</tt></a></b> ()
<dd>
Return a tuple <code>(<var>y</var>, <var>x</var>)</code> of current cursor position 
relative to the window's upper-left corner.
</dl>

<P>
<dl><dt><b><a name='l2h-1264'><tt class='method'>hline</tt></a></b> (<big>[</big><var>y, x,</var><big>]</big><var> ch, n</var>)
<dd>
Display a horizontal line starting at <code>(<var>y</var>, <var>x</var>)</code> with
length <var>n</var> consisting of the character <var>ch</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-1265'><tt class='method'>idcok</tt></a></b> (<var>flag</var>)
<dd>
If <var>flag</var> is false, curses no longer considers using the hardware
insert/delete character feature of the terminal; if <var>flag</var> is
true, use of character insertion and deletion is enabled.  When curses
is first initialized, use of character insert/delete is enabled by
default.
</dl>

<P>
<dl><dt><b><a name='l2h-1266'><tt class='method'>idlok</tt></a></b> (<var>yes</var>)
<dd>
If called with <var>yes</var> equal to 1, <tt class="module">curses</tt> will try and use
hardware line editing facilities. Otherwise, line insertion/deletion
are disabled.
</dl>

<P>
<dl><dt><b><a name='l2h-1267'><tt class='method'>immedok</tt></a></b> (<var>flag</var>)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -