我正在嘗試更改我的 mac(catalina)上 tkinter 按鈕的 bg 顏色,但它沒有獲得彩色背景,而是在布局中顯示了一個空白區域。
我使用的按鈕代碼:
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()
結果我得到:

我所期望的:

我嘗試更改許多引數,但它仍然給我相同的結果,
可以修復還是僅是 tkinter 在 mac 中的錯誤?(它在Windows中正常作業)
uj5u.com熱心網友回復:
我正在尋找有關同一問題的資訊,這似乎是 tkinter 使用 MacOS API 的限制。基本上 MacOS 說按鈕顏色不能改變,所以 tkinter 不能改變它們。
https://github.com/python/cpython/issues/88409
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/469149.html
標籤:Python 苹果系统 tkinter tkinter 布局 tkinter 按钮
上一篇:PythontkinterEntry小部件驗證錯誤:TypeError:'str'objectisnotcallable
