1

I have seen this Python Tkinter - Set Entry grid width 100% and this columnspan in grid options dose't function (which was more useful) but cannot figure out how to get my 'Replot' button to fill the width of the row it is on. No matter what I set the columnspan of the widget to it never changes the width of the button. The button is in a frame with the other widgets and there is nothing else on that row.

enter image description here

Code used for the buttons:

button_quit2 = tk.Button(root, text = "Replot", command = rangesReplot, relief = tk.GROOVE, padx =30, pady =20 )
button_quit2.grid(row = 10, column = 0, columnspan=2)
Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46
Windy71
  • 851
  • 1
  • 9
  • 30

1 Answers1

1

To get it to fill the row fully, use sticky='nsew', like:

button_quit2 = tk.Button(frame2, text = "Replot", command = rangesReplot, relief = tk.GROOVE, padx =30, pady =20 )
button_quit2.grid(row = 10, column = 0, columnspan=2,sticky=tk.N+tk.S+tk.E+tk.W) #same as sticky='nsew'

columnspan allocates the button to have up to 2 columns but it does not completely "fill" or stretch the 2 columns.

halfer
  • 19,824
  • 17
  • 99
  • 186
Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46
  • 1
    Your terminology isn't quite correct. `columnspan` doesn't stretch the button. It simply allocates more than one column of space for the button. – Bryan Oakley Sep 29 '20 at 14:16