Skip to content

Commit d3077ae

Browse files
committed
First Commit
1 parent 18edb8e commit d3077ae

File tree

29 files changed

+682
-0
lines changed

29 files changed

+682
-0
lines changed

ImageGallery/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ImageGallery
2+
Displays images, built using tkinter.
3+
4+
# Screenshot
5+
<img src='screenshots/01.png'>
6+
<img src='screenshots/02.png'>

ImageGallery/grid.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import tkinter as tk
2+
from PIL import Image, ImageTk
3+
4+
# create instance
5+
window = tk.Tk()
6+
# set default window size
7+
window.geometry("850x550")
8+
# set min window size
9+
window.minsize(700, 400)
10+
# set max window size
11+
window.maxsize(1000, 700)
12+
# add a title
13+
window.title("ImageGallery")
14+
15+
# Add header
16+
tk.Label(window,
17+
compound=tk.TOP,
18+
text='---- Image Gallery ----',
19+
pady=20, # padding Vertical
20+
font=("Courier", 15, "bold") # change the font OR "Courier 18 bold"
21+
).pack()
22+
23+
# Add a frame
24+
frame = tk.Frame(window)
25+
frame.pack(anchor=tk.CENTER)
26+
27+
# define image_list
28+
image_list = ['anime.png', 'panda_face.png', 'dog.png', 'shoepping.png',
29+
'color_palette.png', 'android.png']
30+
31+
# open image
32+
image1 = Image.open('./images/' + image_list[0])
33+
photo1 = ImageTk.PhotoImage(image1)
34+
35+
image2 = Image.open('./images/' + image_list[1])
36+
photo2 = ImageTk.PhotoImage(image2)
37+
38+
image3 = Image.open('./images/' + image_list[2])
39+
photo3 = ImageTk.PhotoImage(image3)
40+
41+
image4 = Image.open('./images/' + image_list[3])
42+
photo4 = ImageTk.PhotoImage(image4)
43+
44+
image5 = Image.open('./images/' + image_list[4])
45+
photo5 = ImageTk.PhotoImage(image5)
46+
47+
image6 = Image.open('./images/' + image_list[5])
48+
photo6 = ImageTk.PhotoImage(image6)
49+
50+
# Add image-label inside frame
51+
tk.Label(
52+
master=frame, # attach label to the frame
53+
compound=tk.TOP,
54+
text=image_list[0],
55+
image=photo1,
56+
width=300, height=300
57+
).grid(row=1, column=1)
58+
59+
tk.Label(
60+
master=frame, # attach label to the frame
61+
compound=tk.TOP,
62+
text=image_list[1],
63+
image=photo2,
64+
width=300, height=300
65+
).grid(row=1, column=2)
66+
67+
tk.Label(
68+
master=frame, # attach label to the frame
69+
compound=tk.TOP,
70+
text=image_list[2],
71+
image=photo3,
72+
width=300, height=300
73+
).grid(row=1, column=3)
74+
75+
tk.Label(
76+
master=frame, # attach label to the frame
77+
compound=tk.TOP,
78+
text=image_list[3],
79+
image=photo4,
80+
width=300, height=300
81+
).grid(row=2, column=1)
82+
83+
tk.Label(
84+
master=frame, # attach label to the frame
85+
compound=tk.TOP,
86+
text=image_list[4],
87+
image=photo5,
88+
width=300, height=300
89+
).grid(row=2, column=2)
90+
91+
tk.Label(
92+
master=frame, # attach label to the frame
93+
compound=tk.TOP,
94+
text=image_list[5],
95+
image=photo6,
96+
width=300, height=300
97+
).grid(row=2, column=3)
98+
99+
100+
window.mainloop()

ImageGallery/images/android.png

5.05 KB
Loading

ImageGallery/images/anime.png

15 KB
Loading

ImageGallery/images/color_palette.png

3.5 KB
Loading

ImageGallery/images/dog.png

9.3 KB
Loading

ImageGallery/images/logo.png

5.68 KB
Loading

ImageGallery/images/panda_face.png

14.5 KB
Loading

ImageGallery/images/shoe.png

6.47 KB
Loading

ImageGallery/images/shoepping.png

4.86 KB
Loading

0 commit comments

Comments
 (0)