Search code examples
pythonpython-3.xtkintertkinter-button

Borderwidth resets when button clicked


So I'm making a flashcard game (in progress) and the correct button has a background. I set the borderwidth to 0, and that worked, but whenever I click the button (and it is being held down) the border comes back.

This is my code so far:

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()

How can I make this work?

P.S. Here are the resources:

The Checkmark image: Checkmark Image

The Flashcard image: Flashcard Image


Solution

  • Thanks to @Derek, I used activebackground=BACKGROUNDCOLOR, which worked!