How do you open an image or file that is in another folder? [closed]

1

I am learning Python in my first year of university and I want to work on a visual novel, but without using any graphic engine.

I am using Tkinter in the Python version 3.6 and to be able to maintain a certain order in all the files that I will use, I want to know if it is possible to save the images and the different .py files that I will use in the development, in a folder and open them from there.

This is my code:

from tkinter import *

ventana = Tk()

imagen = PhotoImage(file = 'NicoMostacho.ppm')

canvas = Canvas(ventana)
canvas.pack()

canvas.create_image(150, 130, image = imagen)


ventana.mainloop()

For example, in this code the image is shown without problems, but I would like to save it in a subfolder, but it generates the following error:

  

tkinter.TclError: could not open "NicMostacho.ppm": no such file or directory

    
asked by Fritaku 14.01.2018 в 20:04
source

0 answers