Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter - Columns of equal weight are NOT equal width

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?

like image 397
Codesmith Avatar asked Aug 02 '17 17:08

Codesmith


1 Answers

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.

like image 109
Bryan Oakley Avatar answered Nov 04 '22 17:11

Bryan Oakley