wxpython aui 管理器窗格默认带有选项卡

问题描述 投票:0回答:1

所以我想像这样“堆叠”或“标记”两个 aui 窗格。

但是,如果不启动应用程序并使用鼠标堆叠窗格,我找不到任何说明如何执行此操作的文档

我也不想用aui.notebook

尝试通过 chatgpt 获取答案,但它不起作用


import wx
import wx.lib.agw.aui as aui

class MyFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)

        # create the AuiManager object
        self._mgr = aui.AuiManager(self)

        # create the panes
        pane1 = wx.TextCtrl(self, -1, "Pane 1")
        pane2 = wx.TextCtrl(self, -1, "Pane 2")

        # add the panes to the AuiManager and stack them vertically
        self._mgr.AddPane(pane1, aui.AuiPaneInfo().Name("pane1").Caption("Pane 1").Left())
        self._mgr.AddPane(pane2, aui.AuiPaneInfo().Name("pane2").Caption("Pane 2").Bottom().Layer(1).Position(1))

        # configure the AuiManager
        self._mgr.Update()

# create the app and frame
app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()

非常感谢您的帮助:)

python python-3.x wxpython
1个回答
1
投票
import wx
import wx.lib.agw.aui as aui

class MyFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)

        # create the AuiManager object
        self._mgr = aui.AuiManager(self)

        # create the panes
        pane1 = wx.TextCtrl(self, -1, "Pane 1")
        pane2 = wx.TextCtrl(self, -1, "Pane 2")

        # add the panes to the AuiManager and stack them vertically
        self._mgr.AddPane(pane1, aui.AuiPaneInfo().Name("P1").Caption("P1-Caption").Center().MinSize((10, 10)).BestSize((200, 100)))
        self._mgr.AddPane(pane2, aui.AuiPaneInfo().Name("P2").Caption("P2-Caption").Center().MinSize((10, 10)).BestSize((200, 100)),\
                         target=self._mgr.GetPane("P1")) # target stacks the pane's to tabs

        # configure the AuiManager
        self._mgr.Update()

# create the app and frame
app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()
© www.soinside.com 2019 - 2024. All rights reserved.