如何在 wxPython 3.0 (Phoenix) 中制作 wx.Frame 模态
Ho to make wx.Frame modal in wxPython 3.0 (Phoenix)
wxPython 2中曾经有
self.MakeModal(True)
但不在凤凰城。
我如何显示模态?
我不想使用 wx.Dialog
因为我需要添加状态栏。
我使用的一个很好的解决方法是将样式标志 wx.FRAME_FLOAT_ON_PARENT
添加到框架并通过 frame.GetParent().Disable()
禁用父级 window。然后将类似模态的框架绑定到 EVT_CLOSE
并通过 frame.GetParent().Enable()
.
重新启用父 window
------更新-----
Robin Dunn 的建议是一种更适合框架模态化的方法。
从 wx phoenix migration guide,将其添加到您的框架 class
def MakeModal(self, modal=True):
if modal and not hasattr(self, '_disabler'):
self._disabler = wx.WindowDisabler(self)
if not modal and hasattr(self, '_disabler'):
del self._disabler
wxPython 2中曾经有
self.MakeModal(True)
但不在凤凰城。
我如何显示模态?
我不想使用 wx.Dialog
因为我需要添加状态栏。
我使用的一个很好的解决方法是将样式标志 wx.FRAME_FLOAT_ON_PARENT
添加到框架并通过 frame.GetParent().Disable()
禁用父级 window。然后将类似模态的框架绑定到 EVT_CLOSE
并通过 frame.GetParent().Enable()
.
------更新-----
Robin Dunn 的建议是一种更适合框架模态化的方法。 从 wx phoenix migration guide,将其添加到您的框架 class
def MakeModal(self, modal=True):
if modal and not hasattr(self, '_disabler'):
self._disabler = wx.WindowDisabler(self)
if not modal and hasattr(self, '_disabler'):
del self._disabler