Creating Clickable Tkinter labels


Tkinter Label widgets provide a way to display text and images in the Tkinter application window. We can configure the properties of the label widget by defining the attributes and properties in it. The Label widget can be converted into a clickable object by defining a function that contains some operation which can later be bound with a key.


In this example, we will create a Label widget. Clicking over the Label widget will redirect the user to a specified webpage. So, the label will act as a hyperlink.

#Import the required libraries
from tkinter import *
import webbrowser

#Create an instance of tkinter frame
win = Tk()

#Define a callback function
def callback(url):

#Create a Label to display the link
link = Label(win, text="",font=('Helvetica', 15), fg="blue", cursor="hand2")
link.bind("<Button-1>", lambda e: callback(""))


Running the above code will display a window containing a Label widget. Clicking over the label will redirect the user to the website ""

Published on 26-May-2021 11:52:15