
import tkinter as tk
def toggle_text():
if button.cget("text") == "Click Me":
button.config(text="Clicked!")
else:
button.config(text="Click Me")
root = tk.Tk()
root.title("Toggle Button Text")
button = tk.Button(root, text="Click Me", command=toggle_text)
button.pack()
root.mainloop()
No comments:
Post a Comment