Site icon TestingDocs.com

Python Label Widget

Overview

Python Label widget is a part of the Tkinter library, the standard GUI toolkit for developing GUI applications. The Label widget displays text or images on a GUI window.

Syntax

The general syntax to create a label widget is as follows:

lbl = Label (window, options, …..)

 

Python GUI Program

# Python Program – Label widget
# Python Tutorials – www.TestingDocs.com

from tkinter import *

# Create the window
window = Tk()

window.title(“Python Label Program”)
window.geometry(‘800×400’)
window.configure(background =”lightblue”)

Label(window, text=”Python Tutorials”, fg=”green”,
font=”Arial 33 bold”).pack()

Label(window, text=”By www.TestingDocs.com”, fg=”green”,
font=”Arial 44 bold”).pack()

# Start the Tkinter event loop
window.mainloop()

 

Program Output

Save the program and execute it to view the output.

 

This example creates two labeled widgets with specific font, text color, etc.

Python Tutorials

Python Tutorial on this website can be found at:

https://www.testingdocs.com/python-tutorials/

More information on Python is available at the official website:

https://www.python.org

Exit mobile version