import tkinter as tk
class Page_1:
def __init__(self, window):
self.window = window
self.window.title("p1")
self.window.geometry("200x200")
self.window.config(bg="#F9C03D")
self.button = tk.Button(self.window, text="跳转", command=self.change)
self.button.pack()
def change(self):
self.button.destroy()
Page_2(root)
class Page_2:
def __init__(self, window):
self.window = window
self.window.title("p2")
self.window.geometry("300x300")
self.window.config(bg="#0F375A")
self.button = tk.Button(self.window, text="返回", command=self.back)
self.button.pack()
def back(self):
self.button.destroy()
Page_1(root)
root = tk.Tk()
p1 = Page_1(root)
root.mainloop()