python - Tkinter 按钮背景颜色在 mac os 中不起作用

标签 python macos tkinter tkinter-layout tkinter-button

我正在尝试更改我的 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()

我得到的结果:

Error button

我的预期:

Expected rersult

我尝试改变很多参数,但它仍然给我同样的结果,

它可以被修复还是仅在 mac 内的 tkinter 中存在错误? (它在 windows 中工作正常)

最佳答案

我得到了修复:

使用tkmacosx mac 中的 tkinter 按钮模块,使用“from tkmacosx import Button”,然后更改参数并使用 borderless=1 删除不必要的布局。 你可以看到我使用模块后得到的结果:

MacOS screenshot

关于python - Tkinter 按钮背景颜色在 mac os 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72056706/

相关文章:

python - 寻找最大的重复子串

python - 使用DOT的带有oAuth2的Django DRF(django-oauth-toolkit)

macos - 我无法通过 Homebrew 软件在 Mac M1 上安装 v8@3.15

python - 属性错误 : 'set' object has no attribute 'items'

python - Tkinter:为用户选择的点设置颜色

python - 按索引值连接 Pandas 多索引数据帧的行

python - 如何在django中调用 View 文件中的模型函数

c - Mac 沙箱 : running a binary tool that needs/tmp

android - 通过 osx 命令行构建 tess-two 的问题

python - Python 中的 MD5 哈希函数更改数据