实现点击主窗口按钮,弹出副窗口,同时禁止主窗口功能,在关闭窗口后,使能主窗口。
from tkinter import *
WINDOWSIZE = '710x510+50+50'
def t_close_handler():
root.attributes("-disabled", 0)
f1.destroy()
def infodisplay():
root.attributes("-disabled", 1)
global f1
f1 = Toplevel(root)
# f1.config(width=710,height=510)
f1.geometry("710x510")
f1.title("信息显示")
b1 = Button(f1)
b1.config(width=6,height=1,text="确定")
b1.grid(row=0,column=0,padx=100,pady=50)
f1.protocol("WM_DELETE_WINDOW", t_close_handler)
pass
def remotConfig():
pass
def localConfig():
pass
root = Tk()
root.geometry(WINDOWSIZE)
toolbar = Frame(root)
mqttDisplay = Button(toolbar, text="信息显示", width=7, command=infodisplay)
mqttDisplay.grid(row=0,column=0)
remotCon = Button(toolbar, text="远程配置", width=7, command=infodisplay)
remotCon.grid(row=0,column=1)
localCon = Button(toolbar, text="串口配置", width=7, command=infodisplay)
localCon.grid(row=0,column=2)
toolbar.config(height=1, bd=2)
toolbar.grid(row=0, padx=200)
root.mainloop()
原文链接:https://blog.csdn.net/lijinxue22/article/details/107178010