pupabupa
pupabupa

Reputation: 31

tkinter button image loses transparency when pressed

So I have button widgets with different background colors, and transparent gif images. My problem is that when I press the button, the transparency is lost briefly which looks dumb.

During a button press, spots in the gif image that are supposed to be same colored as the button background are in DefaultBackground color instead.

Is there any way to avoid this?

Here's a very simple example of a button widget I have, it is applied to a frame

Button(frame, image=img, bg="#ff73c8")

A very simple pink button held down, changes color

the image I used in my example, has transparent background

Upvotes: 2

Views: 1041

Answers (1)

Miriam
Miriam

Reputation: 2721

When a button is pressed it becomes active, which is different from its ordinary state, so you need to specify the parameter activebackground:

Button(r, image=i, bg="#ff73c8", activebackground="#ff73c8")

See more on button states here.

Upvotes: 2

Related Questions