level 1
rt
我只知道entry可以通过entry.destroy()去掉,但是其他控件呢?,比如button,比如checkbutton。idle报错说没有这个属性。
2018年09月21日 08点09分
1
level 1
各位大神,你们平时都不用删除控件的么?一点都不考虑删除控件的么?为什么网上都搜索不到控件删除的资料呢?
2018年09月21日 08点09分
2
level 1
把控件记录到列表中:
from tkinter import *
lis = []
def _start():
new = Label(root,text='标签')
new.pack()
lis.append(new)
def _del():
if len(lis)==0:
pass
else:
lis[-1].destroy()
del lis[-1]
root = Tk()
but1 = Button(root,text='点我添加按钮',command=_start)
but2 = Button(root,text='点我删除按钮',command=_del)
but1.pack()
but2.pack()
root.mainloop()
2020年07月05日 13点07分
11
level 1
可以把控件放在Frame组件里,然后删Frame,就把控件一起删了
2021年01月31日 01点01分
14