May-08-2021, 04:50 PM
Hi There,
I'm Rubberduck and an absolut beginner with python but I hope with your great help I become a solid python programmer and learn this fascinating language as quickly as I can.
My slideShow app should display some pictures but it seems that the code wouldn't work perfectly so far.
It would be great if anyone could help. You also find my code here: github
Thanks for helping me.
I'm Rubberduck and an absolut beginner with python but I hope with your great help I become a solid python programmer and learn this fascinating language as quickly as I can.
My slideShow app should display some pictures but it seems that the code wouldn't work perfectly so far.
from itertools import cycle import tkinter as tk class App(tk.Tk): #Tk window/Label adjust to size of image def __init__(self, image_files, x, y, delay): tk.Tk.__init__(self) self.geometry('+{}+{}'.format(x, y)) self.delay = delay self.pictures = cycle((tk.PhotoImage(file=image), image) for image in image_files) self.pictures_display = tk.Label(self) self.picture_display.pack() def show_slides(self): #cycle through the images and dispay them img_object, img_name = next(self.pictures) self.picture_display.config(image=image_object) self.title(img_name) self.after(self.delay, self.show_slides) def run(self): self.mainloop() # set milliseconds time between slides delay = 3500 # get a series of gif images have in the working folder # or use full path, or set directory to where the images are image_files = [ '1.gif', '2.gif', '3.gif', '4.gif', '5.gif', '6.gif', '7.gif' ] x = 100 y = 50 app = App(image_files, x, y, delay) app.show_slides() app.run()My Terminal shows the following
Error:File "/Users/damiankrebs1/Desktop/slideShow/main.py", line 43, in <module>
app = App(image_files, x, y, delay)
NameError: name 'image_files' is not defined
I already defined 'image_files' in line 31 so I cannot understand this error message.It would be great if anyone could help. You also find my code here: github
Thanks for helping me.