May 2017
@author: Burkhard A. Meier

from tkinter import Tk, PhotoImage, Label
from itertools import cycle
from os import listdir, path, chdir
class SlideShow(Tk):
    # inherit GUI framework extending tkinter
    def __init__(self, msShowTimeBetweenSlides=1500):
        # initialize tkinter super class
        # time each slide will be shown
        self.showTime = msShowTimeBetweenSlides
        # look for images in current working directory where this module lives
        chapter_folder = path.realpath(path.dirname(__file__))
        resources_folder = path.join(chapter_folder, 'Resources')
        listOfSlides = [slide for slide in listdir(resources_folder) if slide.endswith('gif')]

        # endlessly read in the slides so we can show them on the tkinter Label 
        self.iterableCycle = cycle((PhotoImage(file=slide), slide) for slide in listOfSlides)
        # create tkinter Label widget which can also display images
        self.slidesLabel = Label(self)
        # create the Frame widget
    def slidesCallback(self):
        # get next slide from iterable cycle
        currentInstance, nameOfSlide = next(self.iterableCycle)
        # assign next slide to Label widget
        # update Window title with current slide
        # recursively repeat the Show
        self.after(self.showTime, self.slidesCallback)

# Start GUI
win = SlideShow()
win.after(0, win.slidesCallback())