from tkinter import * from PIL import Image,ImageTk def resize(value): global catimg k = int(value) / 100 w,h = cat.size w,h = int(w * k),int(h * k) cat2 = cat.resize((w,h)) root.title(cat2.size) catimg = ImageTk.PhotoImage(cat2) cv.itemconfig(pic,image=catimg) #cv.update() root = Tk() b1= Scale(root,length=200,orient=HORIZONTAL,from_=50,to=200, activebackground='red',command=resize) b1.pack() cat = Image.open('cat.png') catimg = ImageTk.PhotoImage(cat) cv = Canvas(root,width=280,height=360,bg='white') cv.pack() pic = cv.create_image(140,180,image=catimg,anchor='center') resize('50') root.mainloop()
李兴球
李兴球的博客是Python创意编程原创博客
要发表评论,您必须先登录。
发表评论