Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- import os
- try:
- from PIL import Image, ImageTk
- except ModuleNotFoundError:
- os.system('pip install pillow')
- from PIL import Image, ImageTk
- _root = frame1
- imagelabel = tk.Label(_root, text="Unable to load image", bg='white', anchor='center')
- imagelabel.pack(anchor='center', expand=True, fill='both')
- def loadimage(path):
- global imagelabel
- global ImageTk
- global Image
- imagelabel.image = ImageTk.PhotoImage(Image.open(path))
- imagelabel.config(image=imagelabel.image)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement