【发布时间】:2018-09-23 22:35:24
【问题描述】:
import tkinter as tk
class main_window(tk.Frame):
def __init__(self, parent):
tk.Frame.__init__(self, parent)
win_button = tk.Button(self, text="Searching and sorting algorithms",
command=self.window)
win_button.grid(column=1,row=1)
win_button2 = tk.Button(self, text="BIG 0",
command=self.window)
win_button2.grid(column=3,row=1)
win_button3 = tk.Button(self, text="Tree Traversal",
command=self.window)
win_button3.grid(column=1, row=3)
win_button4 = tk.Button(self, text="profix,infix and prefix",
command=self.window)
win_button4.grid(column=3, row=3)
def all_children (wid) :
_list = wid.winfo_children()
for item in _list :
if item.winfo_children() :
_list.extend(item.winfo_children())
return _list
def clear(self):
list= root.grid_slaves()
for k in list:
k.destroy()
def window(self):
self.clear()
if __name__ == "__main__":
global root
root = tk.Tk()
main_window(root).pack(fill="both", expand=True)
root.mainloop()
我正在尝试让它创建一个具有 4 个选项的屏幕。然后,该窗口将清除用户选择的任何一个并弹出新信息,但我无法清除。我努力了 。破坏,但它确实有效。
【问题讨论】:
标签: python tkinter python-3.6