wxPython and wxFlexGridSizer problem
Cliff Wells
logiplexsoftware at earthlink.net
Tue Mar 26 13:27:26 EST 2002
On 26 Mar 2002 10:49:46 GMT
Uwe Schmitt wrote:
> Jeff Shannon <jeff at ccvcorp.com> wrote:
>
>
> | Are you sure that you want to use ShowModal()?? How are you setting up
your
> | window?
>
> | This function looks okay to me, as far as it goes, but it's hard to say
what
> | might be going on if we don't know where window is coming from. I
presume that
> | it's a wxDialog of some sort? If so, why aren't you subclassing
wxDialog and
> | putting this code in your __init__(), then calling ShowModal() from the
function
> | that creates the dialog?
>
> I got the answer in the wxwindows-group: there is just
> a window.Layout() call missing. Thats it and everything is fine..
That may be the case, but Jeff brought up some good points. It looks odd
to create a window in this fashion (it looks procedural rather than OO). A
more typical approach would be something like:
class testtt(wxDialog):
def __init__(self, parent, id):
wxDialog.__init__(self, parent, id, "")
basicSizer = wxBoxSizer(wxVERTICAL)
gridSizer= wxFlexGridSizer(cols=2)
t=wxStaticText(self, -1, "Eingabe:")
tt=wxTextCtrl(self, -1, "", size=wxSize(100,-1))
gridSizer.AddMany([
(t, 0, wxALL | wxALIGN_RIGHT),
(tt, 0, wxALL |wxALIGN_LEFT)
])
gridSizer.SetSizeHints(self)
gridSizer.Fit(self)
self.SetSizer(gridSizer)
self.SetAutoLayout(true)
self.Layout()
And then elsewhere:
dlg = testtt(None, -1)
dlg.ShowModal()
Also, I notice that your calls to gridSizer.Add are incorrect. The second
argument is supposed to be a boolean flag indicating whether the widget
should be expanded in the sizer's primary direction (in the case of a
wxFlexGridSizer, I'm not sure what that means, but you still need the
argument, at least as a placeholder). The wxALL and wxALIGN_* flags should
be the third argument.
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308
More information about the Python-list
mailing list