Auto size wx.StaticText

CM cmpython at gmail.com
Wed Sep 22 18:27:52 EDT 2010


On Sep 22, 2:38 pm, Grant Edwards <inva... at invalid.invalid> wrote:
> On 2010-09-22, Dani Valverde <dani.valve... at gmail.com> wrote:
>
> > Is there a way to automatically set the size of a wx.StaticText to fit
> > its content?
>
> According to the docs, it should do that by default:
>
>    http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.StaticText.html
>
> Window Styles
>
>   Window Style          Description
>
>   wx.ALIGN_LEFT         Align the text to the left
>
>   wx.ALIGN_RIGHT        Align the text to the right
>
>   wx.ALIGN_CENTRE       Center the text (horizontally)
>
>   wx.ST_NO_AUTORESIZE   By default, the control will adjust its size to
>                         exactly fit to the size of the text when
>                         SetLabel is called. If this style flag is
>                         given, the control will not change its size
>                         (this style is especially useful with controls
>                         which also have wx.ALIGN_RIGHT or
>                         wx.ALIGN_CENTER style because otherwise they
>                         won't make sense any longer after a call
>                         to SetLabel)
>
> --
> Grant Edwards               grant.b.edwards        Yow! PUNK ROCK!!  DISCO
>                                   at               DUCK!!  BIRTH CONTROL!!
>                               gmail.com            

Yes, just make sure, OP, that you don't pass a size to the
wx.StaticText when constructing it.  Or you can give the size as
size=wx.Size(-1,-1), which means default size.

Che



More information about the Python-list mailing list