- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to align text to the left in Tkinter Label?
Tkinter Label widget can be aligned using the anchor attributes. In order to calculate the accommodate spacing and alignment of the widget, anchor would help in a better way. Anchor provides several options such as N, W, S, E, NW, NE. SW, SE which can be defined in the pack manager itself.
Example
In the following example, we will align the Label text of an application to the left by adding the anchor attribute towards “w” direction.
#Import the required library from tkinter import* #Create an instance of tkinter frame win= Tk() #Set the geometry win.geometry("750x250") #Create a Label Widget Label(win, text= "New Line Text", font= ('Helvetica 15 underline'), background="gray74").pack(pady=20, side= TOP, anchor="w") win.mainloop()
Output
Running the above code will align the text label widget towards Left direction.
- Related Articles
- How to get the Tkinter Label text?
- How to display multiple lines of text in Tkinter Label?
- How to change Tkinter label text on button press?
- How to justify text in label in tkinter in Python Need justify in tkinter?
- How to change the size of text on a label in Tkinter?
- Underline Text in Tkinter Label widget
- Changing Tkinter Label Text Dynamically using Label.configure()
- How to align axis label to the right or top in Matplotlib?
- How to add Label width in Tkinter?
- How to align checkbutton in ttk to the left side?
- How to Align the Dollar Signs Left in Excel?
- Python Tkinter – How do I change the text size in a label widget?
- How to word-wrap text in Tkinter Text?
- How to align text to the right in ttk Treeview widget?
- How to Justify Text using text-align & text-justify CSS Properties?

Advertisements