1

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

Shane
  • 4,875
  • 12
  • 49
  • 87
  • 3
    did you do a `Layout()` or `Refresh()` after adding those items? – Corley Brigman Mar 14 '14 at 10:55
  • 3
    Nice animated screenie in the question! :) – GreenAsJade Mar 14 '14 at 11:06
  • @CorleyBrigman: Yes I've tried both but they didn't work. At first I thought it should work if you force the UI to redraw/refresh, so I did a little search but had no luck with `Layout()` or `Refresh`. – Shane Mar 14 '14 at 11:24
  • 1
    @CorleyBrigman: `Layout()` finally worked! Only you have to use it on `self.MainPanel`, thanks! – Shane Mar 14 '14 at 11:55
  • @Shane: could you post this as an answer and accept it. Especially after being mesmerized by the graphic, it took me a long time to realize this question was answered hours ago. – tom10 Mar 14 '14 at 21:55

1 Answers1

1

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?

Shane
  • 4,875
  • 12
  • 49
  • 87