Unicode error when attempting to put an image as the background

733 Views Asked by At

I am working on a school project for which I am making a small game using Python. Within python, I am using the Tkinter interface module to give shape to it all. I ran into a problem that I would not know anything about on how to fix it. I am trying to use an image as my background in my menu's but for the code that I have now, it gives me a Unicode error. Does anyone know why it's giving me this?
code:

from tkinter import *

root = Tk()
root.title("Test")
root.geometry('500x500')

background = PhotoImage(file='C:\Users\l111190\Desktop\bg.jpg')

label1 = Label(root, image=background)
label1.place (x=0, y=0)

root.mainloop()

And this is the error that I get when running this:

Traceback (most recent call last):
  File "D:\Informatica eindopdracht\Thonny\tkinter test scripts\tkinter test v0.2.py", line 7
    background = PhotoImage(file='C:\Users\l111190\Desktop\bg.jpg')
                                ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
0

There are 0 best solutions below