wxlayoutconstraints inside a wxDialog ?
sheershion at mailexpire.com
Fri Feb 22 19:56:56 CET 2002
Marcus Stojek wrote:
> I'm using wxPython and I'm trying to use
> layout constraints in a Dialog.
> why doesn't this work?
> class CompoDlg(wxDialog):
> def __init__(self,parent):
> win=wxDialog(parent, -1, "Title", wxDefaultPosition,
> wxSize(350, 200))
> E11 = wxStaticText(win,-1,"E11:",wxDefaultPosition,
There is one basic thing wrong with this code: you're not initializing
your class correctly. You should call the constructor of the base
class, but you're creating a new wxDialog instead. With that in mind,
the window which needs laying out is simply 'self', not 'win'. So,
after correcting, rearranging, and removing some unused and redundant
stuff, you might end up with something like this (warning, untested
wxDialog.__init__(self, parent, -1, "Title", wxDefaultPosition,
E11 = wxStaticText(self,-1,"E11:")
By the way, I assume you know that
will not, by itself, actually show the dialog? Do
result = d.ShowModal()
Having gone through all that, you might want to consider using sizers
instead of constraints. As far as development is concerned, constraints
are pretty much dead, or so I gather, and sizers are very much alive.
Furthermore, it has become the preferred layout method of the wxWindows
developers, so who am I to argue with them?
P.S. Take a look at the wxPython mailing list. It's somewhere on
More information about the Python-list