import tkinter as tk from tkinter import ttk def label_clicked(event): label.config(text="Hello World") root = tk.Tk() root.geometry("300x200") label = ttk.Label(root, text="Click Me!") label.bind("", label_clicked) label.pack(pady=50) root.mainloop()
import tkinter as tk from tkinter import ttk def label_keypressed(event): label.config(text="You pressed " + event.keysym) root = tk.Tk() root.geometry("300x200") label = ttk.Label(root, text="Press any key!") label.bind("In this example, we create a Label widget that displays "Press any key!" and bind the "", label_keypressed) label.pack(pady=50) root.mainloop()