Toplevel(顶级窗口),类似于弹出窗口,具有独立的窗口属性(如标题栏、边框等) 。
下边的例子中,在root窗口添加一个按钮,点一下弹出一个顶级窗口。
示例:
from tkinter import *
def create():
top = Toplevel()
Button(top, text='创建toplevel窗口', command=cre).pack()
def cre():
tt = Toplevel()
Label(tt, text='hhhhhhhhhhh').pack()
root = Tk()
Button(root, text='创建顶级窗口', command=create).pack()
mainloop()
效果:



网友评论