[英]grid_columnconfigure() Not Working Inside my Frame
Here is My Code这是我的代码
from tkinter import *
root = Tk()
myframe = Frame(root, bg="red")
myframe.pack()
btn1 = Button(myframe, text="Button 1", font="Comicsans 15 bold")
btn1.grid(row=0, column=0)
btn2 = Button(myframe, text="Button 2", font="Comicsans 15 bold")
btn2.grid(row=0, column=1)
root.grid_columnconfigure((0, 1), weight=1)
root.mainloop()
How do I make grid_columnconfigure()
work?如何使grid_columnconfigure()
工作?
You're calling it on root
, but the widget inside root
is using pack
.您在root
上调用它,但root
内的小部件正在使用pack
。 If you expect it to affect the buttons, you need to call it on myframe
:如果您希望它影响按钮,则需要在myframe
上调用它:
myframe.grid_columnconfigure((0,1), weight=1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.