File: clickable_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 (15 lines) | stat: -rw-r--r-- 504 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from guizero import App, Waffle, PushButton

def change_pixel(x,y):
    if big_waffle.get_pixel(x,y) == 'white':
        big_waffle.set_pixel(x, y, "red")
    else:
        big_waffle.set_pixel(x, y, "white")

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

big_waffle = Waffle(app, height=40, width=40, dim=10, pad=2, dotty=True, command=change_pixel)
enable_button = PushButton(app, big_waffle.enable, text="Enable")
disable_button = PushButton(app, big_waffle.disable, text="Disable")

app.display()