-
Notifications
You must be signed in to change notification settings - Fork 0
/
File Explorer Test2.py
69 lines (48 loc) · 1.94 KB
/
File Explorer Test2.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
#Importing libraries. pillows for image stuff, tkinter for windows explorer
import tkinter as tk
from tkinter import filedialog
from PIL import Image, ImageTk
#function for opening windows explorer and then the original image
def Original():
file_path = filedialog.askopenfilename(filetypes=[("Image files", "*.jpg *.jpeg *.png")])
if file_path:
img = Image.open(file_path)
img = img.resize((100, 100))
img_tk = ImageTk.PhotoImage(img)
label.config(image=img_tk)
label.image = img_tk
#function for opening windows explorer and then the mask image
def Mask():
mask_path = filedialog.askopenfilename(filetypes=[("Image files", "*.jpg *.jpeg *.png")])
if mask_path:
img2 = Image.open(mask_path)
img2 = img2.resize((100, 100))
img2_tk = ImageTk.PhotoImage(img2)
label2.config(image=img2_tk)
label2.image = img2_tk
#create root window
window = tk.Tk()
# Set window title
window.title('File Explorer')
# Set window size
window.geometry("500x500")
#Set window background color
window.config(background = "white")
# Create a File Explorer label
label = tk.Label(window,text = "Selecting Images")
#Top text
label2 = tk.Label(window,text = " ")
#Original image selecting button
button_og = tk.Button(window,text = "Select original image",command = Original)
#Mask image selecting button
button_mask = tk.Button(window,text = "Select masked image",command = Mask)
#Exit button
button_exit = tk.Button(window,text = "Exit",command = exit)
# Grid method is chosen for placing the widgets at respective positions in a table like structure by specifying rows and columns
label.grid(column = 49, row = 1)
label2.grid(column=51,row=1)
button_og.grid(column = 50, row = 4)
button_mask.grid(column=50,row=5)
button_exit.grid(column = 50,row = 6)
# Let the window wait for any events
window.mainloop()