我该如何做到这一点?当单击其中一个按钮时,它将打开一个新窗口或删除窗口中的所有内容,并用问题和答案替换它:
import tkinter
from tkinter import*
from tkinter import ttk
from tkinter import messagebox
def open_msg_box():
messagebox.showinfo(
"Event Triggered",
"Button Clicked"
)
root= Tk()
root.geometry("900x150+200+250")
root.configure(background = "Light blue")
frame = Frame(root)
style = ttk.Style()
style.configure("TButton",
foreground="midnight blue",
font="Times 20 bold italic",
padding=20)
style.configure("TLabel",
foreground="midnight blue",
font="Times 20 bold italic",
padding=20)
question = ttk.Label(root, text="Choose a Topic").pack(side=TOP)
theButton= ttk.Button(root, text="History",
command=open_msg_box).pack(side=LEFT)
theButton2= ttk.Button(root, text="Music",
command=open_msg_box).pack(side=RIGHT)
theButton3= ttk.Button(root, text="Computer Science",
command=open_msg_box).pack()
frame.pack()
root.mainloop()
有很多方法可以做到这一点。但是,当你问这两个答案可以做你可能想做的,第一个将打开下一个窗口,而不删除第一个和第二种方式将向你展示如何通过破坏最后一个窗口时,打开新的。你知道吗
相关问题 更多 >
编程相关推荐