python - 使用 Sticky 时无法调整 Tkinter 按钮的大小
问题描述
我正在尝试调整按钮,但不知何故,即使在改变width之后,它也不会改变大小。这是我的代码:
if __name__ == '__main__':
# create application window
app = Tk()
# title
app.title("Music Players")
# geometry
app.geometry('500x300')
# background color
app.configure(bg='orange')
equation = StringVar()
window_1 = Label(app, textvariable=equation)
window_1.grid(columnspan=3, ipadx=100, ipady=10)
equation.set('music player')
window_2 = Entry(app, width=30)
window_2.grid(columnspan=5, ipadx=100, ipady=10)
# Create buttons and other accessories
button1 = Button(app, text='PLAY', fg='yellow', bg='purple',
command=lambda: press('PLAY'), height=2, width=1)
button1.grid(row=2, column=0, sticky="NSEW")
button2 = Button(app, text='STOP', fg='yellow', bg='purple',
command=lambda: press('STOP'), height=2, width=2)
button2.grid(row=2, column=1, sticky="NSEW")
button3 = Button(app, text='NEXT', fg='yellow', bg='purple',
command=lambda: press('NEXT'), height=2, width=2)
button3.grid(row=2, column=2, sticky="NSEW")
button4 = Button(app, text='PREVIOUS', fg='yellow', bg='purple',
command=lambda: press('PREVIOUS'), height=2, width=2)
button4.grid(row=2, column=3, sticky="NSEW")
我假设这是因为sticky="NSEW",因为当我删除它时,按钮会改变大小,但是按钮之间有很大的空间,而且即使columns=0和columns=1也很间隔.
我怎样才能改变按钮的大小而不摆脱粘滞?或者,没有粘性,但按钮彼此相邻?
先感谢您!
解决方案
推荐阅读
- java - 如何使用 HttpUrlConnection 发送 JSON 和附件
- python - 计算列中的重复项并将它们添加到新的 col Pandas
- excel - 为什么 VBA For Next Loop 计算不正确?{VBA}
- microstrategy - 微观策略报告IF声明
- python - Python Tkinter 在笔记本中放置框架和树视图
- python - 如何在 JupyterHub 新环境中高亮 SQL?
- graphite - docker:来自守护进程的错误响应:冲突。容器名称“/grafana”已被容器“f6b2d471d737a”使用
- python - Python删除(从SQL表中获取数据后
- java - 从其他微服务获取主要的 spring 安全性
- r - Rmarkdown 未将 .Rmd 呈现为 pdf,pandoc 错误 2