1
votes

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)
1
Try button_quit2.grid(row = 10, column = 0, columnspan=2,stikcy='nsew') ? - Cool Cloud
@CoolCloud could you post that as an answer and I'll accept. Is columnspan on its own not enough? Your suggestion works. - Windy71
its making me wait before accepting, 2more mins I think. - Windy71

1 Answers

1
votes

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.