-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSlideShow.py
70 lines (51 loc) · 2.46 KB
/
SlideShow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import Tkinter as tk
from itertools import cycle
from Tkinter import *
from PIL import Image, ImageTk # pip install pillow + sudo apt-get install python-imaging-tk
# based on example found on
# https://raspberrypi.stackexchange.com/questions/18261/how-do-i-display-an-image-file-png-in-a-simple-window
class SlideShow(tk.Frame):
canvas = None
current_image = 0
stopShowing = False
SLIDE_DURATION = 7500
NUMBER_OF_SLIDES = 1
def __init__(self, parent, w, h):
tk.Frame.__init__(self, parent)
# Set up the GUI window via Tk
self.canvas = Canvas(self, background="black", width=w, height=h)
self.canvas.pack(side="bottom", fill="x", padx=4)
# pick an image file you have .bmp .jpg .gif. .png
# load the file and covert it to a Tkinter image object
self.image1 = ImageTk.PhotoImage(Image.open('pictures/speelpong.jpg'))
if self.NUMBER_OF_SLIDES >= 2:
self.image2 = ImageTk.PhotoImage(Image.open('pictures/ouderraad2.jpg'))
if self.NUMBER_OF_SLIDES >= 3:
self.image3 = ImageTk.PhotoImage(Image.open('pictures/ouderraad3.jpg'))
# make the root window the size of the image
#self.canvas.geometry("%dx%d+%d+%d" % (w, h, 0, 0))
# root has no image argument, so use a label as a panel
self.panel1 = tk.Label(self.canvas, image=self.image1)
self.display = self.image1
self.panel1.pack(side=tk.TOP, fill=tk.BOTH, expand=tk.YES)
print "Display image1"
if self.NUMBER_OF_SLIDES > 1:
self.after(self.SLIDE_DURATION, self.update_image)
#self.root.mainloop()
def stop(self):
self.stopShowing = True
def update_image(self):
if self.display == self.image1 and self.NUMBER_OF_SLIDES >= 2:
self.panel1.configure(image=self.image2)
print "Display image2"
self.display = self.image2
elif self.display == self.image2 and self.NUMBER_OF_SLIDES >= 3:
self.panel1.configure(image=self.image3)
print "Display image3"
self.display = self.image3
else:
self.panel1.configure(image=self.image1)
print "Display image1"
self.display = self.image1
if self.stopShowing == False:
self.after(self.SLIDE_DURATION, self.update_image) # Set to call again in 30 seconds