Skip to content

Commit 7d8e87c

Browse files
author
hoarec
committed
Added new Digital Frame Project
0 parents  commit 7d8e87c

11 files changed

+442
-0
lines changed

.idea/PythonDigital.iml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

2012-02-26-032.jpg

1 MB
Loading

2012-02-26-033.jpg

1.03 MB
Loading

RotateImage.py

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Simple enough, just import everything from tkinter.
2+
from tkinter import *
3+
import time
4+
5+
# download and install pillow:
6+
# http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow
7+
from PIL import Image, ImageTk
8+
9+
import glob
10+
from array import array
11+
from random import randint
12+
import threading
13+
14+
15+
16+
# Here, we are creating our class, Window, and inheriting from the Frame
17+
# class. Frame is a class from the tkinter module. (see Lib/tkinter/__init__)
18+
class Window(Frame):
19+
# Define settings upon initialization. Here you can specify
20+
def __init__(self, master=None):
21+
# parameters that you want to send through the Frame class.
22+
Frame.__init__(self, master)
23+
24+
25+
# reference to the master widget, which is the tk window
26+
self.master = master
27+
28+
# with that, we want to then run init_window, which doesn't yet exist
29+
self.init_window()
30+
31+
# Creation of init_window
32+
def init_window(self):
33+
# changing the title of our master widget
34+
self.master.title("GUI")
35+
36+
# allowing the widget to take the full space of the root window
37+
self.pack(fill=BOTH, expand=1)
38+
39+
# creating a menu instance
40+
menu = Menu(self.master)
41+
self.master.config(menu=menu)
42+
43+
# create the file object)
44+
file = Menu(menu)
45+
46+
# adds a command to the menu option, calling it exit, and the
47+
# command it runs on event is client_exit
48+
file.add_command(label="Exit", command=self.client_exit)
49+
50+
# added "file" to our menu
51+
menu.add_cascade(label="File", menu=file)
52+
53+
# create the file object)
54+
edit = Menu(menu)
55+
56+
# adds a command to the menu option, calling it exit, and the
57+
# command it runs on event is client_exit
58+
edit.add_command(label="Show Img", command=self.showImg)
59+
edit.add_command(label="Show Text", command=self.showText)
60+
61+
# added "file" to our menu
62+
menu.add_cascade(label="Edit", menu=edit)
63+
64+
65+
def startImage(self):
66+
67+
print("running")
68+
69+
def showImg(self):
70+
#threading.Timer(5, Window.showImg).join(1)
71+
#time.sleep(10)
72+
try:
73+
filename = self.getfiles()
74+
load = Image.open(filename)
75+
widths = self.winfo_width()
76+
heights = self.winfo_height()
77+
widths = widths - 10
78+
heights = heights - 10
79+
80+
try:
81+
load = load.resize((widths,heights), Image.NEAREST)
82+
except ValueError:
83+
print("Error")
84+
85+
render = ImageTk.PhotoImage(load)
86+
# labels can be text or images
87+
img = Label(self, image=render)
88+
89+
img.image = render
90+
img.place(x=0, y=0)
91+
except ValueError:
92+
print("Start Over")
93+
94+
def showText(self):
95+
text = Label(self, text="Hey there good lookin!")
96+
text.pack()
97+
98+
def client_exit(self):
99+
exit()
100+
101+
def getfiles(self):
102+
print("Getting file")
103+
try:
104+
allfiles = glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
105+
106+
numfiles = len(allfiles)
107+
108+
arraypos = (randint(0, numfiles))
109+
print(arraypos)
110+
return allfiles[arraypos]
111+
# print(glob.glob("/User/hoarec/Documents/Pictures/*.jpg"))
112+
# return #glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
113+
except ValueError:
114+
print("Error Get File")
115+
#thefile = root.getfiles();
116+
#return thefile
117+
118+
def _resize_image(self, event):
119+
120+
new_width = event.width
121+
new_height = event.height
122+
123+
self.image = self.img_copy.resize((new_width, new_height))
124+
125+
self.background_image = ImageTk.PhotoImage(self.image)
126+
self.background.configure(image=self.background_image)
127+
128+
129+
# root window created. Here, that would be the only window, but
130+
# you can later have windows within windows.
131+
root = Tk()
132+
root.attributes('-fullscreen',True)
133+
root.wm_overrideredirect(True)
134+
#root.wm_attributes('-type', 'splash')
135+
root.overrideredirect(0)
136+
137+
138+
#root.geometry("800x600")
139+
140+
# creation of an instance
141+
app = Window(root)
142+
143+
144+
145+
146+
147+
# mainloop
148+
149+
root.mainloop()

