1

I am trying to make my TkInter application resizable, and I am having some troubles achieving the desired layout. Specifically I have some labels that I would like to take up equal amounts of horizontal space, which I would think could be done with the weight attribute. However, as the effbot guide on Tkinter grid geometry manager states

"weight=A relative weight used to distribute additional space between columns."

I would like the absolute size of the labels to be equal, not the amount of extra space - how would I achieve this?

I do setup the labels as follows:

for i in range(0, 7):
    Grid.columnconfigure(self.labelF,index=i, weight=1)

Label(self.labelF, text="Measurement ID", anchor=W, width=0).grid(row=0, column=0, sticky=W+E)
Label(self.labelF, text="Sample ID", anchor=W, width=0).grid(row=0, column=1, sticky=W+E)
Label(self.labelF, text="Meat Type", anchor=W, width=0).grid(row=0, column=2, sticky=W+E)
Label(self.labelF, text="Time", anchor=W, width=0).grid(row=0, column=3, sticky=W+E)
Label(self.labelF, text="Temperature", anchor=W, width=0).grid(row=0, column=4, sticky=W+E)
Label(self.labelF, text="Measurement", anchor=W, width=0).grid(row=0, column=5, sticky=W+E)
Label(self.labelF, text="Comment", anchor=W, width=0).grid(row=0, column=6, sticky=W+E)

Cheers

Halcyon
  • 53
  • 8

1 Answers1

1

rowconfigure and columnconfigure has another attribute, uniform which lets you make certain rows or columns part of a uniform group. Every row or column in the group will have the same size.

The value of the attribute can be anything, as long all rows or columns that you want to be equal have the same value.

For example:

for i in range(0, 7):
    Grid.columnconfigure(..., uniform="foo")
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685