Get the App
SLTechnology News&Howtos  ›  Development  › 

How does Python use PIL.Image to make dynamic diagrams of sports villains

Shulou Source: shulou.com Published: 2022-06-03 03:04:34 10月05日 Update

This article mainly introduces "how Python uses PIL.Image to make the dynamic map of sports villains". In the daily operation, I believe that many people have doubts about how to use Python to make the dynamic map of sports villains. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how Python uses PIL.Image to make dynamic maps of sports villains". Next, please follow the editor to study!

Prepare materials:

Image img.png size: 804x165

Production ideas:

Split the picture into 12 equal parts, each frame size: 67x165; continuous reading and playback will form a dynamic image.

Source code: import tkinter as tkfrom PIL import Image,ImageTkfrom time import sleep flag = False def pause (): global flag flag = not flag while flag: doing () def doing (): global flag while flag: for i in range (12): if not flag:break box = f_out.crop Root = tk.Tk () root.geometry ('400x320') cv = tk.Canvas (root, width=350, height=260) Bg='lightgray') cv.pack () f_in ='d:\\ img.png'f_out = Image.open (f_in) box = f_out.crop ((0gif) 67164) img = ImageTk.PhotoImage (image=box) gif = cv.create_image (180 Magi 135 gif) tk.Button (root,command=pause,text=' action / stop') .place (Xuan 170 Magi 275) root.mainloop () effect:

At this point, the study on "how Python uses PIL.Image to make dynamic diagrams of sports villains" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Dynamic production villains sports learning pictures size more help practical next actions images ideas effects articles methods materials source code theory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Docker vpn Microsoft macOS