How to make a label that automatically wraps when resized?

Hi Dan,

Dan Eloff wrote:

I have a wx.StaticText with text that should wrap. Is it possible to
make it wrap automatically when resized? Or would it make more sense
to use a disabled multiline TextCtrl (which must have this ability I
think.) Still curious how it could be done with a StaticText, I
couldn't find a way with my very limited wx skills.

I recall a thread about this, so searched and found this one: "text wrapping in wx.StaticText".

According to Robin it should wrap, but it is not consistant on all platforms.

-Dan

P.S. Sorry if I'm being a pest, but I'm having lots of fun playing
with wxPython :slight_smile:

Welcome to "the club" and keep having fun!
Werner

Hi Dan, Dan Eloff wrote:

>> I have a wx.StaticText with text that should wrap. Is it possible
>> to make it wrap automatically when resized? Or would it make more
>> sense to use a disabled multiline TextCtrl (which must have this
>> ability I think.) Still curious how it could be done with a
>> StaticText, I couldn't find a way with my very limited wx skills.

> I recall a thread about this, so searched and found this one:
> "text wrapping in wx.StaticText".

> According to Robin it should wrap, but it is not consistant
> on all platforms.

I've found that it wraps somewhat some of the time.

I have several one-line StaticText objects (in a wizard page) that
just run off the end of the window. I also have one (for help text)
that I feed a multiline block of text. If I just give it very long
lines, I end up with some number of lines nicely wrapped (under 10
lines) and the rest of the text is simply missing.

That's on Windows XP.

       paul

You message arrived just as I was in the middle of testing that with
PyCrust. The idea suddenly seemed a lot more promising :slight_smile:

It sort of works. The text does not overflow, but it also won't
"unwrap" if the frame gets larger. I think that can be worked around,
I'll let you know what I come up with.

-Dan

ยทยทยท

On 11/20/06, Werner F. Bruhin <werner.bruhin@free.fr> wrote:

What about using wx.CallAfter in the EVT_SIZE to call your function
which at that point should get the new size of your StaticText.