Open In App

Python Tkinter – Label

Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task using widgets. Widgets are standard graphical user interfaces (GUI) elements, like buttons and menus. Note: For more information, refer to Python GUI – tkinter

Label Widget

Tkinter Label is a widget that is used to implement display boxes where you can place text or images. The text displayed by this widget can be changed by the developer at any time you want. It is also used to perform tasks such as to underline the part of the text and span the text across multiple lines. It is important to note that a label can use only one font at a time to display text. To use a label, you just have to specify what to display in it (this can be text, a bitmap, or an image). Syntax:



w = Label ( master, option, … )

Parameters:



Various Options are:

Example: 




from tkinter import *
 
 
top = Tk()  
top.geometry("450x300") 
   
# the label for user_name
user_name = Label(top,
                  text = "Username").place(x = 40,
                                           y = 60
   
# the label for user_password 
user_password = Label(top,
                      text = "Password").place(x = 40,
                                               y = 100
   
submit_button = Button(top,
                       text = "Submit").place(x = 40,
                                              y = 130)
   
user_name_input_area = Entry(top,
                             width = 30).place(x = 110,
                                               y = 60
   
user_password_entry_area = Entry(top,
                                 width = 30).place(x = 110,
                                                   y = 100
     
top.mainloop()

Output :


Article Tags :