5

I have a Tkinter Toplevel window with three columns. All three columns are configured to have equal weight. Inside column 0 and 2 are sub-frames, inside which are Listbox widgets. Inside column 1 is a set of buttons. For some reason, despite the fact that my 3 columns have equal weight, these Listboxes 'force' their columns to occupy more space.

I've written,

window.columnconfigure(0,weight=1)
window.columnconfigure(1,weight=1)
window.columnconfigure(2,weight=1)

But I get:

Unequal Sizes

I've also given column 1 weights of 3 and 5, but it still remains small. However, having done this, it seems that columns 0 and 2 have some minimum size, then after subtracting that from the real width, the leftover width is used and divided by weight.

Is this a bug? Is there something I need to do to my lists? Might I be forgetting something?

halfer
  • 19,824
  • 17
  • 99
  • 186
Codesmith
  • 5,779
  • 5
  • 38
  • 50

1 Answers1

12

It is not a bug. weight determines how extra space is allocated. It doesn't make any guarantees about the size of a row or column.

If you want columns to have a uniform width, use the uniform option and make them all be part of the same uniform group.

window.columnconfigure(0,weight=1, uniform='third')
window.columnconfigure(1,weight=1, uniform='third')
window.columnconfigure(2,weight=1, uniform='third')

Note: there is nothing special about 'third' -- it can be any string as long as it's the same string for all three columns.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • 1
    Sweet! Works great; didn't realize that! Wish I could find these details in places like http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/grid-config.html – Codesmith Aug 03 '17 at 01:39