Greetings-
I am attempting to build an interface composed of multiple panels. I have a
"base" panel consisting of a wxStaticText and wxTextCtrl which I have named
wxTextEntry. This widget creates a label with a text entry field next to it.
From wxTextEntry, I have created a panel wxNamePanel which consists of
first, middle, last, and suffix instances of the above widget. In my test
program, I create a frame and then an instance of wxNamePanel, which
displays beautifully on my screen (I was surprised at how quickly this went
together). I used wxBoxSizer in "HORIZONTAL" mode. Again, I was pleased that
it worked the first time!
I created wxAddressPanel (street number, street name, suffix, pre and post
directionals), and wxLocalityPanel (city, state, zip code, and zip4). Each
one displays beautifully on my test screen. Each of the above uses
wxBoxSizer inside their respective classes.
What I would like to do is create a wxNameAddressPanel, consisting of all
the above panels to have a single panel for entry of name and address
information. I created a method for each of the above classes (wxNamePanel,
wxAddressPanel, wxLocalityPanel) to return the sizer for each. The code
looks something like this...
class wxNameAddressPanel(wxPanel):
"""Create a panel to collect/display name, address, and locality
information"""
def __init__(self, parent, id):
wxPanel.__init__(self, parent, id)
self.Name = wxNamePanel(self, -1)
self.Address = wxAddressPanel(self, -1)
self.Locality = wxLocalityPanel(self, -1)
self.sizer = wxBoxSizer(wxVERTICAL)
self.sizer.Add(self.Name.sizer(), 1, wxEXPAND)
self.sizer.Add(self.Address.sizer(), 1, wxEXPAND)
self.sizer.Add(self.Locality.sizer(), 1, wxEXPAND)
self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)
self.Show(1)
···
####################################################################
### Test Code ######################################################
####################################################################
if __name__ == '__main__':
class TestWindow(wxFrame):
def __init__(self, parent, id, title='wxNamePanel Test'):
wxFrame.__init__(self, parent, -1, title,
size=(300,300))
# place an exit in the menubar
ID_EXIT = 999
filemenu = wxMenu()
filemenu.Append(ID_EXIT, "Exit")
menuBar = wxMenuBar()
menuBar.Append(filemenu, "File")
self.SetMenuBar(menuBar)
EVT_MENU(self, ID_EXIT, self.OnExit)
# create a text edit pane
name = wxNameAddressPanel(self, -1)
self.Show(1)
def OnExit(self, e):
self.Close(true)
testApp = wxPySimpleApp()
frame = TestWindow(None, -1)
frame.Show(1)
testApp.MainLoop()
But, alas, when I run this code in my test frame, nothing displays! I know
this is a bit much, but what am I doing incorrectly. Should I be using the
wxFlexBoxSizer? I really would like to have separate panels for each element
(name, address, locality), but if that's not possible, I could live with
everything in one.
Where can I get information on wxFlexBoxSizer? I have looked at the
documentation on wxWindows.org, but it's in C++ and I have an abnormally
high loathing of it (maybe because I am a C++ coder by profession :-).
Any help you could pass my way would be appreciated.
Greg Lindstrom
InfoBase Products Development office: (501) 342-1626
301 Industrial Blvd, Conway, AR, 72032 fax: (501) 336-3911
email: Greg.Lindstrom@acxiom.com mail: B011-8
"When the solution is simple, God has spoken"
Albert Einstein