How to use the Tkinter label widget

Tkinter is a Python GUI module used to create cross-platform desktop applications. This module comes with Python's standard library, so we don't need to install any modules to use it. It is lightweight and easy to use compared to other GUI modules available. In this answer, we'll learn to create and use a label in Tkinter.

The label widget in Tkinter is used as a box to place images or text inside it.

Syntax

Label(window_instance, options)

Here, we can provide options like background color, foreground color, text, font, height, width, etc.

Example

#import tkinter module
import tkinter as tk
#create window
window = tk.Tk()

#provide size to window
window.geometry("300x300")

#add text label to window
tk.Label(window, text="Hello From Educative !!!"+str(tk.TkVersion), bg = "orange", fg = "white",padx = "20", pady = "20").pack()

window.mainloop()

Note: The above program runs on the Tkinter version 8.6

Explanation

  • Line 5: We create an instance of the Tkinter class Tk() and assigned it to variable window.

  • Line 8: We set the window size as 300x300 pixels.

  • Line 11: We create a label widget and attached it to the window with the below options:

    • Foreground color fg as white

    • Background-color bg as orange

    • Text as Hello From Educative !!!

    • Horizontal padding padx as 20

    • Vertical padding pady as 20

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved