forked from avinashkranjan/Amazing-Python-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.py
More file actions
65 lines (49 loc) · 1.45 KB
/
script.py
File metadata and controls
65 lines (49 loc) · 1.45 KB
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
from tkinter import *
from PIL import Image, ImageTk
import os
root = Tk()
root.geometry("600x600")
def resize_image(root, copy_image, label1):
new_height = 600
new_width = 600
image=copy_image.resize((new_width,new_height))
photo=ImageTk.PhotoImage(image)
label1.configure(image=photo)
label1.image=photo
def next():
global n
global itemslist
n=(n+1)%len(itemslist)
img1 = itemslist[n]
image = Image.open(path+"/"+img1)
copy_image=image.copy()
photo=ImageTk.PhotoImage(image)
label=Label(root,image=photo)
label.bind('<configure>',resize_image(root, copy_image, label1))
label.pack()
def previous():
global n
global itemslist
n=(n-1)%len(itemslist)
img1 = itemslist[n]
image = Image.open(path+"/"+img1)
copy_image=image.copy()
photo=ImageTk.PhotoImage(image)
label2=Label(root,image=photo)
label2.bind('<configure>',resize_image(root, copy_image, label1))
label2.pack()
n=0
path = input(r"Enter path for the image folder: ")
itemslist = os.listdir(path)
img1 = itemslist[n]
image = Image.open(path+"/"+img1)
copy_image=image.copy()
photo=ImageTk.PhotoImage(image)
label1=Label(root,image=photo)
label1.bind('<configure>',resize_image(root, copy_image, label1))
label1.pack()
btn1 = Button(root,text="next",width=5,height=10,command=next)
btn1.place(x=570,y=150)
btn1 = Button(root,text="prev",width=5,height=10,command=previous)
btn1.place(x=0,y=150)
root.mainloop()