📜  tkinter 更改按钮文本 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:13.196000             🧑  作者: Mango

代码示例1
import tkinter as tk

root = tk.Tk()

def update_btn_text():
    btn_text.set("b")

btn_text = tk.StringVar()
btn = tk.Button(root, textvariable=btn_text, command=update_btn_text)
btn_text.set("a")

btn.pack()

root.mainloop()