我正在尝试更改mac(catalina)上tkinter 按钮的背景颜色,但它没有获得彩色背景,而是在布局中显示空白。
我使用的按钮代码:
button_open = Button(root, width=45, bg="#82CC6C", fg="black", text="OPEN",
highlightbackground="#82CC6C", highlightthickness=1,
borderwidth=0.2, relief="groove", padx=0, pady=0)
button_open.grid()
Run Code Online (Sandbox Code Playgroud)
我得到的结果:
我所期望的:
我尝试更改所有参数,但总是给出相同的结果,
我们该如何解决这个问题?这只是 mac 上 tkinter 的错误吗?
我知道如何删除 Tkinter 按钮和图像的边框。它的完成方式与其他所有事情的完成方式几乎完全相同
borderwidth=0
Run Code Online (Sandbox Code Playgroud)
我需要帮助,如果为什么,即使我将其放入小部件的“设计参数”中,它仍然有边框。
我的代码如下。
# Imports the tkinter library.
from tkinter import *
from tkmacosx import Button
selectedBackground = "black"
selectedForeground = "#22fd35"
root = Tk()
root.configure(bg=selectedBackground)
def openCipher():
print("open cipher")
def openDecipher():
print("open decipher")
cipherButton = Button(root, text=" Cipher ", padx=40, pady=20, command=openCipher, borderwidth=0, background=selectedBackground, foreground=selectedForeground, highlightbackground=selectedForeground)
cipherButton.grid(row=1, column=0)
decipherButton = Button(root, text="Decipher", padx=40, pady=20, command=openDecipher, borderwidth=0, background=selectedBackground, foreground=selectedForeground, highlightbackground=selectedForeground).grid(row=1, column=2)
spacer1 = Label(root, text=" ", padx=10, pady=1, background=selectedBackground, foreground=selectedForeground, highlightbackground=selectedForeground).grid(row=4, column=1)
quitButton = Button(root, text="Exit d3cryptt", …Run Code Online (Sandbox Code Playgroud)