-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewTest.py
66 lines (46 loc) · 1.65 KB
/
newTest.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
from tkinter import *
from PIL import Image, ImageTk
import threading
import glob
from array import array
from random import randint
root = Tk()
root.title("Title")
root.geometry("600x600")
root.configure(background="black")
class Example(Frame):
def __init__(self, master, *pargs):
Frame.__init__(self, master, *pargs)
def _resize_image(self,event):
new_width = event.width
new_height = event.height
self.image = self.img_copy.resize((new_width, new_height))
self.background_image = ImageTk.PhotoImage(self.image)
self.background.configure(image = self.background_image)
def getfiles(self):
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:
thefile = self.getfiles();
return thefile
def setimage(self):
filename = self.getfiles()
self.image = Image.open(filename)
self.img_copy = self.image.copy()
self.background_image = ImageTk.PhotoImage(self.image)
self.background = Label(self, image=self.background_image)
self.background.pack(fill=BOTH, expand=YES)
self.background.bind('<Configure>', self._resize_image)
e.pack(fill=BOTH, expand=YES)
e = Example(root)
def process():
t = threading.Timer(5.0, e.setimage)
t.start()
process()
e.mainloop()