newTest.py

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from tkinter import *
2+
3+
from PIL import Image, ImageTk
4+
5+
import threading
6+
import glob
7+
from array import array
8+
from random import randint
9+
10+
11+
root = Tk()
12+
root.title("Title")
13+
root.geometry("600x600")
14+
root.configure(background="black")
15+
16+
17+
class Example(Frame):
18+
def __init__(self, master, *pargs):
19+
Frame.__init__(self, master, *pargs)
20+
21+
22+
def _resize_image(self,event):
23+
24+
new_width = event.width
25+
new_height = event.height
26+
27+
self.image = self.img_copy.resize((new_width, new_height))
28+
29+
self.background_image = ImageTk.PhotoImage(self.image)
30+
self.background.configure(image = self.background_image)
31+
32+
def getfiles(self):
33+
try:
34+
allfiles = glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
35+
36+
numfiles = len(allfiles)
37+
38+
arraypos = (randint(0, numfiles))
39+
print(arraypos)
40+
return allfiles[arraypos]
41+
# print(glob.glob("/User/hoarec/Documents/Pictures/*.jpg"))
42+
# return #glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
43+
except ValueError:
44+
thefile = self.getfiles();
45+
return thefile
46+
47+
def setimage(self):
48+
filename = self.getfiles()
49+
50+
self.image = Image.open(filename)
51+
self.img_copy = self.image.copy()
52+
53+
self.background_image = ImageTk.PhotoImage(self.image)
54+
55+
self.background = Label(self, image=self.background_image)
56+
self.background.pack(fill=BOTH, expand=YES)
57+
self.background.bind('<Configure>', self._resize_image)
58+
e.pack(fill=BOTH, expand=YES)
59+
60+
61+
e = Example(root)
62+
def process():
63+
t = threading.Timer(5.0, e.setimage)
64+
t.start()
65+
process()
66+
e.mainloop()

pictureframe.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from tkinter import *
2+
from PIL import Image, ImageTk
3+
import glob
4+
from array import array
5+
from random import randint
6+
import threading
7+
8+
9+
10+
class App(Frame):
11+
def __init__(self, master):
12+
Frame.__init__(self, master)
13+
t = threading.Timer(5.0, self.rollimage())
14+
t.start()
15+
16+
17+
18+
def resize(self, event):
19+
size = (event.width, event.height)
20+
resized = self.original.resize(size,Image.ANTIALIAS)
21+
self.image = ImageTk.PhotoImage(resized)
22+
self.display.delete("IMG")
23+
self.display.create_image(0, 0, image=self.image, anchor=NW, tags="IMG")
24+
25+
def getfiles(self):
26+
try:
27+
allfiles = glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
28+
29+
numfiles = len(allfiles)
30+
31+
arraypos = (randint(0, numfiles))
32+
print(arraypos)
33+
return allfiles[arraypos]
34+
#print(glob.glob("/User/hoarec/Documents/Pictures/*.jpg"))
35+
#return #glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
36+
except ValueError:
37+
thefile = self.getfiles();
38+
return thefile
39+
40+
def rollimage(self):
41+
while (True):
42+
try:
43+
filename = self.getfiles()
44+
print(filename)
45+
self.columnconfigure(0, weight=1)
46+
self.rowconfigure(0, weight=1)
47+
self.original = Image.open(filename)
48+
self.image = ImageTk.PhotoImage(self.original)
49+
self.display = Canvas(self, bd=0, highlightthickness=0)
50+
self.display.create_image(0, 0, image=self.image, anchor=NW, tags="IMG")
51+
self.display.grid(row=0, sticky=W + E + N + S)
52+
self.pack(fill=BOTH, expand=1)
53+
self.bind("<Configure>", self.resize)
54+
except ValueError:
55+
print("Error")
56+
57+
58+
root = Tk()
59+
root.attributes('-fullscreen', True)
60+
app = App(root)
61+
62+
#app.mainloop()
63+
#root.destroy()
64+

scrollingImages.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os, tkinter, random, glob
2+
from PIL import Image, ImageTk, ImageFile
3+
4+
5+
def changeImage():
6+
7+
ImageFile.LOAD_TRUNCATED_IMAGES = True
8+
9+
global tkpi #need global so that the image does not get derefrenced out of function
10+
try:
11+
#gets list of file names in certain directory. In this case, the directory it is in
12+
dirlist = glob.glob("/Users/hoarec/Documents/Pictures/*.jpg")
13+
14+
#get random image\
15+
widths = root.winfo_width()
16+
heights = root.winfo_height()
17+
widths = widths - 10
18+
heights = heights - 10
19+
20+
randInt = random.randint(0, (len(dirlist) - 1))
21+
image = Image.open(dirlist[randInt])
22+
image = image.resize((widths,heights), Image.NEAREST)
23+
24+
#set size to show, in this case the whole picture
25+
#root.geometry('%dx%d' % (image.size[0],image.size[1]))
26+
27+
#Creates a Tkinter compatible photo image
28+
tkpi = ImageTk.PhotoImage(image)
29+
30+
#Put image in a label and place it
31+
label_image = tkinter.Label(root, image=tkpi)
32+
label_image.place(x=0,y=0,width=image.size[0],height=image.size[1])
33+
34+
# call this function again in 1/2 a second
35+
root.after(10000, changeImage)
36+
except ValueError:
37+
print("Error")
38+
39+
40+
tkpi = None #create this global variable so that the image is not derefrenced
41+
42+
root = tkinter.Tk()
43+
#root.geometry('+%d+%d' % (-5,-5)) #controls where the window is
44+
#root.attributes('-alpha', 0.0) #For icon
45+
root.iconify()
46+
root = tkinter.Toplevel(root)
47+
root.attributes('-fullscreen',True)
48+
changeImage()
49+
root.mainloop()

0 commit comments

Comments
 (0)