[Tutor] How to make the label left justified in a frame
Michael Lange
klappnase at freenet.de
Thu Nov 23 17:15:10 CET 2006
On Thu, 23 Nov 2006 14:14:59 +0000
"Asrarahmed Kadri" <ajkadri at googlemail.com> wrote:
> Hi Folks,
>
> I am using grid manager inside a frame to arrange 4 label widgets, one
> beneath the other.
>
> What I want is that all teh labels should be placed in the left of the
> frame...
>
> There is no effect of using sticky = W.
>
> Please help ; is it possible to do it with anchor..???
>
> I have the follwng code:
>
>
> frame3 = Frame(root,relief='sunken',bd=2)
> frame3.pack(fill='x')
> label_st_date = Label(frame3,text='Start Date:',font=font_object2)
> label_st_date.grid(row=0)
> label_ed_date = Label(frame3,text='End Date:')
> label_ed_date.grid(row=1,sticky=W)
>
> label_st_time = Label(frame3,text='Start Time:')
> label_st_time.grid(row=3,sticky=W)
> label_ed_time = Label(frame3,text='End Time:')
> label_ed_time.grid(row=4)
Hi Asrarahmed,
sticky=W does put the labels to the frame's left side; the problem is that
the frame's grid column does not expand beyond the requested size of the labels.
To fix this, you need to call: frame3.grid_columnconfigure(0, weight=1)
(similar to pack(fill=X, expand=True)).
I hope this helps
Michael
More information about the Tutor
mailing list