Hi everybody,
I have a strange little problem with displaying text in a wx.TextCtrl. I have some data that I would like to display in a table-like format in an info window, see first screen shot below. The code for the info window is:
class InfoWindow(wx.MiniFrame):
“”“window to display all kinds of information to the user”""
def __init__(self, parent, ID, title, size=(500, 200)):
wx.MiniFrame.__init__(self, parent, ID, title, style=wx.CLOSE_BOX | wx.RESIZE_BORDER)
self.panel = wx.Panel(self)
self.panel.SetBackgroundColour("white")
self.textfield = wx.TextCtrl(self.panel, -1, size=size, style=wx.TE_READONLY | wx.TE_MULTILINE | wx.TE_RICH)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.textfield, 1, border=5, flag=wx.EXPAND | wx.ALL)
self.panel.SetSizerAndFit(self.sizer)
self.Fit()
and it is called in the program via
def displayInInfoWindow(title, text, size=(500, 200)):
“”“display text in an info window of a given size, with a given title”""
infowindow = InfoWindow(None, -1, title, size)
infowindow.textfield.SetValue(text)
infowindow.Show()
…
displayInInfoWindow(“Data table looks fine”, durtext, size=(700, 550)) ## looks good
displayInInfoWindow(“Data table looks horrible”, durtext2, size=(700, 550))
…
At first everything was fine. Then I decided to move the last column a bit further to the right by adding another tab before “(N = …” - and whoa! Suddenly the whole layout was changed. I really don’t understand what the problem is, since the text field is wide enough to accommodate the lines. What’s going wrong here? Any input would be greatly appreciated.
Thanks in advance,
Ingrid
PS: Sample code is attached.
infowindow_problem.py (2.93 KB)