Skip to main content
 首页 » 编程设计

python之如何设置居中的 wx.aui.AuiManager Pane 的大小

2025年05月04日27zhwl

我有三个带有 InfoPane 中心选项的 Pane 。 我想知道如何设置它们的大小。

使用这段代码:

import wx 
import wx.aui 
 
class MyFrame(wx.Frame): 
 
    def __init__(self, parent, id=-1, title='wx.aui Test', 
                 pos=wx.DefaultPosition, size=(800, 600), 
                 style=wx.DEFAULT_FRAME_STYLE): 
        wx.Frame.__init__(self, parent, id, title, pos, size, style) 
 
        self._mgr = wx.aui.AuiManager(self) 
 
        # create several text controls 
        text1 = wx.TextCtrl(self, -1, 'Pane 1 - sample text', 
                            wx.DefaultPosition, wx.Size(200,150), 
                            wx.NO_BORDER | wx.TE_MULTILINE) 
 
        text2 = wx.TextCtrl(self, -1, 'Pane 2 - sample text', 
                            wx.DefaultPosition, wx.Size(200,150), 
                            wx.NO_BORDER | wx.TE_MULTILINE) 
 
        text3 = wx.TextCtrl(self, -1, 'Main content window', 
                            wx.DefaultPosition, wx.Size(200,150), 
                            wx.NO_BORDER | wx.TE_MULTILINE) 
 
        # add the panes to the manager 
        self._mgr.AddPane(text1, wx.CENTER) 
        self._mgr.AddPane(text2, wx.CENTER) 
        self._mgr.AddPane(text3, wx.CENTER) 
 
        # tell the manager to 'commit' all the changes just made 
        self._mgr.Update() 
 
        self.Bind(wx.EVT_CLOSE, self.OnClose) 
 
 
    def OnClose(self, event): 
        # deinitialize the frame manager 
        self._mgr.UnInit() 
        # delete the frame 
        self.Destroy() 
 
 
app = wx.App() 
frame = MyFrame(None) 
frame.Show() 
app.MainLoop() 

我想知道当我们改变 Pane 的大小时调用什么。 如果你告诉我,我可以自己做剩下的:)

请您参考如下方法:

我已经找到了我想要的东西。 这是 wx.aui.AuiPaneInfo.dock_proportion 属性:)