Advertisement
gorskaja2019

Untitled

Apr 10th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. from tkinter import *
  2. from random import *
  3.  
  4. root = Tk()
  5. c = Canvas(root, width = 500, height = 500, bg = 'lightblue')
  6. c.pack()
  7.  
  8. color = ['red', 'yellow', 'blue', 'cyan', 'orange']
  9.  
  10. def random_rectangle(width, height, col):
  11. x1 = randrange(width)
  12. y1 = randrange(height)
  13. x2 = x1 + randint(1, 100)
  14. y2 = y1 + randint(1, 100)
  15. c.create_rectangle(x1, y1, x2, y2, fill = col)
  16.  
  17. for i in range(100):
  18. random_rectangle(500, 500, 'red')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement