我正在尝试更改我的 mac (catalina) 上 tkinter 按钮的背景色,但它没有获得彩色背景,而是在布局中显示空白区域。
我使用的按钮代码:
OpeningFile = Button(root, width=45, bg="#82CC6C", fg="black", text="OPEN", highlightbackground="#82CC6C", highlightthickness=1, borderwidth=0.2, relief="groove", padx=0, pady=0, command=openfile)
OpeningFile.grid()
我得到的结果:
我的预期:
我尝试改变很多参数,但它仍然给我同样的结果,
它可以被修复还是仅在 mac 内的 tkinter 中存在错误? (它在 windows 中工作正常)
最佳答案
我得到了修复:
使用tkmacosx mac 中的 tkinter 按钮模块,使用“from tkmacosx import Button”,然后更改参数并使用 borderless=1 删除不必要的布局。 你可以看到我使用模块后得到的结果:
关于python - Tkinter 按钮背景颜色在 mac os 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72056706/