Advertisement
gorskaja2019

Untitled

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