Link to the gitlab source code :
https://gitlab.com/ymmx/youtube/blob/...
source code:
-*- coding: utf-8 -*-
from _future_ import print_function, absolute_import
from tkinter import *
import random
class a_drop:
def __init__(self,width, height ):
self.x=random.randint(0,width)
self.y=random.randint(0,height)
self.cv = None
self.r=0
self.a=random.randint(1,5)*1.
self.v = 1
self.color='#%02x%02x%02x' % (random.randint(0,255),random.randint(0,255),random.randint(0,255))
class MyApp(Tk):
def __init__(self):
self.nbi=0
Tk.__init__(self)
fr = Frame(self)
fr.pack()
self.canvas = Canvas(fr, height = 720, width = 1280,bg= 'gray10')
self.canvas.pack()
self.drops = []
return
def update_drops(self, ):
self.drops.append(a_drop(self.canvas.winfo_reqwidth(), self.canvas.winfo_reqheight()))
self.drops.append(a_drop(self.canvas.winfo_reqwidth(), self.canvas.winfo_reqheight()))
toremove=[]
for idx, drop_ in enumerate(self.drops):
self.drops[idx].r += self.drops[idx].v
self.drops[idx].a -= 0.05
if self.drops[idx].a <= 0.:
toremove.append(idx)
else:
if self.drops[idx].cv:
self.canvas.delete(self.drops[idx].cv)
self.drops[idx].cv = self.canvas.create_oval(self.drops[idx].x-self.drops[idx].r, self.drops[idx].y-self.drops[idx].r, self.drops[idx].x+self.drops[idx].r, self.drops[idx].y+self.drops[idx].r)
self.canvas.itemconfig(self.drops[idx].cv, outline=self.drops[idx].color)
self.canvas.itemconfig(self.drops[idx].cv, width=self.drops[idx].a)
for i in toremove:
self.canvas.delete(self.drops[i].cv)
self.drops.pop(i)
self.canvas.update()
return
if _name_ == "__main__":
root = MyApp()
i=0
while 1:
root.update_drops( )
root.after(1)
Sur cette page du site, vous pouvez voir la vidéo en ligne Raindow rain with python and Tkinter top view (circle expansion) with source code durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur max La 10 février 2017, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,180 fois et il a aimé 17 téléspectateurs. Bon visionnage!