简体   繁体   English

grid_columnconfigure() 在我的框架内不起作用

[英]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.

相关问题 如何让 .grid_columnconfigure() 在 Frame 内工作? - How to get .grid_columnconfigure() working inside Frame? 如何使用grid-Manager使.grid_columnconfigure()在Frame内部工作? - How to get .grid_columnconfigure() working inside Frame using grid-Manager? 为什么我的 grid_columnconfigure 不能在这个 tkinter 代码上工作? - Why wont my grid_columnconfigure work on this tkinter code? tkinter 的 grid_columnconfigure / row_columnconfigure 是如何工作的? - How does tkinter's grid_columnconfigure / row_columnconfigure work? 带有.grid_columnconfigure的ttk .grid(sticky ='ew')对于笔记本条目无法正常工作 - ttk .grid(sticky = 'ew') with .grid_columnconfigure doesn't work properly for notebook entries 如何使用 grid_columnconfigure tkinter(错误)拉出一行? - How can I pull a row through with grid_columnconfigure tkinter (Error)? TKinter 列配置调整大小选项不起作用 - TKinter columnconfigure resize option not working tkinter columnconfigure将我的标签文本设置为居中 - tkinter columnconfigure is setting my label text to center 如何在 Tkinter 中使用带有可滚动框架的 columnconfigure? - How do you use columnconfigure with a scrollable frame in Tkinter? 为什么 tkinter 网格、列配置和行配置值不会动态变化? - Why tkinter grid, columnconfigure and rowconfigure value not changing dynamically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM