from tkinter import *
class Janela:
def __init__(self, master):
self.master = master
self.master.geometry('800x480-3+0')
self.start = Button(text="Start", font="minecraftia 18", bg="grey", command=self.menu)
self.start.place(x=364, y=290)
def menu(self):
jan1 = Tk()
self.bt1 =Button(jan1, text = "next", command=self.jans)
self.bt1.place(x=200, y=200)
jan1.geometry("800x480-3+0")
def jans(self):
jan2 = Tk()
self.bt2 =Button(jan2, text="back", command=jan2.destroy, command=jan1.destroy)
self.bt2.place(x=200, y=200)
jan2.geometry("800x480-3+0")
root = Tk()
Janela(root)
root.mainloop()
答案 0 :(得分:0)
一个相当简单的解决方案是创建一个调用 2个函数或方法的function_A
。然后将该功能绑定到Tkinter按钮。
def function_A(func1, func2):
func_1() # or method
func_2() # or method
所以在您的功能中
def jans(self):
jan2 = Tk()
def double_command():
jan2.destroy()
jan1.destroy()
self.bt2 =Button(jan2, text="back", command=double_command)
self.bt2.place(x=200, y=200)
jan2.geometry("800x480-3+0")
,在Tkinter按钮中,您可以
self.bt2 =Button(jan2, text="back", command=double_command)