app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
from tkinter import * from PIL import ImageTk, Image from tkinter import filedialog def openfilename(): filename = filedialog.askopenfilename(title ='"pen') return filename def open_img(): x = openfilename() img = Image.open(x) img = img.resize((500, 500), Image.LANCZOS) img = ImageTk.PhotoImage(img) panel = Label(root, image = img) panel.image = img panel.grid(row = 2) root = Tk() root.title("Image Loader") root.geometry("550x300") root.resizable(width = True, height = True) btn = Button(root, text ='open image', command = open_img).grid( row = 1, columnspan = 4) root.mainloop() |