Second post about tkinter from zero. We have seen how to make a button, now we take a look at labels. It’s easy as you may know, we will also check how o bind the click of the mouse to the label to make a call to a function that does change the text of the label. Enjoy the video.
import tkinter as tk
def click(event):
lab["text"]="touched"
root = tk.Tk()
root.geometry("400x400")
root.title("Label")
lab = tk.Label(
root,
text="My label",
font="Arial 20",
fg="red",
bg="yellow")
lab.pack()
lab.bind(
"<Button-1>", click)
root.mainloop()

In the previous post we’ve seen how to make a button with tkinter
How to create buttons is a GUI with Python and the module tkinter
Subscribe to the newsletter for updates
Tkinter templatesTwitter: @pythonprogrammi - python_pygame
Claude's Games
1. Memory gameVideos
Speech recognition gamePygame's Platform Game