tkinker顶级窗口 :Toplevel

2022-01-07  本文已影响0人  HC2

Toplevel(顶级窗口),类似于弹出窗口,具有独立的窗口属性(如标题栏、边框等)

import tkinter as tk
# 建立窗口
window = tk.Tk()
window.title('hello thinter')
height= window.winfo_screenheight()
width= window.winfo_screenwidth()
window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))

def create():
    top = tk.Toplevel()
    top.title("tkinter")

    msg = tk.Message(top, text="hello thinter!")
    msg.pack()

tk.Button(window, text="创建顶级窗口", command=create).pack()

window.mainloop()
上一篇 下一篇

猜你喜欢

热点阅读