nachdem ich schon einige Zeit mitlese, und schon so manche Frage beantwortet wurde, brauche ich jetzt mal konkretere Hilfe.
Ich habe folgendes Problem. Ich habe ein Fenster mit zwei Tabellen (hier im Come mal durch Text-Felder ersetzt). Die obere ist lang und schmal, die untere kurz und breit. Also habe ich mit FlexGridSizern folgendes zusammengebaut.
Code: Alles auswählen
from wxPython.wx import *
class MainFrame(wxFrame):
def __init__(self, parent, ID, title):
self.app = parent
wxFrame.__init__(self, None, ID, title, style = wxCAPTION|\
wxCLOSE_BOX|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|\
wxSYSTEM_MENU|wxFULL_REPAINT_ON_RESIZE|\
wxCLIP_CHILDREN|wxRESIZE_BORDER)
self.panel = wxPanel(self, -1,
style = wxTAB_TRAVERSAL|wxFULL_REPAINT_ON_RESIZE)
self.textctrl1 = wxTextCtrl(self.panel, -1, "My text 1.",
wxDefaultPosition, wxSize(200,300),
wxTE_MULTILINE)
self.textctrl2 = wxTextCtrl(self.panel, -1, "My text 2.",
wxDefaultPosition, wxSize(200,150),
wxTE_MULTILINE)
self.button1 = wxButton(self.panel, -1, "Dummy1")
self.button2 = wxButton(self.panel, -1, "Dummy2")
self.button3 = wxButton(self.panel, -1, "Dummy3")
self.button4 = wxButton(self.panel, -1, "Dummy4")
self.button5 = wxButton(self.panel, -1, "Dummy5")
self.button6 = wxButton(self.panel, -1, "Dummy6")
self.__do_layout()
def __do_layout(self):
sizer_top = wxBoxSizer(wxVERTICAL)
sizer_panel = wxFlexGridSizer(2, 1, 5, 5)
#sizer_panel = wxBoxSizer(wxVERTICAL)
staticbox_1 = wxStaticBox(self.panel, -1, "Text1")
staticboxsizer_1 = wxStaticBoxSizer(staticbox_1, wxVERTICAL)
staticbox_2 = wxStaticBox(self.panel, -1, "Text2")
staticboxsizer_2 = wxStaticBoxSizer(staticbox_2, wxVERTICAL)
button_sizer_1 = wxBoxSizer(wxHORIZONTAL)
button_sizer_2 = wxBoxSizer(wxHORIZONTAL)
button_sizer_1.Add(self.button1, 0, wxALL, 5)
button_sizer_1.Add(self.button2, 0, wxALL, 5)
button_sizer_2.Add(self.button3, 0, wxALL, 5)
button_sizer_2.Add(self.button4, 0, wxALL, 5)
button_sizer_2.Add(self.button5, 0, wxALL, 5)
button_sizer_2.Add(self.button6, 0, wxALL, 5)
staticboxsizer_1.Add(self.textctrl1, 1, wxEXPAND|wxALL, 0)
staticboxsizer_1.Add(button_sizer_1, 0, wxALIGN_CENTER )
staticboxsizer_2.Add(self.textctrl2, 1, wxEXPAND|wxALL, 0)
staticboxsizer_2.Add(button_sizer_2, 0, wxALIGN_CENTER )
sizer_panel.Add(staticboxsizer_1, 1, wxEXPAND|wxALL, 0)
sizer_panel.Add(staticboxsizer_2, 1, wxEXPAND|wxALL, 0)
self.panel.SetAutoLayout(True)
self.panel.SetSizer(sizer_panel)
sizer_panel.Fit(self.panel)
sizer_panel.SetSizeHints(self.panel)
sizer_top.Add(self.panel, 1, wxEXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_top)
sizer_top.Fit(self)
sizer_top.SetSizeHints(self)
self.Layout()
class Application(wxApp):
def OnInit(self):
frame = MainFrame(self, -1, "MainFrame")
frame.Show(true)
self.SetTopWindow(frame)
return True
def main():
app = Application(0)
app.MainLoop()
if __name__ == "__main__":
main()
Nun zu meiner Frage: Ist es irgendwie möglich, die FlexGridSizer dazu zu überreden mitzuwachsen? In der Doku steht was von wxFlexGridSizer::SetFlexibleDirection, aber wenn ich die Zeile "sizer_panel.SetFlexibleDirection(wxBOTH)" einfüge, ändert das nichts am Verhalten. Muss ich da noch mit den Resize-Events arbeiten? Und wenn ja, hat da jeman Beispielcode?
Ach ja, ich arbeite mit Enhanced Python Distribution - Python 2.3.5 for Windows (Enthought Edition) mit wxPython 2.6.1.0
Gruß
Till