<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"lib.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"lib.html" title='Python Library Reference'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"prev" href=
"module-curses.textpad.html" />
<link rel=
"parent" href=
"module-curses.textpad.html" />
<link rel=
"next" href=
"module-curses.wrapper.html" />
<meta name='aesop' content='information'
/>
<title>6.16.1 Textbox objects
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"6.16 curses.textpad "
href=
"module-curses.textpad.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"6.16 curses.textpad "
href=
"module-curses.textpad.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"6.17 curses.wrapper "
href=
"module-curses.wrapper.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-curses.textpad.html">6.16 curses.textpad
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"module-curses.textpad.html">6.16 curses.textpad
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"module-curses.wrapper.html">6.17 curses.wrapper
</A>
<!--End of Navigation Panel-->
<H2><A NAME=
"SECTION0081610000000000000000"></A><A NAME=
"curses-textpad-objects"></A>
You can instantiate a
<tt class=
"class">Textbox
</tt> object as follows:
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><span class=
"typelabel">class
</span> <tt id='l2h-
2147' xml:id='l2h-
2147'
class=
"class">Textbox
</tt></b>(
</nobr></td>
<td><var>win
</var>)
</td></tr></table></dt>
Return a textbox widget object. The
<var>win
</var> argument should be a
curses
<tt class=
"class">WindowObject
</tt> in which the textbox is to be contained.
The edit cursor of the textbox is initially located at the upper left
hand corner of the containing window, with coordinates
<code>(
0,
0)
</code>.
The instance's
<tt class=
"member">stripspaces
</tt> flag is initially on.
<tt class=
"class">Textbox
</tt> objects have the following methods:
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
2148' xml:id='l2h-
2148'
class=
"method">edit
</tt></b>(
</nobr></td>
<td><var></var><big>[
</big><var>validator
</var><big>]
</big><var></var>)
</td></tr></table></dt>
This is the entry point you will normally use. It accepts editing
keystrokes until one of the termination keystrokes is entered. If
<var>validator
</var> is supplied, it must be a function. It will be called
for each keystroke entered with the keystroke as a parameter; command
dispatch is done on the result. This method returns the window
contents as a string; whether blanks in the window are included is
affected by the
<tt class=
"member">stripspaces
</tt> member.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
2149' xml:id='l2h-
2149'
class=
"method">do_command
</tt></b>(
</nobr></td>
<td><var>ch
</var>)
</td></tr></table></dt>
Process a single command keystroke. Here are the supported special
<div class=
"center"><table class=
"realtable">
<th class=
"left" >Keystroke
</th>
<th class=
"left" >Action
</th>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-A
</tt></td>
<td class=
"left" >Go to left edge of window.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-B
</tt></td>
<td class=
"left" >Cursor left, wrapping to previous line if appropriate.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-D
</tt></td>
<td class=
"left" >Delete character under cursor.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-E
</tt></td>
<td class=
"left" >Go to right edge (stripspaces off) or end of line
(stripspaces on).
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-F
</tt></td>
<td class=
"left" >Cursor right, wrapping to next line when appropriate.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-G
</tt></td>
<td class=
"left" >Terminate, returning the window contents.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-H
</tt></td>
<td class=
"left" >Delete character backward.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-J
</tt></td>
<td class=
"left" >Terminate if the window is
1 line, otherwise
insert newline.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-K
</tt></td>
<td class=
"left" >If line is blank, delete it, otherwise clear to
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-L
</tt></td>
<td class=
"left" >Refresh screen.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-N
</tt></td>
<td class=
"left" >Cursor down; move down one line.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-O
</tt></td>
<td class=
"left" >Insert a blank line at cursor location.
</td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">Control-P
</tt></td>
<td class=
"left" >Cursor up; move up one line.
</td></tr></tbody>
Move operations do nothing if the cursor is at an edge where the
movement is not possible. The following synonyms are supported where
<div class=
"center"><table class=
"realtable">
<th class=
"left" >Constant
</th>
<th class=
"left" >Keystroke
</th>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">KEY_LEFT
</tt></td>
<td class=
"left" ><kbd>Control-B
</kbd></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">KEY_RIGHT
</tt></td>
<td class=
"left" ><kbd>Control-F
</kbd></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">KEY_UP
</tt></td>
<td class=
"left" ><kbd>Control-P
</kbd></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">KEY_DOWN
</tt></td>
<td class=
"left" ><kbd>Control-N
</kbd></td></tr>
<tr><td class=
"left" valign=
"baseline"><tt class=
"constant">KEY_BACKSPACE
</tt></td>
<td class=
"left" ><kbd>Control-h
</kbd></td></tr></tbody>
All other keystrokes are treated as a command to insert the given
character and move right (with line wrapping).
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
2150' xml:id='l2h-
2150'
class=
"method">gather
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
This method returns the window contents as a string; whether blanks in
the window are included is affected by the
<tt class=
"member">stripspaces
</tt>
<dl><dt><b><tt id='l2h-
2151' xml:id='l2h-
2151'
class=
"member">stripspaces
</tt></b></dt>
This data member is a flag which controls the interpretation of blanks in
the window. When it is on, trailing blanks on each line are ignored;
any cursor motion that would land the cursor on a trailing blank goes
to the end of that line instead, and trailing blanks are stripped when
the window contents are gathered.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"6.16 curses.textpad "
href=
"module-curses.textpad.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"6.16 curses.textpad "
href=
"module-curses.textpad.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"6.17 curses.wrapper "
href=
"module-curses.wrapper.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-curses.textpad.html">6.16 curses.textpad
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"module-curses.textpad.html">6.16 curses.textpad
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"module-curses.wrapper.html">6.17 curses.wrapper
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.