Question: from tkinter import * import time import math import random # prep canvas master = Tk() w = Canvas(master, width = 700, height = 600,
from tkinter import * import time import math import random # prep canvas master = Tk() w = Canvas(master, width = 700, height = 600, bg="black") w.pack() # create firework func def firework(): # prep random colors r = random.randrange(0 , 255) g = random.randrange(0, 255) b = random.randrange(0, 255) tk_rgb = "#%02x%02x%02x" %(r, g, b) # create x, y position x = random.randrange(100, 650) y = random.randrange(50, 350) bottom = 550 dMove = w.create_oval(x, bottom, x+10, bottom+10, fill = tk_rgb) # move oval up with for loop for j in range(bottom, y, -30): w.move(dMove, 0, -30) time.sleep(0.3) w.update() w.delete(dMove) w.update() for i in range(0, 20): r = 100 d = math.radians(360/20*i) o = r * math.sin(d) # o is opposite site a = r * math.cos(d) # a is adjacent side x3 = x + a y3 = y - o w.create_line(x, y, x3, y3, fill=tk_rgb) #q = random.randrange(255, 10000000) for i in range(10): firework() time.sleep(.06) w.update()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
