I’m creating a readonly TextCtrl in order to enabling copy its message. I want it to show the whole information at the very beginning but it doesn’t adjust its size. A hard-coded way may not be a good approach since message string length may vary. Attached is the code snippet that doesn’t work so well. Thanks!
···
#!/usr/bin/env python
“”“SizerTest - 'cause Sizer’s wx.EXPAND does not GROW “””
import wx
class SizerTest(wx.Frame):
def init(self):
wx.Frame.init(self, parent = None, id = wx.ID_ANY)
frame_box = wx.BoxSizer()
panel = wx.Panel(self, -1, style=wx.BORDER_SUNKEN)
self.text = wx.TextCtrl(panel, id=-1,
value=‘heiheiheihhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh’, style=wx.TE_READONLY|wx.NO_BORDER)
panel_box = wx.BoxSizer()
panel_box.Add(self.text, 1, wx.EXPAND | wx.ALL | wx.ALIGN_TOP)
panel.SetSizer(panel_box)
frame_box.Add(panel, 1, wx.EXPAND)
self.SetSizer(frame_box)
if name == ‘main’:
app = wx.App()
frame = SizerTest()
frame.Show(True)
import wx.lib.inspection
wx.lib.inspection.InspectionTool().Show()
app.MainLoop()