Shane
Shane

Reputation: 4983

wxPython - wx.StaticText not aligning properly

enter image description here

As you can see, none of those wx.StaticText items align properly when it starts, once you try to resize the window, then it's all working.

Sample code:

self.CodeTitleStaticText = wx.StaticText(id=wxID_MAINFRAMECODETITLESTATICTEXT,
              label=u'Code', name=u'CodeTitleStaticText', parent=self.MainPanel,
              pos=wx.Point(10, 10), size=wx.Size(80, 20),
              style=wx.ALIGN_CENTRE)

Then I put all these wx.StaticText items into a wx.GridBagSizer. Could anybody explain to me in which part did I mess it up?

I'm running win 7 64bit with Python 2.7.3(32bit) and wxPython 2.8.12.1

Upvotes: 1

Views: 392

Answers (1)

Shane
Shane

Reputation: 4983

I finally found a solution.

Some of you may have tried Layout() and found it didn't work, well the problem is, you have to redraw/refresh that specific panel on which the sizers are attached to, it won't work if you just update the frame.

I fixed both of my MainPanel and StatusBar alignment problem by implement Layout() on separate panels. Although I don't know why it doesn't work on main frame, maybe somebody can add more explanation to this?

Upvotes: 1

Related Questions