python - Tkinter 按钮与网格对齐

标签 python python-3.x tkinter

我想将 tkinter 按钮向左对齐,但找不到任何帮助。

addButton = Button(root,
                   text="Add Expenses",
                   bg='red',
                   fg='white',
                   command = addButtonDef,
                   font=("Arial narrow",32))
addButton.grid(row=1, column=0)

关于如何对齐有什么解决方案吗?仅使用网格?

最佳答案

您是否尝试过使用“W”表示西的“sticky”。​​

addButton.grid(sticky="W", row=1, column=0)

或者,您可以尝试在按钮小部件中使用anchor="w"。

addButton = Button(root,
                   anchor="w"...)

关于python - Tkinter 按钮与网格对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58878577/

相关文章:

Python 根据日期从 CSV 中删除行

python - Sprite 没有朝它所面对的同一方向移动

python - 无返回时处理 JSON 解码错误

python - tkinter - 辅助显示器的屏幕宽度和高度?

python - 如何在不删除标题栏的情况下禁用 Tkinter 窗口的移动

python - 如何在 Tkinter 中添加图像?

python - 无法在 Fedora 27 上的 Python2 virtualenv 中使用 mysqldb

python - 如何使用PIL(Python Image Library)旋转图片让黑色背景变透明

Python子进程,使用颜色实时打印并保存stdout

python - 在 Django Admin 中添加指向 Actions 的链接