Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import filedialog
- from PIL import ImageTk, Image
- window = Tk()
- window.title("Image preview")
- window.geometry("1024x600")
- def openImage():
- fileName = filedialog.askopenfilename(title = "Please select image")
- print("image path - " + fileName)
- picture = ImageTk.PhotoImage(Image.open(fileName))
- imageLabel.configure(image = picture)
- imageLabel.image = picture
- label = Label(window, text = "Image:")
- label.pack()
- button = Button(window, text = "Open image", command = openImage)
- button.pack()
- imageLabel = Label(window)
- imageLabel.pack()
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement