Auto size wx.StaticText

D

Dani Valverde

Hello!
Is there a way to automatically set the size of a wx.StaticText to fit
its content?
Cheers!

Dani

--
Daniel Valverde Saubí
c/Joan Maragall 37 4 2
17002 Girona
Spain
Telèfon mòbil: +34651987662
e-mail: (e-mail address removed)
http://www.acrocephalus.net
http://natupics.blogspot.com

Si no és del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudaràs a estalviar aigua, energia i recursos forestals. GRÀCIES!

Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!
 
G

Grant Edwards

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)
 
C

CM

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)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Hello 3
Declare self.cursor 2

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top