-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.py
78 lines (67 loc) · 2.33 KB
/
testing.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
71
72
73
74
75
76
77
78
from tkinter import *
from PIL import Image, ImageTk
import glob
from array import array
from random import randint
import threading
def __init__(self, master):
Frame.__init__(self, master)
print("Starting")
root.rollimage()
def resize(event):
size = (event.width, event.height)
resized = root.original.resize(size,Image.ANTIALIAS)
root.image = ImageTk.PhotoImage(resized)
root.display.delete("IMG")
root.display.create_image(0, 0, image=root.image, anchor=NW, tags="IMG")
def getfiles():
print("Getting file")
try:
allfiles = glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
numfiles = len(allfiles)
arraypos = (randint(0, numfiles))
print(arraypos)
return allfiles[arraypos]
#print(glob.glob("/User/hoarec/Documents/Pictures/*.jpg"))
#return #glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
except ValueError:
print("Error Get File")
thefile = root.getfiles();
return thefile
def rollimage():
t = threading.Timer(5.0, root.rollimage())
t.start()
try:
filename = root.getfiles()
print(filename)
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
root.original = Image.open(filename)
root.image = ImageTk.PhotoImage(root.original)
root.display = Canvas(root, bd=0, highlightthickness=0)
root.display.create_image(0, 0, image=root.image, anchor=NW, tags="IMG")
root.display.grid(row=0, sticky=W + E + N + S)
root.pack(fill=BOTH, expand=1)
root.bind("<Configure>", root.resize)
except ValueError:
print("Error")
def setNexr():
print("Next Image")
try:
filename = root.getfiles()
print(filename)
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
root.original = Image.open(filename)
root.image = ImageTk.PhotoImage(root.original)
root.display = Canvas(root, bd=0, highlightthickness=0)
root.display.create_image(0, 0, image=root.image, anchor=NW, tags="IMG")
root.display.grid(row=0, sticky=W + E + N + S)
root.pack(fill=BOTH, expand=1)
root.bind("<Configure>", root.resize)
except ValueError:
print("Error")
root = Tk()
root.attributes('-fullscreen', True)
app = rollimage();
app.mainloop()