简体   繁体   English

无法获得 columnspan 以使按钮填充 Tkinter 框架的行

[英]cannot get columnspan to make button fill the row of a Tkinter frame

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.我见过这个Python Tkinter - Set Entry grid width 100% and this columnspan in grid options dos't function (这更有用)但无法弄清楚如何让我的“重新绘制”按钮填充它所在的行的宽度在。 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.该按钮与其他小部件位于一个框架中,该行上没有其他任何内容。

在此处输入图片说明

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)

To get it to fill the row fully, use sticky='nsew' , like:要让它完全填满该行,请使用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 allocates the button to have up to 2 columns but it does not completely "fill" or stretch the 2 columns. columnspan将按钮分配为最多 2 列,但它不会完全“填充”或拉伸 2 列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM