cak3_lover
cak3_lover

Reputation: 1938

left align text on setting Label width

I have a label inside a grid with a fixed width like this:

Label(popup,text="Testing",width=25,justify="left").grid(row=1,column=1,sticky="w",padx=(0,10),pady=10)

enter image description here

I need the text to align to the left and hide the overflow if any occurs,
How do I achieve this?

Upvotes: 0

Views: 53

Answers (1)

martineau
martineau

Reputation: 123443

You need to specify an anchor option when creating the Label widget:


from tkinter import *

popup = Tk()

Label(popup, text="Testing", width=25, anchor="w").grid(
        row=1, column=1, sticky="w", padx=(0,10), pady=10)

popup.mainloop()

Result:

Screenshot

Upvotes: 2

Related Questions