I have an aui management framework with many panels. I found that when the frame was maximized, the size change of the panel was not consistent with the actual display. For example, if the frame size is (930,311) and the panel size is (0, 0) during initialization, the actual panel size should be (720,400). When maximized, the frame is (1536,801) and the panel is (726,290), while the actual display size of the panel is (1328,400). Panel size is always one change behind. Why is this?
class CanvasFrame(wx.Frame):
def init(self, ):
wx.Frame.init(self,None, -1, ‘CanvasFrame’, size=(950, 350))
self.pnl=wx.Panel(self)
self.gridPanel = wx.Panel(self.pnl,-1)
grid = wx.grid.Grid(self.gridPanel, -1, wx.Point(0, 0),size=(400,100),style=wx.NO_BORDER | wx.WANTS_CHARS)
grid.CreateGrid(500, 15)
search_window=wx.Panel(self.gridPanel,-1)
search_value=wx.TextCtrl(search_window,-1)
searchBox=wx.BoxSizer(wx.HORIZONTAL)
searchBox.Add(search_value,6,wx.LEFT,1)
searchBox.Add(wx.Button(search_window,-1,label="GO"),1,wx.LEFT, 5)
search_window.SetSizer(searchBox)
leftBox = wx.BoxSizer(wx.VERTICAL)
leftBox.Add(grid, 40, wx.EXPAND)
leftBox.Add(wx.StaticText(self.gridPanel, label = "search:"), 1, wx.LEFT, 60)
leftBox.Add(search_window,3,wx.LEFT)
self.gridPanel.SetSizer(leftBox)
self.md_page=wx.Panel(self.pnl,-1,size=(720,400),style=wx.FULL_REPAINT_ON_RESIZE)
self.tench=wx.Panel(self.pnl)
self.t1=wx.Panel(self.pnl)
self.t2=wx.Panel(self.pnl)
self.t3=wx.Panel(self.pnl,-1)
# ------------------------------------------------------------
self.mgr = aui.AuiManager()
self.mgr.SetManagedWindow(self.pnl)
self.mgr.AddPane(self.md_page, aui.AuiPaneInfo().Top().
BestSize(-1,400).MinSize((-1, 400)).
CloseButton(False). Name("Notebook"))
self.mgr.AddPane(self.gridPanel,aui.AuiPaneInfo().Bottom().CenterPane().
BestSize((500,100)).MinSize((100, -1)).Layer(1).
Caption("wxPython Demo").
CloseButton(False).Name("DemoTree"))
self.mgr.AddPane(self.tench,aui.AuiPaneInfo().Right().
Layer(0).BestSize((200,100)).
Caption("Demo Log Messages").
CloseButton(False).Name("LopgWindow"))
self.mgr.AddPane(self.t2,aui.AuiPaneInfo().Right().
Layer(0).Position(1).
Caption(" Messages").
CloseButton(False).Name("LopgWindow333"))
self.mgr.AddPane(self.t1, aui.AuiPaneInfo().Right().
Layer(0).Position(2).
Caption(" Messages").
CloseButton(False).Name("LopgWindow3"))
self.mgr.AddPane(self.t3,aui.AuiPaneInfo().Right().
BestSize(200,830).Layer(2).
Caption("Log Messages").
CloseButton(False).Name("LopgWindow2"))
self.mgr.Update()
self.Bind(wx.EVT_SIZE,self.OnSize)
def OnSize(self,e):
print(self.GetClientSize(),self.md_page.GetClientSize(),self.t3.GetClientSize())
self.mgr.Update()
self.Refresh()
e.Skip()
class App(wx.App):
def OnInit(self):
“”“Create the main window and insert the custom frame.”""
frame = CanvasFrame()
self.SetTopWindow(frame)
frame.Show(True)
return True
if name == ‘main’:
app = App()
app.MainLoop()