是否可以将 wx.auiManager 窗格停靠在另一个窗格的顶部/底部? [英] Is it possible to dock wx.auiManager panes onto tops/bottoms of another panes?

查看:33
本文介绍了是否可以将 wx.auiManager 窗格停靠在另一个窗格的顶部/底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此代码:

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)


        info = wx.aui.AuiPaneInfo()
        info.CaptionVisible(True)
        info.BottomDockable(False)
        info.LeftDockable(False)
        info.RightDockable(False)
        info.PaneBorder(False)
        info.Top()
        info.Row(1)

        info2 = wx.aui.AuiPaneInfo()
        info2.CaptionVisible(True)
        info2.BottomDockable(False)
        info2.LeftDockable(False)
        info2.RightDockable(False)
        info2.Top()
        info2.Row(2)

        self._mgr.AddPane(text1, info, 'Pane Number One')
        self._mgr.AddPane(text2, info2, 'Pane Number Two')

        self._mgr.Update()

        self.Bind(wx.EVT_CLOSE, self.OnClose)


    def OnClose(self, event):
        self._mgr.UnInit()
        self.Destroy()


app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()

我创建的两个窗格停靠在顶部.info.Row(1) 和 info2.Row(2) 将两个窗格一个接一个:

the two panes that I create are docked in the Top. The info.Row(1) and info2.Row(2) put the two panes one after another:

_TOP_
Pane1
Pane2

现在,如果我在 Pane2 上移动,它会停靠在顶部并且会发生这种情况:

Now, if I move on Pane2, this docks in the Top and this situation occurs:

_TOP_
Pane1|Pane2

我想要:1. 避免这种情况(每行只有一个窗格!)2.如果我移动,将窗格停靠在另一个窗格的底部/顶部

I want: 1. to avoid this situation (only one pane per row!) 2. if I move, dock the pane in the bottom/top of another pane

这可能吗?

推荐答案

也许是 AuiNotebook wxPython 示例对你有用吗?

Maybe the AuiNotebook wxPython sample works for you?

import wx
import wx.aui

########################################################################
class TabPanel(wx.Panel):
    """
    This will be the first notebook tab
    """
    #----------------------------------------------------------------------
    def __init__(self, parent):
        """"""

        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        sizer = wx.BoxSizer(wx.VERTICAL)
        txtOne = wx.TextCtrl(self, wx.ID_ANY, "")
        txtTwo = wx.TextCtrl(self, wx.ID_ANY, "")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(txtOne, 0, wx.ALL, 5)
        sizer.Add(txtTwo, 0, wx.ALL, 5)

        self.SetSizer(sizer)

class DemoPanel(wx.Panel):
    """
    This will be the first notebook tab
    """
    #----------------------------------------------------------------------
    def __init__(self, parent):
        """"""
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        # create the AuiNotebook instance
        nb = wx.aui.AuiNotebook(self)

        # add some pages to the notebook
        pages = [(TabPanel(nb), "Tab 1"),
                 (TabPanel(nb), "Tab 2"),
                 (TabPanel(nb), "Tab 3")]
        for page, label in pages:
            nb.AddPage(page, label)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(nb, 1, wx.EXPAND)
        self.SetSizer(sizer)

########################################################################
class DemoFrame(wx.Frame):
    """
    Frame that holds all other widgets
    """

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, wx.ID_ANY,
                          "AUI-Notebook Tutorial",
                          size=(600,400))
        panel = DemoPanel(self)
        self.Show()

#----------------------------------------------------------------------
if __name__ == "__main__":
    app = wx.PySimpleApp()
    frame = DemoFrame()
    app.MainLoop()

这篇关于是否可以将 wx.auiManager 窗格停靠在另一个窗格的顶部/底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