【菜鸟提问】tkinter中的控件如何删除?
tkinter吧
全部回复
仅看楼主
level 1
clf198808102 楼主
rt
我只知道entry可以通过entry.destroy()去掉,但是其他控件呢?,比如button,比如checkbutton。idle报错说没有这个属性。
2018年09月21日 08点09分 1
level 1
clf198808102 楼主
各位大神,你们平时都不用删除控件的么?一点都不考虑删除控件的么?为什么网上都搜索不到控件删除的资料呢?
2018年09月21日 08点09分 2
level 1
clf198808102 楼主
有人么??
2018年09月21日 12点09分 3
level 1
clf198808102 楼主
顶一下
2018年09月22日 15点09分 4
level 1
clf198808102 楼主
顶一下
2018年09月25日 08点09分 5
level 1
clf198808102 楼主
顶一下
2018年09月26日 01点09分 6
level 5
Pack_forget() 另外两种也一样
2018年11月22日 10点11分 7
Label和Entry好像不能
2018年12月17日 12点12分
@zjjcs150 可以放到frame里然后frame forget
2018年12月17日 12点12分
回复 妖怪_哪里跑_ :Label和Entry也可以用的,之前是我写的东西出了点小big
2018年12月18日 05点12分
level 4
del widget
2020年05月24日 01点05分 8
没用的
2020年05月26日 05点05分
有destroy,Misc里定义的,你看看是不是拼错了
2020年06月26日 07点06分
level 4
2020年06月26日 07点06分 10
视频发不上来
2020年06月26日 07点06分
你自己运行一下吧
2020年06月26日 07点06分
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
level 1
等方法
2021年05月06日 07点05分 15
1