Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- The following contains bright, flashing lights and/or
- imagery that may cause discomfort and/or seizures for
- those with photosensitive epilepsy.
- Viewer discretion is advised.
- '''
- # Import the necessary modules
- import tkinter as tk
- import random
- # Create a window
- root = tk.Tk()
- # Create a canvas
- canvas = tk.Canvas(root, width=500, height=500)
- canvas.pack()
- # Create a list of colors
- colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple']
- # Create a loop to create a rainbow
- for i in range(500):
- # Create a random color
- color = random.choice(colors)
- # Create a rectangle
- canvas.create_rectangle(0, 0, i, 500, fill=color)
- # Refresh the window
- root.update()
- # Pause for 1/100 second
- root.after(10)
- # End the program
- root.mainloop()
- # End of file
Add Comment
Please, Sign In to add comment