Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import numpy as np
- import cv2
- from PIL import ImageTk
- import PIL.Image
- import msvcrt as m
- from tkinter import *
- path = 'img/'
- images = os.listdir(path)
- imgNum = len(images)
- idx = 0
- def leftKey(event):
- changeImg()
- os.rename(path + images[idx-1], path + 'left/' + images[idx-1])
- def rightKey(event):
- changeImg()
- os.rename(path + images[idx-1], path + 'right/' + images[idx-1])
- def changeImg():
- global idx
- idx += 1
- if(idx == imgNum):
- root.destroy()
- else:
- img2 = ImageTk.PhotoImage(PIL.Image.open(path + images[idx]))
- panel.configure(image=img2)
- panel.image = img2
- if not os.path.exists(path + 'left'):
- os.makedirs(path + 'left')
- if not os.path.exists(path + 'right'):
- os.makedirs(path + 'right')
- root = Tk()
- img = ImageTk.PhotoImage(PIL.Image.open(path + images[idx]))
- panel = Label(root, image = img)
- panel.pack(side = "bottom", fill = "both", expand = "yes")
- root.bind('<Left>', leftKey)
- root.bind('<Right>', rightKey)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement