wxPython面板未填充paren

2024-04-25 20:26:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个wxPython框架包含一个自定义面板。我想让这个嵌板填满它的框架。你知道吗

class MyCustomFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.mainPanel = MyCustomPanel(self)
        self.SetAutoLayout(True)

但是由于某些原因,自定义面板声称它的大小总是20x20,不管我如何调整主窗口的大小。你知道吗

class MyCustomPanel(wx.Panel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        print('Panel size:', self.GetSize())

Panel size: (20, 20)

怎么了?你知道吗

编辑:从here

If a wxFrame (or derived class) is to have only one child, then you don't need a sizer at all, as the default behaviour of the frame's EVT_SIZE handler (assuming there is only one child) is to resize that child to occupy all of the frame's client area.

但事实并非如此。你知道吗


Tags: thetoself框架child面板initis