Python 3.x 在Python3中使用tkinter按下按钮后,如何删除按钮?

Python 3.x 在Python3中使用tkinter按下按钮后,如何删除按钮?,python-3.x,tkinter,Python 3.x,Tkinter,我正在尝试用Tkinter制作一个游戏,我正在尝试移除按钮 我使用的代码是: from tkinter import * from random import * def ct(): textA.destroy() tAb.destroy() window = Tk() textA = Text(window, width = 15, height = 1) textA.insert(END, 'Choose a type.') textA.config(state="dis

我正在尝试用Tkinter制作一个游戏,我正在尝试移除按钮

我使用的代码是:

from tkinter import *
from random import *

def ct():
    textA.destroy()
    tAb.destroy()

window = Tk()
textA = Text(window, width = 15, height = 1)
textA.insert(END, 'Choose a type.')
textA.config(state="disabled")
tAb = Button(window,  text = 'filler', command = ct)

我不想把它改得太多。

这段代码与您期望的有什么不同?这是一个错误吗?破坏错误的东西?在错误的时间销毁它?还有什么?首先,您的代码没有调用任何布局函数,例如
文本
按钮
小部件上的
grid()
pack()
,因此它们不会显示。其次,代码没有调用
window.mainloop()
。您的代码将
文本
按钮
小部件一起销毁在
ct()
函数中。如果您只想删除按钮,只需调用
tAb.destroy()