How to Create Label in Python TKinter GUI

In this lesson i want to show you How to Create Label in Python TKinter GUI, To create a label in Python TKinter GUI, you can use the Label widget. Here is an example of creating a label and setting its text and font:

 

In this example, we first import the Tk class from the tkinter module. Then we create a new Tkinter application by creating an instance of the Tk class. The Label widget is then created and its text and font are set to “Hello GeeksCoders” and “Arial 20”, respectively. Finally, the pack() method is used to place the label on the screen. The mainloop() method is called to start the event loop and display the label on the screen.

 

 

Run the complete code and this will be the result 

How to Create Label in Python TKinter GUI
How to Create Label in Python TKinter GUI

 

 

You can also use grid or place method for layout management.

 

In the above example, grid layout is used to place the label on the screen and place layout is used to place the label on the specific position.

 

Here is an example of creating a label using Object-Oriented Programming (OOP) in Python TKinter:

 

 

You can also use grid or place layout management within the class

 

In the above example, grid layout is used within the class to place the label on the screen and place layout is used within the class to place the label on the specific position.

 

 

Learn More on TKinter

Leave a Comment