Reputation: 117
I am trying to use anchor to align the text in a Label to the right like that:
label=Label(root, text="some text", anchor='e', width=50)
It works fine for one line. but for some reason when the text is longer than one line it works only for the longest line, but the other lines are centered ralative to the longest one. Why does it happen? and how can i fix that? example
Upvotes: 1
Views: 647
Reputation: 243
so I think your problem is that you are using anchor
instead of justify
.
These two differ on how many text lines they manipulate. The first affects one line of text while the latter affects more than one line of text.
So I tried it out and:
from tkinter import *
root = Tk()
myContainer1 = Frame(root)
myContainer1.grid()
label1 = Label(root, text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.\n" +
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer\n" +
"took a galley of type and scrambled it to make a type specimen book.\n" +
"It has survived not only five centuries, but also the leap into electronic typesetting,\n"+
"remaining essentially unchanged.",justify = 'right', width = 100 )
label1.grid(row = 0, column= 0)
root.mainloop()
So this works and justifies the text to the east.
Hope this helps!
Upvotes: 3