0

I'm creating a button in Tkinter and I wanted to create rounded corners, other posts suggested using an image to do this. After doing this I noticed that the corners of the button are filled in, unlike my original photo. How do I stop it from filling in?

I have tried using images with and without transparency, but the result is the same. I also tried putting something transparent in the middle of the image, this could be seen in the button but the corners could not. I also know it is not to do with the background of the button because when I change the colour in the .png it also changes the fill of the corners.

button_icon = tk.PhotoImage(file="C:/Python/buy_button.png")
button1 = tk.Button(d["inner_frame" + str(idx)], image=button_icon, command=lambda idx=idx: add(result, str(idx)+"A"), bd=0, bg="white")
button1.image = button_icon

I expected it to look identical to the .png however, the corners of the image is filled in by the colour surrounding it in the image.


Images:

The original png:
enter image description here

What appears when I run:
enter image description here

Artemis
  • 2,553
  • 7
  • 21
  • 36
S.James
  • 19
  • 7
  • 1
    I'm not sure there's enough information in this question. I can't recreate what you're talking about with your code example. – Jarad Mar 24 '19 at 23:15
  • The effective layout is OS dependant, try `ttk.Button(...` but this requieres `ttk.Style(...` [Styles and Themes](https://tkdocs.com/tutorial/styles.html), relevant [how-to-change-the-color-of-ttk-button](https://stackoverflow.com/questions/27347981/how-to-change-the-color-of-ttk-button) – stovfl Mar 25 '19 at 14:49

1 Answers1

0

After some further testing, I have found that the issue was due to my image being slightly bigger than the size of my button. After resizing the .png it works fine and the image fills the button.

Thanks for the help!

S.James
  • 19
  • 7