有没有一种方法可以在单击按钮时更改按钮中的文本。 (tkinter)

时间:2020-07-10 08:11:54

标签: python button tkinter

当按钮在Tkinter中单击时,我想进行更改,在按钮中更改文本。

1 个答案:

答案 0 :(得分:1)

这是否可以帮助您解决问题。使用.config(),您可以在tkinter中更新按钮

from tkinter import Button,Tk


root = Tk()


def click():
    b.config(text='You jus clicked me!')


b = Button(root, text='Click me', command=click)
b.pack()

root.mainloop()