6.13.1 Textbox objects
You can instantiate a Textbox object as follows:
- Textbox (win)
Return a textbox widget object. The win argument should be a
curses WindowObject 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 containin window, with coordinates
The instance's stripspaces flag is initially on.
Textbox objects have the following methods:
- edit ([validator])
This is the entry point you will normally use. It accepts editing
keystrokes until one of the termination keystrokes is entered. If
validator 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 stripspaces member.
- do_command (ch)
Process a single command keystroke. Here are the supported special
||Go to left edge of window.
||Cursor left, wrapping to previous line if appropriate.
||Delete character under cursor.
||Go to right edge (stripspaces off) or end of line (stripspaces on).
||Cursor right, wrapping to next line when appropriate.
||Terminate, returning the window contents.
||Delete character backward.
||Terminate if the window is 1 line, otherwise insert newline.
||If line is blank, delete it, otherwise clear to end of line.
||Cursor down; move down one line.
||Insert a blank line at cursor location.
||Cursor up; move up one line.|
Move operations do nothing if the cursor is at an edge where the
movement is not possible. The following synonyms are supported where
All other keystrokes are treated as a command to insert the given
character and move right (with line wrapping).
- gather ()
This method returns the window contents as a string; whether blanks in
the window are included is affected by the stripspaces
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 is gathered.
Ver Sobre este documento... para obtener información sobre sugerencias.