0

I am trying to add buttons with custom bg or image so like 3d color. But it gives a white unclickable button as result. I tried many other ways but failed, the code i gave below its a code which lets us to select the weight and height we want for the button that's why i choosed it otherwise if other things like the .zoom or making a function to make the image fit the button were working i would be using them, they are all not working and i have no idea, i know i must be doing something wrong but wellas you see i am new in python, i learned everything myself so really i am 0 x). I Resized the image aswell, it has the same weight height with the button: enter image description here

root.geometry(geo)

image = ImageTk.PhotoImage(file='background.png')

label = Label(root, image=image)
label.pack(fill='both', expand=True)
label.image = image 


myWidth = 150
myHeight = 82
img4=Image.open('button.png')
image4=img4.resize((myWidth,myHeight))
useImg4=ImageTk.PhotoImage(image4)
quitBtn = Button(label, image=useImg4,command=lambda: root.destroy())
quitBtn.pack()

do you know why its not working? The result: enter image description here

  • Are you saying this exact code gives you the error? What you describe sounds like you are creating the image in a function. See https://stackoverflow.com/questions/16424091 – Bryan Oakley Feb 16 '21 at 00:28
  • wov! you're smart xD, how did you understand that? It worked when i took it off from the function thanks! @BryanOakley –  Feb 16 '21 at 05:44

0 Answers0