可以,可以使用 grid 布局或者 pack 布局中的 fill 选项来实现。以下是使用 pack 布局实现的代码:

# 输入cooKie
self.cookie_label = tk.Label(self, text='请输入cookie:')
self.cookie_label.pack(side='top', fill='x')

self.cookie_entry = tk.Entry(self)
self.cookie_entry.pack(side='top', fill='x')

self.date_label = tk.Label(self, text='请输入开始日期 格式为yyyy-mm-dd hh:mm:ss:')
self.date_label.pack(side='top', fill='x')

self.date_entry = tk.Entry(self)
self.date_entry.pack(side='top', fill='x')

# 结束时间
self.enddate_label = tk.Label(self, text='请输入结束日期 格式为yyyy-mm-dd hh:mm:ss:')
self.enddate_label.pack(side='top', fill='x')

self.enddate_entry = tk.Entry(self)
self.enddate_entry.pack(side='top', fill='x')

这样每个元素就会垂直排列,并且占据整个窗口的宽度。

Tkinter 窗口中垂直排列输入框和标签

原文地址: https://www.cveoy.top/t/topic/mTV7 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录