'I am making a calculator and I get TypeError: can only concatenate str (not "int") to str [closed]

I was making a graphic calculator and I just received an error.

Here is the code:

from tkinter import *
from PIL import *
window = Tk()
window.geometry('680x815')
window.resizable(width=False,height=False)
photo_bg = PhotoImage(file=r'C:\Users\Lenovo\Desktop\behrad\calc.png')
label_bg = Label(window,image=photo_bg)
label_bg.place(x=30,y=0, height=780)
photo_0 = PhotoImage(file=r'C:\Users\Lenovo\Desktop\behrad\calc.0.png')
button_0 = Button(window,photo_0)

window.mainloop()

I receive the error at this line:
button_0 = Button(window,photo_0)
and error:
TypeError: can only concatenate str (not "int") to str I think this problem has arisen because I'm setting the photo image wrong.



Solution 1:[1]

As @derek suggested in the comments, you may try button_0 = Button(windows, image=photo_0)

Solution 2:[2]

You need to use something like this:

photo_0 = PhotoImage(file="calc.0.png")
button_calc = tk.Button(root, text="ButtonText", image=photo_0 , command=print_hello)
button_calc.pack() 

where photo_0 is your image, images and print_hello is the function for button use.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 C?t?lin George Fe?til?