0

I'm working with tkinter in Python and using grid, and when I put two widgets in different columns in one row and a widget spanning both columns in another row, then the columns' widths are both set to half the width of the widget spanning both rows. Is there any way I could get it to fit the columns to the two widgets?

The reason I want this is to get the left widget to fill all of the width of the spanning widget except for that taken up by the right widget, which should be a fixed width.

The code is like this:

spanningboth.grid(row=0, column=0, columnspan = 2)
infirstcol.grid(column=0, row=1, sticky='EW')
insecondcol.grid(column = 1, row = 1)
davidhsonic
  • 11
  • 1
  • 3
  • _" If I do the same thing, but put the two widgets in a lower row, then the columns' widths are both set to half the width of the widget spanning both rows."_ - that is not a true statement. The behavior is identical whether the two smaller widgets are on top or below. Please provide a _complete_ [mcve] to illustrate the problem. – Bryan Oakley Apr 10 '21 at 15:34
  • @BryanOakley I realized right after I posted the question that that part was incorrect, and edited the question. – davidhsonic Apr 10 '21 at 17:38
  • You cannot do it because logically a row/column is reserved to that widget no matter how much space it takes, You can't really do anything about that except use a different geometry manager or set more columns – Matiiss Apr 10 '21 at 18:23
  • 1
    @Matiiss: your comment doesn't make much sense. `grid` is highly configurable. Most likely the solution to the OP's problem can be done with `grid`. – Bryan Oakley Apr 10 '21 at 20:39
  • 1
    Use `.columnconfigure(0, weight=1)` on the parent of the widgets. – acw1668 Apr 10 '21 at 23:37
  • @acw1668 That does exactly what I want. Do you want to put that in an answer so I can mark it as correct? – davidhsonic Apr 11 '21 at 19:12

0 Answers0