Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import filedialog
  3. from PIL import ImageTk, Image
  4.  
  5. window = Tk()
  6. window.title("Image preview")
  7. window.geometry("1024x600")
  8.  
  9. def openImage():
  10.     fileName = filedialog.askopenfilename(title = "Please select image")
  11.     print("image path - " + fileName)
  12.     picture = ImageTk.PhotoImage(Image.open(fileName))
  13.     imageLabel.configure(image = picture)
  14.     imageLabel.image = picture
  15.  
  16.  
  17.  
  18. label = Label(window, text = "Image:")
  19. label.pack()
  20.  
  21. button = Button(window, text = "Open image", command = openImage)
  22. button.pack()
  23.  
  24. imageLabel = Label(window)
  25. imageLabel.pack()
  26.  
  27. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement