The ExpandoTextCtrl is a multi-line wx.TextCtrl that will adjust its height on the fly as needed to accommodate the number of lines needed to display the current content of the control. It is assumed that the width of the control will be a fixed value and that only the height will be adjusted automatically. If the control is used in a sizer then the width should be set as part of the initial or min size of the control.
When the control resizes itself it will attempt to also make necessary adjustments in the sizer hierarchy it is a member of (if any) but if that is not suffiecient then the programmer can catch the EVT_ETC_LAYOUT_NEEDED event in the container and make any other layout adjustments that may be needed.
wx.lib.agw.aui.auibook.TabTextCtrl
, wx.lib.agw.customtreectrl.TreeTextCtrl
, wx.lib.agw.ultimatelistctrl.UltimateListTextCtrl
Default class constructor. |
|
Appends the text to the end of the text control. |
|
Returns the maximum height that the control will expand to on its own. |
|
Handles the |
|
Handles the |
|
Sets the font for the |
|
Sets the maximum height that the control will expand to on its |
|
Writes the text into the text control at the current insertion position. |
ExpandoTextCtrl
(wx.TextCtrl)¶The ExpandoTextCtrl is a multi-line wx.TextCtrl that will adjust its height on the fly as needed to accommodate the number of lines needed to display the current content of the control. It is assumed that the width of the control will be a fixed value and that only the height will be adjusted automatically. If the control is used in a sizer then the width should be set as part of the initial or min size of the control.
When the control resizes itself it will attempt to also make necessary adjustments in the sizer hierarchy it is a member of (if any) but if that is not suffiecient then the programmer can catch the EVT_ETC_LAYOUT_NEEDED event in the container and make any other layout adjustments that may be needed.
__init__
(self, parent, id=-1, value="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name="expando")¶Default class constructor.
parent (wx.Window
) – parent window, must not be None
;
id (integer) – window identifier. A value of -1 indicates a default value;
value (string) – the control text label;
pos (tuple or wx.Point
) – the control position. A value of (-1, -1) indicates a default position,
chosen by either the windowing system or wxPython, depending on platform;
size (tuple or wx.Size
) – the control size. A value of (-1, -1) indicates a default size,
chosen by either the windowing system or wxPython, depending on platform;
style (integer) – the underlying wx.Control
style;
validator (wx.Validator) – the window validator;
name (string) – the widget name.
AppendText
(self, text)¶Appends the text to the end of the text control.
text (string) – text to write to the text control.
See also
GetMaxHeight
(self)¶Returns the maximum height that the control will expand to on its own.
int
OnSize
(self, evt)¶Handles the wx.EVT_SIZE
event for ExpandoTextCtrl
.
event – a wx.SizeEvent
event to be processed.
OnTextChanged
(self, evt)¶Handles the wx.EVT_TEXT
event for ExpandoTextCtrl
.
event – a CommandEvent
event to be processed.
SetFont
(self, font)¶Sets the font for the ExpandoTextCtrl
.
font (wx.Font) – font to associate with the ExpandoTextCtrl
, pass
NullFont
to reset to the default font.
bool
True
if the font was really changed, False
if it was already
set to this font and nothing was done.
SetMaxHeight
(self, h)¶Sets the maximum height that the control will expand to on its own, and adjusts it down if needed.
h (integer) – the maximum control height, in pixels.
WriteText
(self, text)¶Writes the text into the text control at the current insertion position.
text (string) – text to write to the text control.
Note
Newlines in the text string are the only control characters allowed, and they
will cause appropriate line breaks. See AppendText
for more convenient
ways of writing to the window. After the write operation, the insertion point
will be at the end of the inserted text, so subsequent write operations will
be appended. To append text after the user may have interacted with the control,
call TextCtrl.SetInsertionPointEnd
before writing.