Python 3, Tkinter, How to update button text

后端 未结 7 1601
孤城傲影
孤城傲影 2020-12-06 08:41

Im trying to make it so that when the user clicks a button, it becomes \"X\" or \"0\" (Depending on their team). How can I make it so that the text on the button is updated?

相关标签:
7条回答
  • 2020-12-06 09:13

    use myButtonObject["text"] = "Hello World"

    python 3

    from tkinter import *
    
    btnMyButton = Button(text="Im Button", command=onClick)
    btnMyButton["text"] = "Im not button"
    

    python 2

    import Tkinter as tk
    
    btnMyButton = tk.Button(text="Im Button", command=onClick)
    btnMyButton["text"] = "Im not button"
    
    0 讨论(0)
提交回复
热议问题