本文整理汇总了Python中tkinter.Toplevel.wait_window方法的典型用法代码示例。如果您正苦于以下问题:Python Toplevel.wait_window方法的具体用法?Python Toplevel.wait_window怎么用?Python Toplevel.wait_window使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Toplevel
的用法示例。
在下文中一共展示了Toplevel.wait_window方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _license
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import wait_window [as 别名]
def _license(self):
""" affiche la licence dans une nouvelle fenêtre """
def close():
""" ferme la fenêtre """
self.focus_set()
fen.destroy()
fen = Toplevel(self)
fen.title(_("License"))
fen.transient(self)
fen.protocol("WM_DELETE_WINDOW", close)
fen.resizable(0, 0)
fen.grab_set()
# set_icon(fen)
texte = Text(fen, width=50, height=18)
texte.pack()
texte.insert("end",
_("Sudoku-Tk is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\n"))
texte.insert("end",
_("Sudoku-Tk is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\n"))
texte.insert("end",
_("You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/."))
i = int(texte.index("5.end").split(".")[1])
texte.tag_add("link", "5.%i" % (i - 29), "5.%i" % (i - 1))
texte.tag_configure("link", foreground="#0000ff", underline=1)
texte.tag_bind("link", "<Button - 1>",
lambda event: webOpen("http://www.gnu.org/licenses/"))
texte.tag_bind("link", "<Enter>",
lambda event: texte.config(cursor="hand1"))
texte.tag_bind("link",
"<Leave>", lambda event: texte.config(cursor=""))
texte.configure(state="disabled", wrap="word")
b_close = Button(fen, text=_("Close"), command=close)
b_close.pack(side="bottom")
b_close.focus_set()
fen.wait_window(fen)
示例2: nameHandler
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import wait_window [as 别名]
def nameHandler(name, message):
'''Takes a string name and character, provides an interface for correcting
the illegal name, returns a new legal string name.'''
#todo: create a proper validate method
def destroy(*args):
root.destroy()
root = Toplevel()
root.title('Bad Name')
root.resizable(False, False)
root.after(100, root.focus_force) #todo: temp?
mainFrame = ttk.Frame(root, padding=MAIN_PAD)
mainFrame.grid(column=0, row=0, sticky='nwes')
newname = StringVar(value=name)
nameEntry = ttk.Entry(mainFrame, textvariable=newname)
nameEntry.grid(row=1, sticky='we')
ttk.Label(mainFrame, text=message).grid(row=0)
for child in mainFrame.winfo_children():
child.grid(padx=5, pady=5)
nameEntry.after(100, nameEntry.focus) #todo: temp?
root.bind('<Return>', destroy)
root.wait_window()
#todo: disable the ability to close the window instead? add abort option?
if len(newname.get()) < 1:
return nameHandler(name, message)
else:
return newname.get()