Phillip Watts wrote:
I'll look into this and see what I can come up with. Then I'll post it
or put it in the wiki and let you guys give me suggestions for improvement.
Mike
This a fairly simple one generated by glade:
The mystery _1 for the frame, then a panel with
1 vertical and 2 horizontal
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
sizer_3.Add(self.text_ctrl_1, 0, 0, 0)
sizer_3.Add(self.text_ctrl_2, 0, 0, 0)
sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
sizer_4.Add(self.text_ctrl_3, 0, 0, 0)
sizer_4.Add(self.button_1, 0, 0, 0)
sizer_2.Add(sizer_4, 1, wx.EXPAND, 0)
self.panel_1.SetSizer(sizer_2)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
Careful reading reveals the hierarchy, but its not as intuitive
as Tkinter pack().
The panel is added to the top level, I guess I get that.
The two SetSizers(), and only two, I don't get.
I don't know what the Fit() and Layout() do because all
the tutorials are inconsistent and the docs are no help.
And some example have functions which apparently glade
doesn't use.
I'm not asking you to comment on the above. Just giving my
comments for your proposed tutorials.
If you look at the xml generated by wxglade, attached,
even though its not easy to read, the hierarchy is very obvious.
I'm going to comment regardless since I probably won't get to work on my tutorials until at least tomorrow or the weekend.
SetSizer tells the container widget which sizer to use. So the first one tells the panel to use sizer_2 and the second SetSizer tells the frame to use sizer_1.
Layout() forces a size event, which should (as I understand it) cause the sizers to calculate the best size of the widgets that they contain and refresh the screen appropriately. So, if you add or remove/hide a widget and then call Layout(), it will force the sizers to resize dynamically to fit the widgets.
Fit() on the other hand will use the minimum size of all the contained windows and resize appropriately. I usually don't use it unless I want the frame to be tiny.
And yes, sizers are complicated. I'm glad it's been abstracted as much as it has, but it's still hard to grasp. Just an FYI, but there's a SizerControls addon to help in laying out widgets at a higher level. You might take a look at that. Or XRC.
Mike