How to use the guizero.Box 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_box.py View on Github external
def test_repeat_schedule():
    a = App()
    b = Box(a)
    schedule_repeat_test(a, b)
    a.destroy()
github lawsie / guizero / tests / test_box.py View on Github external
def test_enable():
    a = App()
    b = Box(a)
    t = Text(b)
    cascading_enable_test(a)
    cascading_enable_test(b)
    a.destroy()
github lawsie / guizero / tests / test_box.py View on Github external
def test_grid_layout():
    a = App(layout="grid")
    
    w = Box(a, grid=[1,2])
    grid_layout_test(w, 1, 2, 1, 1, None)
    
    ws = Box(a, grid=[1,2,3,4])
    grid_layout_test(ws, 1, 2, 3, 4, None)

    wa = Box(a, grid=[1,2], align="top")
    grid_layout_test(wa, 1, 2, 1, 1, "top")
    
    a.destroy()
github lawsie / guizero / tests / test_box.py View on Github external
def test_default_values():
    a = App()
    b = Box(a)
    assert b.master == a
    assert b.layout == "auto"
    assert b.grid == None
    assert b.align == None
    a.destroy()
github lawsie / guizero / examples / layout_boxes.py View on Github external
from guizero import App, Box, Text, TextBox
app = App()

title_box = Box(app, width="fill", align="top", border=True)
Text(title_box, text="title")

buttons_box = Box(app, width="fill", align="bottom", border=True)
Text(buttons_box, text="buttons")

options_box = Box(app, height="fill", align="right", border=True)
Text(options_box, text="options")

content_box = Box(app, align="top", width="fill", border=True)
Text(content_box, grid=[0,0], text="content")

form_box = Box(content_box, layout="grid", width="fill", align="left", border=True)
Text(form_box, grid=[0,0], text="form")
Text(form_box, grid=[0,1], text="label")
TextBox(form_box, grid=[1,1], text="data", width="fill")
github lawsie / guizero / examples / using_turtle2.py View on Github external
a = App()

def draw():
    turtle2.pencolor(color.value)
    turtle.clear()
    turtle2.clear()

    for i in range(sides.value):
        turtle.forward(length.value)
        turtle.right(int(360 / sides.value))
        turtle2.forward(length.value)
        turtle2.right(int(360 / sides.value))

Text(a, text="this is a guizero turtle")

buttons_box = Box(a)

Text(buttons_box, text="no. of sides: ", align="left")
sides = Slider(buttons_box, start=3, end=10, align="left")

Text(buttons_box, text="length: ", align="left")
length = Slider(buttons_box, start=10, end=100, align="left")
length.value = 100

color = Combo(buttons_box, align="left", options=["red", "green", "blue", "yellow", "purple", "black"])

draw_button = PushButton(buttons_box, text="Draw", align="left", command=draw)

turtle = Turtle(a, width="fill", height="fill")
turtle2 = Turtle(turtle, width="fill", height="fill")

a.display()
github lawsie / guizero / examples / tk_widget.py View on Github external
from guizero import App, Box, Text
from tkinter import Spinbox
from tkinter.ttk import Progressbar

app = App(title="Using tk widgets")

Text(app, text="Spinbox")

# add a spinbox widget to the app
sp = Spinbox(from_=0, to=10)
app.add_tk_widget(sp)

Text(app, text="and Progressbar")

box = Box(app, border=True)

# add a progress bar to the boc
pb = Progressbar(box.tk)
box.add_tk_widget(pb)
pb.start()

Text(app, text="in guizero")

app.display()
github lawsie / guizero / examples / multi_box.py View on Github external
for screen in all_screens:
        screen.hide()


app = App("Multi box app", layout="grid")

# Create a blank list to hold all the different screens
all_screens = []

# Create a box to contain the menu buttons
menu = Box(app, grid=[0,0], layout="grid")
menu.tk.width = 900
menu.bg = "red"

# Option 1 box
option1 = Box(app, grid=[1,1])
text1 = Text(option1, text="This is the first page of stuff")
combo = Combo(option1, options=["Beef", "Chicken", "Fish", "Vegetarian"])
all_screens.append(option1)

# Option 2 box
option2 = Box(app, grid=[1,1])
text2 = Text(option2, text="This is the second page of stuff")
slider = Slider(option2)
all_screens.append(option2)

# Add the screens to the menu box
option1_button = PushButton(menu, text="Option 1", command=switch_screen, args=[option1], grid=[0,0], align="left")
option2_button = PushButton(menu, text="Option 2", command=switch_screen, args=[option2], grid=[1,0], align="left")

# Hide all screens and then show the first one
hide_all()
github topshed / RPi_8x8GridDraw / 8x8grid-guizero.py View on Github external
text_slider = Text(box_framerate, text="Framerate (fps)", grid = [0,1], size=10)


matrix = Waffle(app,height=8,width=8,dim=30,command=p_clicked,color="black",grid=[0,1,7,7])
palette = Waffle(app,height=10, width=1, dim =20, command = col_select,grid=[7,1,1,7])
palette.set_pixel(0, 0, "red")
palette.set_pixel(0,1, (0,255,0))
palette.set_pixel(0,2, "blue")
palette.set_pixel(0,3, "yellow")
palette.set_pixel(0,4, (100,100,100))
palette.set_pixel(0,5, "white")
palette.set_pixel(0,6, (255,0,255))
palette.set_pixel(0,7, "orange")
palette.set_pixel(0,8, "black")
palette.set_pixel(0,9, (66,220,240))
box = Box(app, width=30,height=30,grid=[2,10,2,1])
box.bg =col
text_current_col = Text(app, text="Selected Colour:", grid=[0,10,3,1])
text_rotation = Text(app, text="LED Rotation:", grid=[5,10,3,1])
combo_rotation = Combo(app, options=["0", "90", "180", "270"],grid=[8,10,2,1],command=sh_rotation)


button_clear = PushButton(app, command=clear_matrix,grid=[8,1], text = "Clear")
button_clear.bg = col


frame_status_text = Text(app, text="Frame " + str(current_frame_number).zfill(3) + " of " + str(len(frames)).zfill(3), grid=[0,11,3,1])
button_new_frame = PushButton(app, command=new_frame,grid=[3,11,2,1], text = "New",padx=28)
button_new_frame = PushButton(app, command=copy_frame,grid=[5,11,2,1], text = "Duplicate")
button_new_frame = PushButton(app, command=delete_frame,grid=[7,11,2,1], text = "Delete", padx=20)
github lawsie / guizero / examples / paint.py View on Github external
tool = Combo(tool_box, options=["line", "rectangle", "oval"], selected="line", align="top", width="fill", command=select_tool)

color_label = Text(tool_box, text="color", align="top", width="fill")
color_label.bg = "black"
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()