The code below is from a PythonCard app, which is why it references
self.components, but this problem will apply to any wxPython app. I've got a
wxFrame that contains a single wxPanel and on that panel are a wxButton
(comp.btnRun) and a custom control based on a wxWindow (comp.bufOff). When
the app opens, it runs the initSizers method below and the window looks
fine. What I would like to do is be able to manually change the size of
comp.bufOff in response to certain user actions and have the window resize
appropriately.
I've been able to do that with simpler windows using SetClientSize, but the
extra control (btnRun) or the status bar or menu or something is throwing
off the calculation. Or perhaps I'm simply calling the wrong method(s). I've
tried various combinations of Fit() and Layout()... but can't seem to get
the window to resize correctly.
Anyway, what is the general way of setting the new size of a control sitting
on a panel within a frame and then fitting the the frame (window) to the new
minimum best size?
Perhaps the complication is that comp.bufOff is set to wxEXPAND and so it is
getting fit to the window rather than having the window fit to its new size
when I try to resize it manually?
ka
···
---
def initSizers(self):
sizer1 = wx.wxBoxSizer(wx.wxVERTICAL)
comp = self.components
flags = wx.wxLEFT | wx.wxRIGHT | wx.wxBOTTOM | wx.wxALIGN_BOTTOM
sizer1.Add(comp.btnRun, 0, flags, 5)
sizer1.Add(comp.bufOff, 1, wx.wxEXPAND)
sizer1.Fit(self)
sizer1.SetSizeHints(self)
self.sizer = sizer1
self.panel.SetSizer(sizer1)
self.panel.SetAutoLayout(1)
self.panel.Layout()