【发布时间】:2018-09-27 10:56:22
【问题描述】:
我将 tkinter 用作具有函数的类,当我运行一个函数导致另一个函数时,再次以再次运行第一个函数结束,但是原始函数不起作用。请帮忙
def idle(self):
self.next.destroy()
self.info.destroy()
self.prompt.configure(text=city_line + ", What do you want to do?")
self.backpack = tk.Button(self, text="Backpack", command=self.backpack)
self.shop = tk.Button(self, text="Shop")
self.wander = tk.Button(self, text="Wander", command=self.wander)
self.travel = tk.Button(self, text="Travel", command=self.travel)
self.backpack.pack(side="right", padx=5, pady=5)
self.shop.pack(side="right", padx=5, pady=5)
self.wander.pack(side="right", padx=5, pady=5)
self.travel.pack(side="right", padx=5, pady=5)
def backpack(self):
self.backpack.destroy()
self.shop.destroy()
self.wander.destroy()
self.travel.destroy()
self.output.destroy()
self.info = tk.Message(self, width=150, text=backpacke + ". Gold: " + str(gold))
self.output = tk.Label(self, text="")
self.next = tk.Button(self, text="Next", command=self.idle)
self.info.pack(side="top", fill="x", pady=8)
self.output.pack(side="top", fill="x", expand=True)
self.next.pack(side="right", padx=5, pady=5)
【问题讨论】:
-
请发布完整的课程以及您如何调用课程方法。