Cho hỏi tại sao nhấn btn lại không hiện hình ảnh
from tkinter import from tkinter.ttk import from PIL import ImageTk,Image, ImageFilter
filter_types =['BLUR','CONTOUR','DETAIL','EDGE_ENHANCE','EDGE_ENHANCE_MORE','EMBOSS','FIND_EDGES','SHARPEN','SMOOTH','SMOOTH_MORE'] path = 'girl.jpg'
def btnShow_click(): filter_type = cb.get() load = Image.open(path) if filter_type=='BLUR': load1 = load.filter(ImageFilter.BLUR) elif filter_type=='CONTOUR': load1 = load.filter(ImageFilter.CONTOUR) elif filter_type=='DETAIL': load1 = load.filter(ImageFilter.DETAIL) elif filter_type=='EDGE_ENHANCE': load1 = load.filter(ImageFilter.EDGE_ENHANCE) elif filter_type=='EDGE_ENHANCE_MORE': load1 = load.filter(ImageFilter.EDGE_ENHANCE_MORE) else: load1 = load.filter(ImageFilter.EMBOSS)
im = ImageTk.PhotoImage(load1)
print(type(im))
labal1 = Label(frame2, image=im)
labal1.grid(column=0,row=1)
win = Tk() win.geometry('550x600') frame1 = Frame(win) frame1.grid(column=0,row=0) frame2 = Frame(win) frame2.grid(column=0,row=1)
cb = Combobox(frame1,width=30,font=('Arial',14)) cb['values'] = filter_types cb.current(0) cb.pack(side=TOP) btnShow = Button(frame1, text="Show",command=btnShow_click) btnShow.pack(side=TOP) win.mainloop()
Unpublished comment
Viết câu trả lời