wxPython:禁用笔记本选项卡?
有没有办法禁用笔记本选项卡?就像您可以使用小部件本身一样吗?我启动了一个很长的流程,虽然对于那些查看它的人来说应该是不言自明的,但我希望能够防止用户在其他选项卡中乱搞,直到它正在运行的流程完成为止。
我似乎在 wx.Notebook
中找不到任何可以帮助解决此问题的内容?
代码片段:
def __init__(self, parent):
wx.Notebook.__init__(self, parent, id=wx.ID_ANY, style=wx.BK_DEFAULT)
self.AddPage(launchTab.LaunchPanel(self), "Launch")
self.AddPage(scanTab.ScanPanel(self), "Scan")
self.AddPage(extractTab.ExtractPanel(self), "Extract")
self.AddPage(virtualsTab.VirtualsPanel(self), "Virtuals")
Is there anyway to disable a notebook tab? Like you can with the Widgets themselves? I have a long process I kick off, and while it should be pretty self-explanatory for those looking at it, I want to be able to prevent the user from mucking around in other tabs until the process it is running is complete.
I couldn't seem to find anything in wx.Notebook
to help with this?
Code snippet:
def __init__(self, parent):
wx.Notebook.__init__(self, parent, id=wx.ID_ANY, style=wx.BK_DEFAULT)
self.AddPage(launchTab.LaunchPanel(self), "Launch")
self.AddPage(scanTab.ScanPanel(self), "Scan")
self.AddPage(extractTab.ExtractPanel(self), "Extract")
self.AddPage(virtualsTab.VirtualsPanel(self), "Virtuals")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它不能用
wx.Notebook
实现。但是您可以使用一些更高级的小部件,例如wx.lib.agw.aui.AuiNotebook:It si not doable with
wx.Notebook
. But you can use some of the more advanced widgets such aswx.lib.agw.aui.AuiNotebook
:从技术上讲,wx.Notebook 没有办法禁用选项卡。但是,您可以通过检查单击了哪个选项卡来执行相同的操作,如果它被“禁用”,则否决 EVT_NOTEBOOK_PAGE_CHANGING 或 EVT_NOTEBOOK_PAGE_CHANGED 事件。或者,您可以使用上面提到的 AUI 笔记本。请注意,这是来自 agw lib 的库,而不是来自 wx.aui 的库。 FlatNotebook 还提供禁用选项卡的功能。有关示例,请参阅 wxPython 演示。
Technically, wx.Notebook doesn't have a way to disable a tab. However, you can do the same thing by checking which tab is clicked on and if it is "disabled", veto the EVT_NOTEBOOK_PAGE_CHANGING or EVT_NOTEBOOK_PAGE_CHANGED event. Alternately, you can use the AUI notebook as mentioned above. Note that that is the one from the agw lib, NOT from the wx.aui one. The FlatNotebook also provides the ability to disable tabs. See the wxPython demo for an example.
活动选项卡可以通过 Notebook.SetSelection() 设置。但事件应该解除绑定/禁用并在其周围绑定/启用,以避免无限循环。面板代码中应该有wx.BeginBusyCursor()、wx.EndBusyCursor()。然后,当应用程序繁忙时,选项卡更改将“禁用”。
The active tab can be set by Notebook.SetSelection(). But the event should be unbinded/disable and bind/enable around it to avoid in infinite looping. There should be wx.BeginBusyCursor(), wx.EndBusyCursor() in panel codes. Then The tab changing is "disabled" when app is busy.