Alignment isn't working in Linux

Hey list, here is some example code I've tried in Windows XP and
Ubuntu 9.04. It makes the frame, gives it a sizer, and adds a
wx.StaticText to it with the wx.ALIGN_CENTER flag. However, the center
alignment only works in windows and is completely ignored in Linux. I
tried googling this and got zero results, which probably means that
I'm doing something stupid. Any one know what's wrong?

import wx

class MyFrame( wx.Frame ):
    def __init__( self ):
        wx.Frame.__init__( self, None, -1, "Test" )
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        sizer.Add(wx.StaticText(self,-1,'testing',style=wx.ALIGN_CENTER),1,wx.EXPAND)
        self.Show()

app = wx.App(0)
MyFrame()
app.MainLoop()

Thanks

align.PNG

Peter Mellon wrote:

Hey list, here is some example code I've tried in Windows XP and
Ubuntu 9.04. It makes the frame, gives it a sizer, and adds a
wx.StaticText to it with the wx.ALIGN_CENTER flag. However, the center
alignment only works in windows and is completely ignored in Linux. I
tried googling this and got zero results, which probably means that
I'm doing something stupid. Any one know what's wrong?

import wx

class MyFrame( wx.Frame ):
    def __init__( self ):
        wx.Frame.__init__( self, None, -1, "Test" )
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        sizer.Add(wx.StaticText(self,-1,'testing',style=wx.ALIGN_CENTER),1,wx.EXPAND)
        self.Show()

app = wx.App(0)
MyFrame()
app.MainLoop()

Hmmm... The wxGTK code is setting the justification of the label widget, but maybe it needs to be doing some additional step. Please submit a ticket about this. In the meantime you can use the sizer to do the alignment for you.

import wx
print wx.version()

class MyFrame( wx.Frame ):
     def __init__( self ):
         wx.Frame.__init__( self, None, -1, "Test" )
         sizer = wx.BoxSizer(wx.VERTICAL)
         self.SetSizer(sizer)
         st = wx.StaticText(self,-1,'testing')#,style=wx.ALIGN_RIGHT)
         sizer.Add(st, 0, wx.ALIGN_CENTER) #wx.EXPAND)
         self.Show()

app = wx.App(0)
f = MyFrame()
import wx.lib.inspection
wx.lib.inspection.InspectionTool().Show()
app.MainLoop()

···

--
Robin Dunn
Software Craftsman