Python 3 Tkinter Align Text in Center Position in Label Widget Full Example in GUI Desktop App Full Project For Beginners

Python 3 Tkinter Align Text in Center Position in Label Widget Full Example in GUI Desktop App Full Project For Beginners

 

Welcome folks today in this blog post we will be aligning label text in the center position in tkinter gui desktop app in python. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to install the below library using the pip command as shown below

 

pip install tkinter

 

After installing this library you need to make an app.py file and copy paste the following code

 

app.py

 

import tkinter as tk

class Window(tk.Tk):
    def __init__(self):
        super().__init__()
        self.title("Hello Tkinter")

        label = tk.Label(self, text="Hello World!")
        label.pack(fill=tk.BOTH, expand=1, padx=100, pady=50)


if __name__ == "__main__":
    window = Window()
    window.mainloop()

 

 

If you execute the above python script by typing the below command

 

python app.py

 

 

Leave a Reply