Skip to content

Commit be5eb69

Browse files
author
Landon Perkins (FROM PROSSER)
authored
Add files via upload
1 parent bda7f23 commit be5eb69

1 file changed

Lines changed: 228 additions & 9 deletions

File tree

main.py

Lines changed: 228 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from tkinter import *
2-
from PIL import ImageTk, Image
2+
from PIL import ImageTk, Image, ImageFilter
33
import pygame
4+
import random
5+
import os
46

57
root = Tk()
68
root.title('Image Slideshow Program')
@@ -10,13 +12,34 @@
1012
root.minsize(512, 635)
1113
root.maxsize(512, 635)
1214
root.resizable(False, False)
13-
im1 = ImageTk.PhotoImage(Image.open('images/aliendude.png'))
14-
im2 = ImageTk.PhotoImage(Image.open('images/bluesmurfcat.png'))
15-
im3 = ImageTk.PhotoImage(Image.open('images/imspongebob.png'))
16-
im4 = ImageTk.PhotoImage(Image.open('images/jonesy.png'))
17-
im5 = ImageTk.PhotoImage(Image.open('images/pythonlogo.png'))
18-
image_list = [im1, im2, im3, im4, im5]
19-
counter = 0
15+
16+
17+
def defineimages():
18+
global im1pil
19+
global im2pil
20+
global im3pil
21+
global im4pil
22+
global im5pil
23+
global im1tk
24+
global im2tk
25+
global im3tk
26+
global im4tk
27+
global im5tk
28+
global image_list
29+
global image_names
30+
global counter
31+
im1pil = Image.open("images/aliendude.png")
32+
im2pil = Image.open("images/bluesmurfcat.png")
33+
im3pil = Image.open("images/imspongebob.png")
34+
im4pil = Image.open("images/jonesy.png")
35+
im5pil = Image.open("images/pythonlogo.png")
36+
im1tk = PhotoImage(file='images/aliendude.png')
37+
im2tk = PhotoImage(file='images/bluesmurfcat.png')
38+
im3tk = PhotoImage(file='images/imspongebob.png')
39+
im4tk = PhotoImage(file='images/jonesy.png')
40+
im5tk = PhotoImage(file='images/pythonlogo.png')
41+
image_list = [im1tk, im2tk, im3tk, im4tk, im5tk]
42+
counter = 0
2043

2144

2245
def nextimage():
@@ -26,12 +49,208 @@ def nextimage():
2649
else:
2750
counter = 0
2851
imageLabel.configure(image=image_list[counter])
52+
if counter == 0:
53+
global im1tk
54+
imageLabel.config(image=im1tk)
55+
if counter == 1:
56+
global im2tk
57+
imageLabel.config(image=im2tk)
58+
if counter == 2:
59+
global im3tk
60+
imageLabel.config(image=im3tk)
61+
if counter == 3:
62+
global im4tk
63+
imageLabel.config(image=im4tk)
64+
if counter == 4:
65+
global im5tk
66+
imageLabel.config(image=im5tk)
2967
infoLabel.config(text='Image ' + str(counter + 1) + ' of ' + str(len(image_list)))
3068

3169

