Raindow rain with python and Tkinter top view (circle expansion) with source code

Published: 10 February 2017
on channel: max La
1,180
17

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)


On this page of the site you can watch the video online Raindow rain with python and Tkinter top view (circle expansion) with source code with a duration of hours minute second in good quality, which was uploaded by the user max La 10 February 2017, share the link with friends and acquaintances, this video has already been watched 1,180 times on youtube and it was liked by 17 viewers. Enjoy your viewing!