Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_image_resize_demo.py
- from Tkinter import *
- from PIL import ImageTk, Image
- root=Tk()
- img=Image.open("solidball.png") # http://tinyurl.com/h2sball001
- canvas=Canvas(root, height=200, width=200)
- canvas.pack(side = TOP, expand=True, fill=BOTH)
- def img_resize(basewidth):
- image=img
- wpercent = (basewidth / float(image.size[0]))
- hsize = int((float(image.size[1]) * float(wpercent)))
- image = image.resize((basewidth, hsize), Image.ANTIALIAS)
- photo = ImageTk.PhotoImage(image)
- item4 = canvas.create_image(100, 100, image=photo)
- canvas.update()
- #
- while True:
- for basewidth in range(1, 400):
- img_resize(basewidth)
- root.mainloop()
Add Comment
Please, Sign In to add comment