Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_full_360_img_rotate_for_Py3.py
- # This was very tricky to solve, rotating images such as in this demo was said to be impossible for Py3 by all the many experts who addressed
- from tkinter import *
- from PIL import ImageTk, Image
- import io
- import base64, zlib
- root = Tk()
- root.geometry("200x200+0+0")
- canvas = Canvas(root)
- canvas.pack()
- b64='''\
- eJzlVok7FNobPpipmRHG2MYgjF2SLWNLxjq2CbkydWlIaFGKQkUMRaXQLYw21XXJLZRIpcWSpZsQ
- spQsCWVJ9nW+37j3z/id5znn/b7vfOd5z3nPc5ZzbkwHEQKFgBAScWTYevAxm18zcUL81tOE1MMH
- gTAPB2tU8F7+O9/BBNFd6Qg9TBFe9sMiJITcXDzt+HE8np86ghAPyQAFgYzMiLT0HNIEZAhaCIwQ
- mKAZEwTa2q00Wquq6qK5+XcLi0XkCMgNUCCgSGAi2IF4xxAwmd329t9sbBZZrOEdO5b37/8UGPgt
- KGgpMnKB0kURGhbikyCQIveRpQHJLMggUEdgbNhtqAqIBkhtRE17Sdviu4XpsikCOwTbEQQjCOdT
- 7QC0F9CxFWQ3bue06OQ+4+7F82JNsHYu7tw/vD+YF3xs5FjEQgSKA8QFlAuoFBAkIEhHcAfBM1QP
- qJ0fqUbwEX3nG0OIx5MBUAMwAWAARAA0Skt/ERTsERFp4xuKih+1tD7r6Y0jNColNS0g8AuPX507
- IoAwmsfjAZEAKQIJARn9kpdfkZJalpMDpAz/CaeJQB+BGfqmqTlGpU6pq/OoVJ6W1tSWLQvGxkvm
- 5oCsADnxl8VDuwAFADoKtv8u1wfBAQRhCE6gTgeHzp07e44fH3N0nHB2XrK25rm6znh4TLNYy7/9
- NuDvP3b4cP+RI/0nT04dOLAcEMALCZkMDZ06cWLlyJFExLuFIB9BCQJA8YAuAroK6AagbECFgIoB
- Peetf1iHoGU1oQrQP4BaAH0aXnW/AfoxtWpM8RAPCACyAFoABgAuAJ4A/gAn4RygTED5gF7w5eQg
- uIQgDUEWgmwE91clh2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8ZPbrsRQqsRHscnhsg+UeooKDcQcBr8GEQde
- SYxf1Xu3JzqBjBEupGYmn0qk1Mxsn5NhkwZ+dmxxKtnhOrtiWqPjPW92ud7257qFlp9s2/1FuMnD
- d15U2uzVjIhsAJf+PVIDt06u2F9kt59OMugl6nhOnXgYdLsJ+9ToGaNnbVsvKeDGqfgqsfLPUn0Y
- X9GtflUbGTGF4eT1c/RyYYsQ/gurKU8jk+wvUSa1b4os7I8YYkQ80fERyGK/9nNrPkK9mdYhpm6W
- vPRI0KcpyK3kaFhBgeVg5LKXzZO3TuQ34ffuP16WuUFwnrjLTmF7zeIC99JkdCR5YrkfK/4KNTmz
- c/Xf6mjHtC2wZnP+B/XTMrY='''
- def draw():
- canvas.create_image(100, 100, image=cv.photo, anchor="center")
- root.update()
- #
- canvas = Canvas(root, width=200, height=200)
- canvas.place(relx=0.5, rely=0.5, anchor="center")
- #
- class Cv(): pass
- cv=Cv()
- cv.angle = 0
- b64_img = zlib.decompress(base64.b64decode(b64))
- photo = Image.open(io.BytesIO(b64_img))
- # make background of photo transparent
- photo = photo.convert("RGBA")
- def do360():
- cv.angle = (cv.angle + 2) % 360
- cv.photo = ImageTk.PhotoImage(photo.rotate(cv.angle, expand=True))
- draw()
- # root.after(10, do360)
- while 1:
- do360()
Add Comment
Please, Sign In to add comment