On Mar 4, 2005, at 11:00 AM, Bo Green wrote:
>
> I have been trying to piece together how to do a sizer in a
> CustomDialog. So far it doesn't work. If I leave the resource button
> positions as is, the buttons always appear there. If I comment out the
> resource button positions, the buttons end up both in the top left
> corner of the dialog, on top of each other. Here is the dialog's
> __init__ method in its current state (I've tried many variations of
> the same code). Part of the problem is my lack of understanding of the
> sizer methods, but possibly also how to add the components of the
> dialog to the sizer.
>
> def _init_(self, mainBG):
> "Initialise the project dialog"
> model.CustomDialog.__init__(self, mainBG)
> self.parent = mainBG
> sizer = wx.BoxSizer(wx.VERTICAL)
> sizer.Add(self.components.buttonCreate,flag=wx.GROW)
> sizer.Add(self.components.buttonOpen,flag=wx.GROW)
> sizer.Fit(self)
> self.SetSizer(sizer)
> self.SetAutoLayout(true)
> self.Layout()
> Thanks for any help.
> Bo
>
There are a number of potential problems here. One, you need to be
setting the sizer with self.panel, not just self. The panel is what all
the components actually sit on and the panel sits in the frame. Yes
this is one of those things that would be nice to completely hide,
which is what the Background sort of does, but it gets exposed when you
do the raw wxPython stuff like sizers.
sizer.Fit(self)
sizer.SetSizeHints(self) # you might need this line, not sure
self.panel.SetSizer(sizer)
self.panel.SetAutoLayout(True)
self.panel.Layout()
The other problem is that I don't think you mean to use the wx.GROW
flag like that, but maybe that's okay. I only do sizers periodically,
they make my head hurt, and then I don't do them again for a while, so
I could be wrong ;-)
There is a fairly complicated CustomDialog that uses a sizer in
PythonCard/templates/dialogs/runOptionsDialog.py which is used by the
codeEditor and resourceEditor.
ka
|