wx.lib.expando.ExpandoTextCtrl¶
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.
Class Hierarchy¶
Known Subclasses¶
wx.lib.agw.aui.auibook.TabTextCtrl
, wx.lib.agw.customtreectrl.TreeTextCtrl
, wx.lib.agw.ultimatelistctrl.UltimateListTextCtrl
Known Superclasses¶
Methods Summary¶
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. |
|
GetNumberOfLines() -> int |
|
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. |
Class API¶
- class 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.
Methods¶
- __init__(self, parent, id=-1, value='', pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name='expando')¶
Default class constructor.
- Parameters:
parent (
wx.Window
) – parent window, must not beNone
;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.
- Parameters:
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.
- Return type:
int
- GetNumberOfLines(self)¶
GetNumberOfLines() -> int
Returns the number of lines in the text control buffer.
- OnSize(self, evt)¶
Handles the
wx.EVT_SIZE
event forExpandoTextCtrl
.- Parameters:
event – a
wx.SizeEvent
event to be processed.
- OnTextChanged(self, evt)¶
Handles the
wx.EVT_TEXT
event forExpandoTextCtrl
.- Parameters:
event – a
CommandEvent
event to be processed.
- SetFont(self, font)¶
Sets the font for the
ExpandoTextCtrl
.- Parameters:
font (wx.Font) – font to associate with the
ExpandoTextCtrl
, passNullFont
to reset to the default font.- Return type:
bool
- Returns:
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.
- Parameters:
h (integer) – the maximum control height, in pixels.
- WriteText(self, text)¶
Writes the text into the text control at the current insertion position.
- Parameters:
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, callTextCtrl.SetInsertionPointEnd
before writing.