您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python Tkinter-设置条目网格宽度100%

Python Tkinter-设置条目网格宽度100%

使用grid()您可以grid_columnconfigure()在父项上使用Entry

import tkinter as tk

root = tk.Tk()

tk.Entry(root).grid(sticky='we')
root.grid_columnconfigure(0, weight=1)

root.mainloop()

使用pack()你可以使用fill='x'

import tkinter as tk

root = tk.Tk()

tk.Entry(root).pack(fill='x')

root.mainloop()

顺便说一句:使用:

self.path = tk.Entry().grid()

您将的结果分配给grid()self.pathgrid()始终返回None

如果需要,self.path请执行以下操作:

self.path = tk.Entry()
self.path.grid()

如果您不需要,self.path则可以执行以下操作:

tk.Entry().path.grid()
python 2022/1/1 18:45:58 有324人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