tazbirul.mbec
tazbirul.mbec

Reputation: 23

Error with python Image

I am new in python. so, I tried to show image in my tkinter project. But I continuously received this error. I searched for a lot of codes in Google but everything was out of my league.

###################################################
from tkinter import *

##################################################
StartScreen = Tk()
##Photo Car##
PhotoCarRed = PhotoImage(file="D:\Projects\Python\Practice\1.png")
PlacementPhotoCarRed = Label(StartScreen, image=PhotoCarRed)
PlacementPhotoCarRed.pack(side="top", fill=X)

Here is the error:

enter image description here

Upvotes: 1

Views: 70

Answers (1)

Bruno Lubascher
Bruno Lubascher

Reputation: 2131

change

"D:\Projects\Python\Practice\1.png"

into

"D:\\Projects\\Python\\Practice\\1.png"

a single backslash \ acts as a escape character. So you can see in your error that the program reads your paths as "D:\Projects\Python\Practice .png", which is wrong.

Upvotes: 1

Related Questions