This code of mine is showing an error: _tkinter.TclError: unknown option "-command". I am a newbie so I may have made a silly mistake. Please help!
import tkinter
bod = tkinter.Tk()
button = tkinter.Button(bod, text="Hello (Click here)")
def hello():
button = tkinter.Button(bod, text="Hello World!")
button.place(x=10, y=100, height="100", width="100", command=hello)
bod.mainloop()
You should do this :
from tkinter import *
def hello():
button.config(text="Hello, World!")
bod = Tk()
button = Button(bod, text="Hello (Click here)", command=hello, height="100", width="100")
button.pack()
bod.mainloop()
This will help you : http://effbot.org/tkinterbook/button.htm#Tkinter.Button.config-method
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.