I'm back here with a new error that I can't solve... it's a strange error, idk, I put the images in the same directory of the program, in the directory specified in the code... Ah, I don't know, but this is all the code:
from tkinter import *
def toggle_fs():
"""
Function that enables fullscreen for the window I create
"""
state = False if root.attributes('-fullscreen') else True
root.attributes('-fullscreen', state)
if not state:
root.geometry('300x300+100+100')
print("Inserisci il nome della foto: ") # Enter the name of the image -> "ImmagineProva"
nomeImg = input()
def getImg(nomeImg):
"""
Function that obtaines the right image, because I have different images that are all the same picture but all are different in resolution (1360x768, 1920x1080...)
"""
# detect the resolution of the monitor
WIDTH, HEIGHT = root.winfo_screenwidth(), root.winfo_screenheight()
# Takes the right image thanks to its name and screen resolution took before
img = PhotoImage(file = "ImmaginiDiProva/" + nomeImg + str(WIDTH) + "x" + str(HEIGHT) + ".png")
# All the images have the same name "ImmagineProva" with the relative resolution
return img
root = Tk(screenName = "Prova")
root.attributes("-fullscreen", True)
canvas = Canvas(root, bg = "white")
canvas.pack(fill = BOTH, expand = True)
img = getImg(nomeImg)
canvas.create_image(0, 0, anchor = NW, image = img)
root.bind("<Escape>", toggle_fs())
mainloop()
I hope this is enough for you... I'm frustrated, I put the images everywhere and it doesn't recognize them, wtf O.o
I read the comments, so I post an image so you'll be able to see everything about the program, images...
An image of the folder of the program
Ah, I did what said the utent in the comment (I don't remember the nick and the page doesn't make me scroll up lol) ->
import os; print(etc...)
and raised the errorFileNotFoundError: [WinError 3] Impossibile trovare il percorso specificato: 'ImmaginiDiProva'
Why this? there is also the folder in the image I posted... I don't understand ahahah
Thank you guys for your help, by the way <3