窗口中有一个按钮,初始显示“确定”,单击按钮在“确定”和“取消”间切换。
from tkinter import *
def CallBack():
b.pack_forget()
b1.pack()
def CallBack1():
b1.pack_forget()
b.pack()
win = Tk()
win.geometry("500x250")
win.title('第三题')
b = Button(win,text = '确定',command = CallBack,width = 20,height = 10)
b1 = Button(win,text = '取消',command = CallBack1,width = 20,height = 10)
b.pack()
win.mainloop()