Advertisement
here2share

# tk_justrandomdots.py

Jun 16th, 2023
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. # tk_justrandomdots.py
  2.  
  3. import tkinter as tk
  4. import random
  5.  
  6. ww = hh = 600
  7.  
  8. def generate_pattern():    
  9.     for _ in range(1200):
  10.         x = random.randint(0, ww)
  11.         y = random.randint(0, hh)
  12.         r = random.randint(0, 255)
  13.         g = random.randint(0, 255)
  14.         b = random.randint(0, 255)
  15.         size = random.randint(1, 20)
  16.        
  17.         canvas.create_oval(x, y, x+size, y+size, fill=f'#{r:02x}{g:02x}{b:02x}', outline='')
  18.  
  19. root = tk.Tk()
  20. canvas = tk.Canvas(root, width=ww, height=hh)
  21. canvas.pack()
  22.  
  23. generate_pattern()
  24.  
  25. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement