python-3.x 单击按钮时重置边框宽度

soat7uwm  于 2023-02-01  发布在  Python
关注(0)|答案(1)|浏览(122)

我正在做一个抽认卡游戏(正在进行中),正确的按钮有背景,我把边框宽度设置为0,这很有效,但是每当我点击按钮(它被按住),边框就会回来。
这是我的代码:

from tkinter import *

# variables
BACKGROUND_COLOR = "#B1DDC6"

# basic setup
window = Tk()
window.config(pady=50, padx=50, bg=BACKGROUND_COLOR)
window.title("Flashy")

# everything else

# actual flash card
flash_card_img = PhotoImage(file="images/card_front.png")
flash_card = Canvas(highlightthickness=0, height=526, width=800, bg=BACKGROUND_COLOR)
flash_card.create_image(400, 263, image=flash_card_img)
flash_card.grid(row=0, column=0, columnspan=2)

checkmark_img = PhotoImage(file="images/right.png")
correct_button = Button(image=checkmark_img, highlightthickness=0, bg=BACKGROUND_COLOR, highlightcolor=BACKGROUND_COLOR,
                        borderwidth=0)
correct_button.grid(column=0, row=1)

# mainloop
window.mainloop()

我该怎么做呢?
P.S.以下是相关资源:
复选标记图像:

抽认卡图像:

gblwokeq

gblwokeq1#

感谢@Derek,我使用了activebackground=BACKGROUNDCOLOR,它起作用了!

相关问题