0

I want to use a transparent image as a button in a tkinter program. I searched a lot, and I finally came to this:

def play():
    Gun = PhotoImage(file='Gun.png')
    GunButton = Button(win, image = Gun) #no command yet
    GunButton.photo = Gun
    GunButton.place(x=100,y=100)

It shows the button as well but the image is not transparent, it has gray background. I tried this too but nothing changed:

def play():
    Gun = PhotoImage(file='Gun.png')
    GunButton = Button(win)
    GunButton.config(image=Gun)
    GunButton.photo = Gun
    GunButton.place(x=100,y=100)

I also tried this, but the image is blank I'm new to python I would be thankful if someone could help me

PariKia
  • 1
  • 2
  • 1
    What are you expecting to be visible through the transparent parts of your images? Tkinter widgets are *always* opaque rectangles - so your only actual option is the background color of the Button. – jasonharper Jul 05 '22 at 19:26
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 06 '22 at 05:02

0 Answers0