Guest User

Untitled

a guest
Sep 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. # Function to load the next image into the Label
  2. def next_img():
  3. img_label.img = tk.PhotoImage(file=next(imgs))
  4. img_label.config(image=img_label.img)
  5.  
  6. # Function to load the next image into the Label
  7. def previous_img():
  8. img_label.img = tk.PhotoImage(file=back(imgs))
  9. img_label.config(image=img_label.img)
  10.  
  11. def sel():
  12. selection = "Value = " + str(var.get())
  13. label.config(text = selection)
  14. print(img_label.img, selection)
  15.  
  16. root = tk.Tk()
  17. var = tk.DoubleVar()
  18. scale = tk.Scale(root, variable = var, orient='horizontal', from_=1, to=10)
  19. scale.pack(anchor='center')
  20. button = tk.Button(root, text="Confirm", command=sel)
  21. button.pack(anchor='center')
  22. label = tk.Label(root)
  23. label.pack()
  24.  
  25. # Choose multiple images
  26. img_dir = filedialog.askdirectory(parent=root, initialdir="D:/Temp/", title='Choose folder')
  27. os.chdir(img_dir)
  28. imgs = iter(os.listdir(img_dir))
  29.  
  30. img_label = tk.Label(root)
  31. img_label.pack()
  32. #img_label.bind("<Button-1>",save_coords)
  33.  
  34. btn_next = tk.Button(root, text='Next image', command=next_img, anchor=tk.SE)
  35. btn_previous = tk.Button(root, text='Previous image', command=previous_img, anchor=tk.SW)
  36. btn_next.pack()
  37. btn_previous.pack()
  38.  
  39. next_img() # load first image
  40.  
  41. root.mainloop()
Add Comment
Please, Sign In to add comment