I'm new to python and I'm trying this code:
import random
from random import choice
import tkinter
from tkinter import messagebox
from tkinter import *
from tkinter.filedialog import askopenfilename
import sys
from PIL import ImageTk, Image
from tkinter import filedialog
import os
num_npcs = 2
num_img_tot = 100
npc_window = {}
canvas = {}
background_label = {}
for i in range(0, num_npcs,1):
num_img = round(random.uniform(0.5, num_img_tot+0.5))
npc_window["npc_window{0}".format(i)] = Tk()
canvas["canvas{0}".format(i)] = Canvas(npc_window["npc_window{0}".format(i)], bg="blue", height=250, width=300)
filename["canvas{0}".format(i)] = PhotoImage(file=base_folder + 'biome\\'+str(char)+'\\'+str(int) + '\\'+str(num_img)+'.png')
background_label["background_label{0}".format(i)] = Label(npc_window["npc_window{0}".format(i)], image=filename["canvas{0}".format(i)])
background_label["background_label{0}".format(i)].place(x=0, y=0, relwidth=1, relheight=1)
canvas["canvas{0}".format(i)].pack()
but I probably messed up a little bit... I'm not used to GUI and stuff and I'm actually experimenting. By the way the error is:
_tkinter.TclError: image "pyimage2" doesn't exist
I'm trying to make a program that opens X (random) images, that's why I tried Tk(). Also I'm using Pycharm in a Windows 10 machine.