1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
class CEdit
__init__(self, parent, initial_text, nchars = None)
Class CEdit represents an edit (or entry) control, a one-line box
in which the user types and edits text. To read the text after
the user has entered it, use GetWindowText().
If the edit control is in a dialog box, the Enter and Esc keys will
dismiss the dialog box as usual, even if the Edit Control has focus.
Instance Variables
wpyParent, wpyText, wpyChildList, wpySizeX/Y, wpyLocX/Y
wpyPasswordChar, char or None, readonly after Create()
If this is changed from None to a character such as "*", then
that character will be shown in the control rather than the
characters actually typed.
wpyTextColor, the tuple (r, g, b)
Sets the text color to the given color.
wpyBrush, an instance of a CBrush (don't forget to Create() it).
Sets the background color to the color of the brush.
Methods
__init__(self, parent, initial_text, nchars = None)
Return an editbox with self.wpySizeX/Y set according to the arguments given.
parent, object
The view or dialog parent of the control.
initial_text, string
The initial text to display in the edit control. Assigned to wpyText.
nchars, int or None
The size of the editbox is nchars average characters if given, else
it is the size of initial_text if given, else it is 10 characters.
Create(self)
Make the editbox visible by calling the underlying GUI.
SetSel(self, char1, char2)
Set the selection to the range char1 to char2, and set the cursor to
just before char2. If char1 == char2, just set the cursor, not the
selection. Use a large char2 (such as 999) to indicate the end of
the edit control.
SetWindowText(self, text)
Write the text to the editbox replacing any existing text.
GetWindowText(self)
Get the edited text from the editbox. Returns a string.
LimitText(length)
Limit the length of text which the user can enter. This is not
supported by Tk.
Messages
OnChar(self, char, flags)
Sent to the edit control when the user presses a key. Useful for
dismissing the edit control when the user presses "enter". If
the edit control is in a dialog box, the dialog box will be dismissed
when the user presses "enter" or "esc".
OnEditChange(self, control)
Sent when the edit control has changed. This
may be sent for each key stroke, so it must be efficient.
class CMultiEdit
__init__(self, parent, initial_text, nchars = None, nlines = 4)
Class CMultiEdit represents a multi-line edit control. It is similar to
CEdit, except for supporting multiple lines. The methods used to access
the text are the same as used for CEditView. Use of SetWindowText() and
GetWindowText() requires return-newline on Windows
and newline alone on Tk, so use of these should be avoided. Use WpyAppend
to add lines with or without lineends instead.
Also, initial_text must be just one line (the longest line for sizing) if it
is used.
To include scroll bars on a CMultiEdit, set self.wpyHScrollSize and/or
self.wpyVScrollSize to non-zero. The size of the scroll bars is available
as self.wpyScrollWidth, and is not included in the size returned from
the constructor.
Messages
OnVScroll(self, control)
OnHScroll(self, control)
Sent when the user operates the scroll bar of a multiline
edit control. The wpyVScrollPos is updated to the index
of the first visible line. wpyHScrollPos is always zero.
Examples
# Create a label and editbox.
editlabel = CLabel(self, "Edit: ")
editlabel.wpyLocX = x
editlabel.wpyLocY = y
editlabel.Create()
editbox = CEdit(self, "initial text", 20)
editbox.wpyLocX = x + editlabel.wpySizeX
editbox.wpyLocY = y
editbox.Create()
|