Newbie trying to align text

Hello,

I just starting with wx.Python and of course have a little problem:

I use this:
naamLbl = wx.StaticText(self, -1, "Naam : ", size=(120,-1), style =
wx.ALIGN_RIGHT)

and later in a grid:

wedstr2Sizer.Add(naamLbl, flag=
wx.LEFT|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)

I thought the first would right align the text, where the second would right
align the widget.

Where an I wrong? I need the txt "Naam : " to be right aligned within the
120 px.

Thanks in advance for any tips.

Bauke

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/Newbie-trying-to-align-text-tp2642068p2642068.html
Sent from the wxPython-users mailing list archive at Nabble.com.

You should set the wx.EXPAND flag in the sizer.Add method. I have
attached a quick script that
demonstrates what wx.EXPAND does.

I know I struggled with this when I started.

Josh

StaticTextFormatting.py (2.39 KB)

···

On Fri, Aug 20, 2010 at 5:12 AM, Bauke <devries.bp@gmail.com> wrote:

Hello,

I just starting with wx.Python and of course have a little problem:

I use this:
naamLbl = wx.StaticText(self, -1, "Naam : ", size=(120,-1), style =
wx.ALIGN_RIGHT)

and later in a grid:

wedstr2Sizer.Add(naamLbl, flag=
wx.LEFT|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)

I thought the first would right align the text, where the second would right
align the widget.

Where an I wrong? I need the txt "Naam : " to be right aligned within the
120 px.

Thanks in advance for any tips.

Bauke
--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/Newbie-trying-to-align-text-tp2642068p2642068.html
Sent from the wxPython-users mailing list archive at Nabble.com.

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Josh English
Joshua.R.English@gmail.com

Yes, that sounds like it should be working, although wx.LEFT is not needed since you do not specify a border size. Please make a small runnable sample that demonstrates the problem so we can see all the details of your situation. MakingSampleApps - wxPyWiki

BTW, there is some code in the demo that does something similar to what it sounds like you want to do. Look at the subpanels in the ScrolledPanel sample. In that case it is not specifying a width for the static texts, so the widget alignment flag is not used.

···

On 8/20/10 5:12 AM, Bauke wrote:

Hello,

I just starting with wx.Python and of course have a little problem:

I use this:
naamLbl = wx.StaticText(self, -1, "Naam : ", size=(120,-1), style =
wx.ALIGN_RIGHT)

and later in a grid:

wedstr2Sizer.Add(naamLbl, flag=
wx.LEFT|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)

I thought the first would right align the text, where the second would right
align the widget.

Where an I wrong? I need the txt "Naam : " to be right aligned within the
120 px.

--
Robin Dunn
Software Craftsman