File: massive_waffle.py

package info (click to toggle)
python-guizero 1.1.1%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,676 kB
  • sloc: python: 6,286; makefile: 28; sh: 17
file content (27 lines) | stat: -rw-r--r-- 832 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from guizero import App, Waffle
from tkinter import Canvas, BOTH
import random

# Changes the colour of a randomly chosen pixel to a random colour value
def change_color():
    x = random.randint(1, big_waffle.width-1)
    y = random.randint(1, big_waffle.height-1)
    try:
        rgb = "#%02x%02x%02x" % ( random.randint(0,255), random.randint(0,255), random.randint(0, 255))
        big_waffle.set_pixel(x, y, rgb)
    except:
        print("Oops, something went wrong")

    # Wait 10ms and call this function again
    app.after(10, change_color)


app = App("Waffle!", height=50*20, width=50*20)

# Create a waffle 80x80 with circular pixels 10x10 and 2px padding between them
big_waffle = Waffle(app, height=80, width=80, dim=10, pad=2, dotty=True)

# Call the function once to start it off...
change_color()

app.display()