I am trying to use an image for the canvas background. I was successful before now I get an error no matter what I do. The only difference that I know of is that I was using 3.7 before and now I am using 3.5.

After some research I was able to use a jpg image for the canvas background. I shut down the Raspberry Pi and when I started it up the next morning it wouldn't boot. I flashed a new sd card with 3.5 (that's all I found) and now I am getting an error. I tried jpg, png, gif. I tried full path, relative path. Here is the code :

w = Tk()
w.geometry = ("1920x1080")

c = Canvas(w, height=1080, width=1920,)
c.pack()

# I tried everything here
img = Image.open("Dash-Background.png")
background_image = ImageTk.PhotoImage(img)

c.create_image(0, 0, background_image, anchor="nw")

I expected to get a 1920x1080 window with my image centered like before. Instead I get a window with a black background (ok), but no image and the following error:

_tkinter.tclerror: unknown option "pyimage1"

What am I doing wrong??

1 Answers

2
MaxiMouse On

Replace the call to create_image with:

c.create_image(0, 0, image=background_image, anchor="nw")