In my Tkinter program I would like to display the last 3 pictures of a folder. However, these are not displayed when running. Here is the code:
pics = glob.glob('path/to/folder/*.png')
pics = (sorted(pics, key=os.path.getmtime))
pics = pics[::-1]
bildertimer = 3
bild = 0
x_koo = 0
y_koo = 0
bilderraum = Canvas(width=1750, height=930)
bilderraum.place(x=130, y=20)
while bildertimer > 0:
if x_koo > 1430:
x_koo = 0
y_koo = y_koo + 200
img = PhotoImage(file=pics[bild])
img.image = pics[bild]
img_small = img.subsample(6)
bilderraum.create_image(x_koo, y_koo, anchor='nw', image=img_small)
bildertimer = bildertimer - 1
bild = bild + 1
x_koo = x_koo + 340
If I change the 3 in the bildertimer to 4, the last one is shown to me, but only where the 2nd picture should be. In addition, I then have the list index out of range error, which means the program does not continue. What am I doing wrong?