Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Function to load the next image into the Label
- def next_img():
- img_label.img = tk.PhotoImage(file=next(imgs))
- img_label.config(image=img_label.img)
- # Function to load the next image into the Label
- def previous_img():
- img_label.img = tk.PhotoImage(file=back(imgs))
- img_label.config(image=img_label.img)
- def sel():
- selection = "Value = " + str(var.get())
- label.config(text = selection)
- print(img_label.img, selection)
- root = tk.Tk()
- var = tk.DoubleVar()
- scale = tk.Scale(root, variable = var, orient='horizontal', from_=1, to=10)
- scale.pack(anchor='center')
- button = tk.Button(root, text="Confirm", command=sel)
- button.pack(anchor='center')
- label = tk.Label(root)
- label.pack()
- # Choose multiple images
- img_dir = filedialog.askdirectory(parent=root, initialdir="D:/Temp/", title='Choose folder')
- os.chdir(img_dir)
- imgs = iter(os.listdir(img_dir))
- img_label = tk.Label(root)
- img_label.pack()
- #img_label.bind("<Button-1>",save_coords)
- btn_next = tk.Button(root, text='Next image', command=next_img, anchor=tk.SE)
- btn_previous = tk.Button(root, text='Previous image', command=previous_img, anchor=tk.SW)
- btn_next.pack()
- btn_previous.pack()
- next_img() # load first image
- root.mainloop()
Add Comment
Please, Sign In to add comment