32-
imageLabel = Label(root, image=im1)
70+
def save():
71+
randomname1 = random.randint(1, 10000)
72+
randomname2 = random.randint(1, 10000)
73+
randomname3 = randomname1 + randomname2
74+
if counter == 0:
75+
global im1pil
76+
global im1tk
77+
im1pil.save(str(randomname3) + ".png")
78+
im1tk = PhotoImage(file=str(randomname3) + ".png")
79+
imageLabel.config(image=im1tk)
80+
if counter == 1:
81+
global im2pil
82+
global im2tk
83+
im2pil.save(str(randomname3) + ".png")
84+
im2tk = PhotoImage(file=str(randomname3) + ".png")
85+
imageLabel.config(image=im2tk)
86+
if counter == 2:
87+
global im3pil
88+
global im3tk
89+
im3pil.save(str(randomname3) + ".png")
90+
im3tk = PhotoImage(file=str(randomname3) + ".png")
91+
imageLabel.config(image=im3tk)
92+
if counter == 3:
93+
global im4pil
94+
global im4tk
95+
im4pil.save(str(randomname3) + ".png")
96+
im4tk = PhotoImage(file=str(randomname3) + ".png")
97+
imageLabel.config(image=im4tk)
98+
if counter == 4:
99+
global im5pil
100+
global im5tk
101+
im5pil.save(str(randomname3) + ".png")
102+
im5tk = PhotoImage(file=str(randomname3) + ".png")
103+
imageLabel.config(image=im5tk)
104+
105+
106+
def blur():
107+
randomname1 = random.randint(1, 10000)
108+
randomname2 = random.randint(1, 10000)
109+
randomname3 = randomname1 + randomname2
110+
if counter == 0:
111+
global im1pil
112+
global im1tk
113+
im1pil.save(str(randomname3) + ".png")
114+
im1pil = Image.open(str(randomname3) + ".png")
115+
im1pil = im1pil.convert('RGB')
116+
im1pil = im1pil.filter(ImageFilter.BLUR)
117+
im1pil.save(str(randomname3) + ".png")
118+
im1tk = PhotoImage(file=str(randomname3) + ".png")
119+
imageLabel.config(image=im1tk)
120+
os.remove(str(randomname3) + ".png")
121+
if counter == 1:
122+
global im2pil
123+
global im2tk
124+
im2pil.save(str(randomname3) + ".png")
125+
im2pil = Image.open(str(randomname3) + ".png")
126+
im2pil = im2pil.convert('RGB')
127+
im2pil = im2pil.filter(ImageFilter.BLUR)
128+
im2pil.save(str(randomname3) + ".png")
129+
im2tk = PhotoImage(file=str(randomname3) + ".png")
130+
imageLabel.config(image=im2tk)
131+
os.remove(str(randomname3) + ".png")
132+
if counter == 2:
133+
global im3pil
134+
global im3tk
135+
im3pil.save(str(randomname3) + ".png")
136+
im3pil = Image.open(str(randomname3) + ".png")
137+
im3pil = im3pil.convert('RGB')
138+
im3pil = im3pil.filter(ImageFilter.BLUR)
139+
im3pil.save(str(randomname3) + ".png")
140+
im3tk = PhotoImage(file=str(randomname3) + ".png")
141+
imageLabel.config(image=im3tk)
142+
os.remove(str(randomname3) + ".png")
143+
if counter == 3:
144+
global im4pil
145+
global im4tk
146+
im4pil.save(str(randomname3) + ".png")
147+
im4pil = Image.open(str(randomname3) + ".png")
148+
im4pil = im4pil.convert('RGB')
149+
im4pil = im4pil.filter(ImageFilter.BLUR)
150+
im4pil.save(str(randomname3) + ".png")
151+
im4tk = PhotoImage(file=str(randomname3) + ".png")
152+
imageLabel.config(image=im4tk)
153+
os.remove(str(randomname3) + ".png")
154+
if counter == 4:
155+
global im5pil
156+
global im5tk
157+
im5pil.save(str(randomname3) + ".png")
158+
im5pil = Image.open(str(randomname3) + ".png")
159+
im5pil = im5pil.convert('RGB')
160+
im5pil = im5pil.filter(ImageFilter.BLUR)
161+
im5pil.save(str(randomname3) + ".png")
162+
im5tk = PhotoImage(file=str(randomname3) + ".png")
163+
imageLabel.config(image=im5tk)
164+
os.remove(str(randomname3) + ".png")
165+
166+
167+
def sharpen():
168+
randomname1 = random.randint(1, 10000)
169+
randomname2 = random.randint(1, 10000)
170+
randomname3 = randomname1 + randomname2
171+
if counter == 0:
172+
global im1pil
173+
global im1tk
174+
im1pil.save(str(randomname3) + ".png")
175+
im1pil = Image.open(str(randomname3) + ".png")
176+
im1pil = im1pil.convert('RGB')
177+
im1pil = im1pil.filter(ImageFilter.SHARPEN)
178+
im1pil.save(str(randomname3) + ".png")
179+
im1tk = PhotoImage(file=str(randomname3) + ".png")
180+
imageLabel.config(image=im1tk)
181+
os.remove(str(randomname3) + ".png")
182+
if counter == 1:
183+
global im2pil
184+
global im2tk
185+
im2pil.save(str(randomname3) + ".png")
186+
im2pil = Image.open(str(randomname3) + ".png")
187+
im2pil = im2pil.convert('RGB')
188+
im2pil = im2pil.filter(ImageFilter.SHARPEN)
189+
im2pil.save(str(randomname3) + ".png")
190+
im2tk = PhotoImage(file=str(randomname3) + ".png")
191+
imageLabel.config(image=im2tk)
192+
os.remove(str(randomname3) + ".png")
193+
if counter == 2:
194+
global im3pil
195+
global im3tk
196+
im3pil.save(str(randomname3) + ".png")
197+
im3pil = Image.open(str(randomname3) + ".png")
198+
im3pil = im3pil.convert('RGB')
199+
im3pil = im3pil.filter(ImageFilter.SHARPEN)
200+
im3pil.save(str(randomname3) + ".png")
201+
im3tk = PhotoImage(file=str(randomname3) + ".png")
202+
imageLabel.config(image=im3tk)
203+
os.remove(str(randomname3) + ".png")
204+
if counter == 3:
205+
global im4pil
206+
global im4tk
207+
im4pil.save(str(randomname3) + ".png")
208+
im4pil = Image.open(str(randomname3) + ".png")
209+
im4pil = im4pil.convert('RGB')
210+
im4pil = im4pil.filter(ImageFilter.SHARPEN)
211+
im4pil.save(str(randomname3) + ".png")
212+
im4tk = PhotoImage(file=str(randomname3) + ".png")
213+
imageLabel.config(image=im4tk)
214+
os.remove(str(randomname3) + ".png")
215+
if counter == 4:
216+
global im5pil
217+
global im5tk
218+
im5pil.save(str(randomname3) + ".png")
219+
im5pil = Image.open(str(randomname3) + ".png")
220+
im5pil = im5pil.convert('RGB')
221+
im5pil = im5pil.filter(ImageFilter.SHARPEN)
222+
im5pil.save(str(randomname3) + ".png")
223+
im5tk = PhotoImage(file=str(randomname3) + ".png")
224+
imageLabel.config(image=im5tk)
225+
os.remove(str(randomname3) + ".png")
226+
227+
228+
def helpinfo():
229+
helpwindow = Toplevel(root)
230+
helpwindow.title("Help")
231+
helpwindow.geometry("250x250")
232+
helpwindow.mainloop()
233+
234+
235+
run_once = 0
236+
if run_once == 0:
237+
defineimages()
238+
run_once = 1
239+
imageLabel = Label(root, image=im1tk)
33240
infoLabel = Label(root, text='Image ' + str(counter + 1) + ' of ' + str(len(image_list)),
34241
font=('Minecraft Pixel Font 5x5 Regular', 20))
242+
menubar1 = Menu(root)
243+
filemenu1 = Menu(menubar1, tearoff=0)
244+
filemenu1.add_command(label="Save", command=save)
245+
menubar1.add_cascade(label="File", menu=filemenu1)
246+
filemenu2 = Menu(menubar1, tearoff=0)
247+
filemenu2.add_command(label="Blur", command=blur)
248+
filemenu2.add_command(label="Sharpen", command=sharpen)
249+
menubar1.add_cascade(label="Edit", menu=filemenu2)
250+
filemenu3 = Menu(menubar1, tearoff=0)
251+
filemenu3.add_command(label="Info", command=helpinfo)
252+
menubar1.add_cascade(label="Help", menu=filemenu3)
253+
root.config(menu=menubar1)
35254
button = Button(root, text="Next Image", font=('Minecraft Pixel Font 5x5 Regular', 20), command=nextimage)
36255
infoLabel.pack()
37256
imageLabel.pack()

0 commit comments

Comments
 (0)