Last active
September 23, 2020 10:21
-
-
Save martinohanlon/f72aad61bb48b93e04988704739fa3cd to your computer and use it in GitHub Desktop.
DM@H paint app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, Text, Drawing, Combo, Box, Slider, PushButton | |
def start(event): | |
painting.start_event = event | |
def draw(event): | |
painting.line( | |
painting.start_event.x, painting.start_event.y, | |
event.x, event.y, | |
color=color_picker.value, | |
width=width_picker.value | |
) | |
painting.start_event = event | |
def clear(): | |
painting.clear() | |
app = App(title="Paint") | |
intro = Text(app, "Pi Paint") | |
controls_box = Box(app, align="top", width="fill") | |
color_picker = Combo(controls_box, options=["white", "black", "red", "green", "blue"], align="left") | |
width_picker = Slider(controls_box, start=1, end=10, align="left") | |
width_picker.value = 3 | |
clear_button = PushButton(controls_box, text="clear", command=clear, align = "right") | |
painting = Drawing(app, width="fill", height="fill") | |
painting.bg = "black" | |
painting.when_left_button_pressed = start | |
painting.when_mouse_dragged = draw | |
app.display() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, Text | |
app = App(title="Paint") | |
intro = Text(app, "Christina's paint app - lets draw something cool!") | |
app.display() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, Text, Drawing | |
app = App(title="Paint") | |
intro = Text(app, "Christina's paint app - lets draw something cool!") | |
painting = Drawing(app, width="fill", height="fill") | |
painting.bg = "black" | |
app.display() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, Text, Drawing | |
def draw(event): | |
painting.oval( | |
event.x - 1, event.y - 1, | |
event.x + 1, event.y + 1, | |
color="white") | |
app = App(title="Paint") | |
intro = Text(app, "Christina's paint app - lets draw something cool!") | |
painting = Drawing(app, width="fill", height="fill") | |
painting.bg = "black" | |
painting.when_mouse_dragged = draw | |
app.display() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, Text, Drawing | |
def start(event): | |
painting.start_event = event | |
def draw(event): | |
painting.line( | |
painting.start_event.x, painting.start_event.y, | |
event.x, event.y, | |
color="white", | |
width=3 | |
) | |
painting.start_event = event | |
app = App(title="Paint") | |
intro = Text(app, "Christina's paint app - lets draw something cool!") | |
painting = Drawing(app, width="fill", height="fill") | |
painting.bg = "black" | |
painting.when_left_button_pressed = start | |
painting.when_mouse_dragged = draw | |
app.display() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, Text, Drawing, Combo | |
def start(event): | |
painting.start_event = event | |
def draw(event): | |
painting.line( | |
painting.start_event.x, painting.start_event.y, | |
event.x, event.y, | |
color=color_picker.value, | |
width=3 | |
) | |
painting.start_event = event | |
app = App(title="Paint") | |
intro = Text(app, "Christina's paint app - lets draw something cool!") | |
color_picker = Combo(app, options=["white", "black", "red", "green", "blue"]) | |
painting = Drawing(app, width="fill", height="fill") | |
painting.bg = "black" | |
painting.when_left_button_pressed = start | |
painting.when_mouse_dragged = draw | |
app.display() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment