.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. module:: wx.lib.expando .. currentmodule:: wx.lib.expando .. highlight:: python .. _wx.lib.expando: ========================================================================================================================================== |phoenix_title| **wx.lib.expando** ========================================================================================================================================== This module contains the :class:`~lib.expando.ExpandoTextCtrl`, which is a multi-line text control that will expand its height on the fly to be able to show all the lines of the content of the control. Description =========== The :class:`ExpandoTextCtrl` is a multi-line :class:`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. Usage ===== Sample usage:: import wx from wx.lib.expando import ExpandoTextCtrl, EVT_ETC_LAYOUT_NEEDED class MyFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title="Test ExpandoTextCtrl") self.pnl = p = wx.Panel(self) self.eom = ExpandoTextCtrl(p, size=(250,-1), value="This control will expand as you type") self.Bind(EVT_ETC_LAYOUT_NEEDED, self.OnRefit, self.eom) # create some buttons and sizers to use in testing some # features and also the layout vBtnSizer = wx.BoxSizer(wx.VERTICAL) btn = wx.Button(p, -1, "Write Text") self.Bind(wx.EVT_BUTTON, self.OnWriteText, btn) vBtnSizer.Add(btn, 0, wx.ALL|wx.EXPAND, 5) btn = wx.Button(p, -1, "Append Text") self.Bind(wx.EVT_BUTTON, self.OnAppendText, btn) vBtnSizer.Add(btn, 0, wx.ALL|wx.EXPAND, 5) sizer = wx.BoxSizer(wx.HORIZONTAL) col1 = wx.BoxSizer(wx.VERTICAL) col1.Add(self.eom, 0, wx.ALL, 10) sizer.Add(col1) sizer.Add(vBtnSizer) p.SetSizer(sizer) # Put the panel in a sizer for the frame so we can use self.Fit() frameSizer = wx.BoxSizer() frameSizer.Add(p, 1, wx.EXPAND) self.SetSizer(frameSizer) self.Fit() def OnRefit(self, evt): # The Expando control will redo the layout of the # sizer it belongs to, but sometimes this may not be # enough, so it will send us this event so we can do any # other layout adjustments needed. In this case we'll # just resize the frame to fit the new needs of the sizer. self.Fit() def OnWriteText(self, evt): self.eom.WriteText("This is a test... Only a test. If this had " "been a real emergency you would have seen the " "quick brown fox jump over the lazy dog.") def OnAppendText(self, evt): self.eom.AppendText("Appended text.") app = wx.App(0) frame = MyFrame() frame.Show() app.MainLoop() |class_summary| Classes Summary =============================== ================================================================================ ================================================================================ `~wx.lib.expando.ExpandoTextCtrl` The ExpandoTextCtrl is a multi-line wx.TextCtrl that will ================================================================================ ================================================================================ | .. toctree:: :maxdepth: 1 :hidden: wx.lib.expando.ExpandoTextCtrl