Home > Enterprise >  Tkinter Label Widget Justify
Tkinter Label Widget Justify

Time:11-27

I have an information frame inside of an information pane on a form. I'm using labels to give the user needed information. However when using the label widget the labels aren't left justified event though I set justify='left'. Here is my code:

 infolabel1 = Label(infoFrame, justify ='left', text="This project uses Strat-O-Matic Baseball" )
infolabel1.pack_propagate()
infolabel1.grid(row=1, column=1)

infolabel2 = Label(infoFrame, justify = 'left', text='Items with * are required')
infolabel2.pack_propagate()
infolabel2.grid(row=2, column=1)

CodePudding user response:

It's hard to be certain as you have not provided any of the code surrounding these widgets, but here goes:

The Label widgets are justified, but they are not of equal length, and grid() places them in the middle of available space. The shorter Label will seem to be to far to the right. You can fix this by sticky the Label to the left side of the containing Frame:

infolabel2.grid(row=2, column=1, sticky='w')
  • Related