[Tkinter-discuss] re garding labels alignment in PyTkinter GUI
John McMonagle
jmcmonagle at velseis.com.au
Sat Jul 5 11:48:12 CEST 2008
> Hari Om,
>
> Here iam facing one problem is i created more than one labels
> which have different lengths.
>
> All labels text are displaying(aligned) in center based
> on longest label length. (I am not require any textwrapping)
>
> So how can i aligne all labels text from left side means
> left justify.
>
> Example code is:
> -------------------------------------------------
> from Tkinter import *
> master = Tk()
> w = Label(master, text="AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB", anchor=W,
> justify=LEFT)
> w.pack()
> w1 = Label(master, text="AAAAAAAAAAAAA ", anchor=W, justify=LEFT)
> w1.pack()
> mainloop()
> ----------------------------------
> Output producing is : AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB
> AAAAAAAAAAAAA
>
> But i require like this : AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB
> AAAAAAAAAAAAA
>
> Kindly help me to solve this problem:
> Iam very thankful if i got output like this.
>
> By urs friend
>
> Lakshminarayana.
You must also anchor the packing. Try the following:
from Tkinter import *
master = Tk()
w = Label(master, text="AAAAAAAAAAAAA BBBBBBBBBBBBBBBBBB", anchor=W,
justify=LEFT)
w.pack(anchor=W)
w1 = Label(master, text="AAAAAAAAAAAAA ", anchor=W, justify=LEFT)
w1.pack(anchor=W)
master.mainloop()
Regards,
John
More information about the Tkinter-discuss
mailing list