本文整理汇总了Python中tkinter.Toplevel.grab_release方法的典型用法代码示例。如果您正苦于以下问题:Python Toplevel.grab_release方法的具体用法?Python Toplevel.grab_release怎么用?Python Toplevel.grab_release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Toplevel
的用法示例。
在下文中一共展示了Toplevel.grab_release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ToplevelVidget
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import grab_release [as 别名]
class ToplevelVidget(object):
"""
ToplevelVidget contains a Toplevel widget.
"""
def __init__(
self,
close_handler=None,
master=None,
):
"""
Initialize object.
@param close_handler: Window close button event handler.
@param master: Master widget.
@return: None.
"""
# Create toplevel widget
self._toplevel = Toplevel(master=master)
# Hide the toplevel widget
self._toplevel.withdraw()
# Window close button event handler
self._close_handler = close_handler \
if close_handler is not None else self._close_handler_default
# Register window close button event handler
self._toplevel.protocol('WM_DELETE_WINDOW', self._close_handler)
def toplevel(self):
"""
Get the toplevel widget.
@return: toplevel widget.
"""
return self._toplevel
def __getattr__(self, name):
"""
Delegate attribute lookup to the toplevel widget.
@return: Attribute value, or raise AttributeError.
"""
return getattr(self._toplevel, name)
def _close_handler_default(self):
"""
Default window close button event handler.
@return: None.
"""
# Hide the toplevel widget
self._toplevel.withdraw()
# Release grab on the toplevel widget
self._toplevel.grab_release()