es könnte Es gibt viele Möglichkeiten, dies zu tun. aber wie du gefragt hast, könnten diese zwei Antworten es tun, wie du willst, der erste wird das nächste Fenster öffnen, ohne den ersten zu löschen und der zweite Weg zeigt dir, wie du es schaffen könntest, indem du das letzte Fenster zerstörst, wenn du das neue öffnest .
import tkinter
from tkinter import*
from tkinter import ttk
class way1:
def __init__(self):
root= Tk()
self.root=root
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=self.histroy_quetsion).pack(side=LEFT)
theButton2= ttk.Button(root, text="Music",command=self.Music_quetsion).pack(side=RIGHT)
theButton3= ttk.Button(root, text="Computer Science", command=self.Computer_quetsion).pack()
frame.pack()
root.mainloop()
def histroy_quetsion(self):
histroy=Toplevel(self.root)
question = ttk.Label(histroy, text="These is the histroy quetsion and answer page").pack(side=TOP)
def Music_quetsion(self):
Music=Toplevel(self.root)
question = ttk.Label(Music, text="These is music quetsion and answer page").pack(side=TOP)
def Computer_quetsion(self):
Computer=Toplevel(self.root)
question = ttk.Label(Computer, text="These is the coumputer science quetsion and answer page").pack(side=TOP)
way1()
class way2:
def __init__(self):
root= Tk()
self.root=root
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=self.histroy_quetsion).pack(side=LEFT)
theButton2= ttk.Button(root, text="Music",command=self.Music_quetsion).pack(side=RIGHT)
theButton3= ttk.Button(root, text="Computer Science", command=self.Computer_quetsion).pack()
frame.pack()
root.mainloop()
def histroy_quetsion(self):
self.root.destroy()
root=Tk()
question = ttk.Label(root, text="These is the histroy quetsion and answer page").pack(side=TOP)
def Music_quetsion(self):
self.root.destroy()
root=Tk()
question = ttk.Label(root, text="These is music quetsion and answer page").pack(side=TOP)
def Computer_quetsion(self):
self.root.destroy()
root=Tk()
question = ttk.Label(root, text="These is the coumputer science quetsion and answer page").pack(side=TOP)
way2()
Wenn Sie möchten, dass es mehr kostümiert ist und jede Frage haben, fragen Sie mich, und ich werde versuchen, so viel wie ich kann, um sie zu beantworten – Hilea