wxPanel and Sizers question
Donnal Walter
donnalcwalter at yahoo.com
Thu Jan 23 10:56:47 EST 2003
"Markus von Ehr" <markus.vonehr at ipm.fhg.de> wrote in message
news:3E300AD1.8AE42379 at ipm.fhg.de...
> Hi,
>
> I want to create a Panel wherein several controls should be
> displayed vertically arranged.
> The problem is, that only the first button: "one" is
> displayed. I don't know where the problem is, because in
> several examples it's done like that.
>
> class MyWindow(wxPanel):
> def __init__(self, parent, ID):
> wxPanel.__init__(self, parent, -1)
>
> box = wxBoxSizer(wxVERTICAL)
> box.AddWindow(wxButton(self, 1, "one"), 0, wxEXPAND)
> box.AddWindow(wxButton(self, 1, "two"), 0, wxEXPAND)
> box.AddWindow(wxButton(self, 1, "three"), 0, wxEXPAND)
> box.AddWindow(wxButton(self, 1, "four"), 0, wxEXPAND)
>
> Any hints? Thanks,
Try this (untested, but it should work):
class MyWindow(wxPanel):
def __init__(self, parent, ID):
wxPanel.__init__(self, parent, -1)
box = wxBoxSizer(wxVERTICAL)
box.AddWindow(wxButton(self, -1, "one"), 0, wxEXPAND)
box.AddWindow(wxButton(self, -1, "two"), 0, wxEXPAND)
box.AddWindow(wxButton(self, -1, "three"), 0, wxEXPAND)
box.AddWindow(wxButton(self, -1, "four"), 0, wxEXPAND)
Using -1 for the wxButton id argument lets wxPython make up a new id for
each button. When you use 1, it sets ALL the button ids to 1.
Donnal Walter
Arkansas Children's Hospital
More information about the Python-list
mailing list