1

我已经看到了这个Python Tkinter - Set Entry grid width 100% and this columnspan in grid options does't function(这更有用)但无法弄清楚如何让我的“重新绘制”按钮填充它的行宽在。无论我将小部件的列跨度设置为什么,它都不会改变按钮的宽度。该按钮与其他小部件位于一个框架中,该行上没有其他内容。

在此处输入图像描述

用于按钮的代码:

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)
4

1 回答 1

1

要让它完全填满行,请使用sticky='nsew',例如:

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将按钮分配给最多 2 列,但它没有完全“填充”或拉伸 2 列。

于 2020-09-29T07:24:23.670 回答