I'm trying to make software with python using Tkinter, but I can't see the image when I type the code.
Put the py file and the image file in the same folder and select the image file name.
Not only PhotoImage and Button, but also icons are not reflected, so the image file itself is probably impossible.
·Restart PC
·Uninstall and reinstall python
·Type python-V
in cmd to confirm that the version appears
·Try with a different image
·Move the file to another location
* I'm a beginner, so I don't know how to solve it at all.If you are kind, please reply.
python tkinter
The image was displayed successfully in my environment.
The active directory in the running environment may be different from the file path in the image.
Verify that the file is placed in the path shown by executing the code below.
importos
print(os.path.abspath('icon.ico'))# Full path to get icon
If the file is not located in the path shown, consider the following actions:
C:\Users\Owner\OneDrive\Document\MyPython\Tkinter Course\icon.ico
FileC:\Users\Owner\OneDrive\Document\MyPython\icon.ico
.os.chdir
importos
and os.chdir(r"C:\Users\Owner\OneDrive\Document\MyPython\Tkinter Course")
around the third line of the code.PSC:\(omitted)\MyPython>
in Terminal with cd C:\Users\Owner\OneDrive\Document\MyPython\Tkinter Course
.
© 2024 OneMinuteCode. All rights reserved.