How to use the guizero.Drawing function in guizero

To help you get started, we’ve selected a few guizero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lawsie / guizero / tests / test_drawing.py View on Github external
def test_repeat_schedule():
    a = App()
    d = Drawing(a)
    schedule_repeat_test(a, d)
    a.destroy()
github lawsie / guizero / tests / test_drawing.py View on Github external
def test_auto_layout():
    a = App()
    w = Drawing(a)
    auto_layout_test(w, None)
    a.destroy()
github lawsie / guizero / tests / test_drawing.py View on Github external
def test_destroy():
    a = App()
    d = Drawing(a)
    destroy_test(d)
    a.destroy()
github lawsie / guizero / tests / test_drawing.py View on Github external
def test_after_schedule():
    a = App()
    d = Drawing(a)
    schedule_after_test(a, d)
    a.destroy()
github lawsie / guizero / tests / test_drawing.py View on Github external
def test_display():
    a = App()
    d = Drawing(a)
    display_test(d)
    a.destroy()
github lawsie / guizero / tests / test_drawing.py View on Github external
def test_delete():
    a = App()
    d = Drawing(a)
    id1 = d.line(1,2,3,4)
    id2 = d.oval(1,2,3,4)
    assert len(d.tk.find_all()) == 2
    d.delete(id1)
    assert len(d.tk.find_all()) == 1
    d.delete(id2)
    assert len(d.tk.find_all()) == 0
    a.destroy()
github lawsie / guizero / tests / test_drawing.py View on Github external
def test_default_values():
    a = App()
    d = Drawing(a)
    assert d.master == a
    assert d.grid == None
    assert d.align == None
    assert d.width == 100
    assert d.height == 100
    a.destroy()
github lawsie / guizero / tests / test_drawing.py View on Github external
def test_rectangle():
    a = App()
    d = Drawing(a)
    id = d.rectangle(1,2,3,4)
    assert id > 0
    a.destroy()
github lawsie / guizero / examples / drawing.py View on Github external
from guizero import App, Drawing

a = App(width = 370, height=700)

# create drawing object
d = Drawing(a, width="fill", height="fill")
d.bg = "light blue"

# draw the shapes
d.rectangle(10, 10, 60, 60)
d.rectangle(70, 10, 120, 60, color="yellow")
d.rectangle(130, 10, 180, 60, color="yellow", outline=True)
d.rectangle(190, 10, 240, 60, color="yellow", outline=5)
d.rectangle(250, 10, 300, 60, color="yellow", outline=5, outline_color="green")
d.rectangle(310, 10, 360, 60, color=None, outline=5, outline_color="red")

d.oval(10, 100, 60, 150)
d.oval(70, 100, 120, 200, color="yellow")
d.oval(130, 100, 240, 150, color="yellow", outline=True)
d.oval(130, 160, 240, 210, color="yellow", outline=5)
d.oval(250, 100, 300, 150, color="yellow", outline=5, outline_color="green")
d.oval(310, 100, 360, 150, color=None, outline=5, outline_color="red")
github lawsie / guizero / examples / paint.py View on Github external
color_label.text_color = "white"

red = Slider(tool_box, end=255, command=update_color)
red.bg = (255, 0, 0)

green = Slider(tool_box, end=255, command=update_color)
green.bg = (0, 255, 0)

blue = Slider(tool_box, end=255, command=update_color)
blue.bg = (0, 0, 255)

line_width_box = Box(tool_box, align="top")
Text(line_width_box, text="width", align="top")
line_width = Slider(line_width_box, start=1, end=10, align="top")

painting = Drawing(paint_box, width="fill", height="fill")
painting.last_event = None
painting.last_shape = None
painting.when_left_button_pressed = start_paint
painting.when_mouse_dragged = draw_paint
painting.when_left_button_released = stop_paint

PushButton(tool_box, text="Clear", command=painting.clear, align="bottom", width="fill")

a.display()