Difficulties with sizers and text controls

John Li wrote:

Since the wxTextCtrl can scroll it doesn't automatically set itself to a
size that can display everything. You should set the width of the text
controls yourself and the sizer will then use that width in further
calculations.

Thanks! I gather, then, that since wx.StaticText doesn't scroll,
it automatically sets itself to a size that can display everything,
and this works well.

Yes.

So, I decided to create a class, derived from wx.StaticText, that
looks like a wx.TextCtrl (added a border and a white background).
On windows there was a slight problem with the border, in that
the wx.StaticText didn't calculate the extra space needed for the
border, which resulted in the text partially covered vertically, and
wrapped. I solved this by adding leading and trailing spaces,
and by manually specifying a bigger height.
However, on Linux, neither the border nor the white background
shows up. In the wx.StaticText demo, the background color
doesn't show up there as well. I tried all possible types of
borders. I wouldn't think that this is a native widget problem, since a wx.TextCtrl can have a border and white background...
Is there a way to modify this behavior on Linux? (And is
there a better solution to my Windows kluge?) Thanks-

Not all native widget types on all platforms are able to implement the full wxWindow functionality. On GTK things like the static text are not true windows and are just drawn on their parent window and so they suffer some of the problems you've found.

When you want to change the behaviour of a standard widget it is sometimes better to just create a new widget from scratch instead. In this case I've already done it for you, take a look at stattext.py in the library. You shoudl be able to derive from that class and with a little tweaking do what you want.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!