Python/wxPython:auinotebook 获取所有页面

发布于 2024-12-22 13:12:38 字数 124 浏览 1 评论 0原文

我有一个auinotebook,有没有办法获取笔记本中所有页面的列表?当用户从列表中选择一个操作时,一个新页面将添加到笔记本中。如果他们再次选择该操作,则不应再次添加该页面(相反,将为他们选择该页面)。我看不出如何做到这一点? 谢谢!

I have an auinotebook, is there anyway to get a list of all pages in the notebook? When the user selects an action from a list, a new page is added to the notebook. If they select that action again, then the page should not be added again (instead, that page will be selected for them). I can't see to figure out how to do this??
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

許願樹丅啲祈禱 2024-12-29 13:12:38

假设您正在使用 wx.lib.agw.aui.AuiNotebook:

import wx.lib.agw.aui as aui

class MyNotebook(aui.AuiNotebook):
    def __getitem__(self, index):
        ''' More pythonic way to get a specific page, also useful for iterating
            over all pages, e.g: for page in notebook: ... '''
        if index < self.GetPageCount():
            return self.GetPage(index)
        else:
            raise IndexError

现在您可以迭代笔记本的页面:

notebook = MyNotebook(parent)
notebook.AddPage(someWindow, "page 1")
notebook.AddPage(someOtherWindow, "page 2")
for page in notebook:
    ...

Assuming you are using wx.lib.agw.aui.AuiNotebook:

import wx.lib.agw.aui as aui

class MyNotebook(aui.AuiNotebook):
    def __getitem__(self, index):
        ''' More pythonic way to get a specific page, also useful for iterating
            over all pages, e.g: for page in notebook: ... '''
        if index < self.GetPageCount():
            return self.GetPage(index)
        else:
            raise IndexError

Now you can iterate over the pages of the notebook:

notebook = MyNotebook(parent)
notebook.AddPage(someWindow, "page 1")
notebook.AddPage(someOtherWindow, "page 2")
for page in notebook:
    ...
公布 2024-12-29 13:12:38

您没有提及您正在使用哪个 AuiNotebook。是wx.aui自带的还是wx.lib.agw.aui自带的?无论哪种方式,我认为您可以使用 GetChildren() 来获取笔记本面板的列表,并根据需要迭代这些面板。还有一个 GetPageCount,您可以将其与 GetPageInfo 和 GetPageText 结合使用(最后三个方法位于 agw 版本中...不确定它们是否包含在另一个版本中)。有关详细信息,请参阅文档:http://xoomer.virgilio.it/infinity77/AGW_Docs/aui.auibook.AuiNotebook.html#aui-auibook-auinotebook

或者您可以交叉发布到 wxPython 用户列表。

You don't mention which AuiNotebook you're using. Is it the one that comes with wx.aui or wx.lib.agw.aui? Either way, I would think you could use GetChildren() to get a list of the notebook's panels and iterate through those as necessary. There's also a GetPageCount that you might be able to use in conjunction with GetPageInfo and GetPageText (these last three methods are in the agw version...not sure if they're included in the other). See the documentation for more information: http://xoomer.virgilio.it/infinity77/AGW_Docs/aui.auibook.AuiNotebook.html#aui-auibook-auinotebook

Or you could cross-post to the wxPython user's list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文