首页 > 解决方案 > Python TKMACOSX Button Anchor 从中心开始

问题描述

我正在使用 tkmaxosx(MacOS、Pycharm 2020.2.3、Python 3.8)在 Python 应用程序中放置按钮。我希望按钮文本在按钮的左上角起作用,所以我设置了“anchor=NW”。

问题是,声明的点是使用按钮的中心点作为固定参考点。这是代码:

foo=Button(foowin, text='Test Text', anchor=NW, height=18, width=145, bg='SystemButtonFace', command=lambda rn=i: FooCommand(variables))

这是结果,显示了不同的锚点: 显示 NW、E、W、SE 锚点

标签: pythonpycharm

解决方案


tkmacosx 按钮的锚定问题已在 tkmacosx-0.1.6 版本中得到修复。你可以升级它

pip install tkmacosx --upgrade

推荐阅读