How to use the guizero.ListBox 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_listbox.py View on Github external
def test_grid_layout():
    a = App(layout="grid")
    
    w = ListBox(a, grid=[1,2])
    grid_layout_test(w, 1, 2, 1, 1, None)
    
    ws = ListBox(a, grid=[1,2,3,4])
    grid_layout_test(ws, 1, 2, 3, 4, None)

    wa = ListBox(a, grid=[1,2], align="top")
    grid_layout_test(wa, 1, 2, 1, 1, "top")
    
    a.destroy()
github lawsie / guizero / tests / test_listbox.py View on Github external
def test_repeat_schedule():
    a = App()
    l = ListBox(a, ["foo", "bar"])
    schedule_repeat_test(a, l)
    a.destroy()
github lawsie / guizero / tests / test_listbox.py View on Github external
def test_auto_layout():
    a = App()
    w = ListBox(a)
    auto_layout_test(w, None)
    a.destroy()
github lawsie / guizero / tests / test_listbox.py View on Github external
def test_grid_layout():
    a = App(layout="grid")
    
    w = ListBox(a, grid=[1,2])
    grid_layout_test(w, 1, 2, 1, 1, None)
    
    ws = ListBox(a, grid=[1,2,3,4])
    grid_layout_test(ws, 1, 2, 3, 4, None)

    wa = ListBox(a, grid=[1,2], align="top")
    grid_layout_test(wa, 1, 2, 1, 1, "top")
    
    a.destroy()
github lawsie / guizero / tests / test_listbox.py View on Github external
def test_insert():
    a = App()
    l = ListBox(a, ["foo", "bar"])

    assert l.items == ["foo", "bar"]
    l.insert(1, "car")
    assert l.items == ["foo", "car", "bar"]

    a.destroy()
github lawsie / guizero / tests / test_listbox.py View on Github external
def test_alt_values():
    a = App(layout = "grid")
    l = ListBox(
        a,
        ["foo", "bar"],
        selected = "bar",
        grid = [0,1],
        align = "top",
        width=10,
        height=11)

    assert l.value == "bar"
    assert l.items == ["foo", "bar"]
    assert l.grid[0] == 0
    assert l.grid[1] == 1
    assert l.align == "top"
    assert l.width == 10
    assert l.height == 11
github lawsie / guizero / tests / test_listbox.py View on Github external
def test_multi_getters_setters():
    a = App()
    l = ListBox(a, ["foo", "bar"], multiselect=True)

    assert l.value == None
    l.value = ["bar"]
    assert l.value == ["bar"]
    l.value = ["bar", "foo"]
    # test selected values are in value
    assert all(x in l.value for x in ['bar', 'foo'])

    a.destroy()
github lawsie / guizero / tests / test_listbox.py View on Github external
def test_clear():
    a = App()
    l = ListBox(a, ["foo", "bar"])
    assert l.items == ["foo", "bar"]
    l.clear()
    assert l.items == []

    a.destroy()
github lawsie / guizero / tests / test_listbox.py View on Github external
def test_update_command():
    a = App()

    callback_event = Event()
    def callback():
        callback_event.set()

    l = ListBox(a, ["foo", "bar"])

    l._listbox._command_callback()
    assert not callback_event.is_set()

    l.update_command(callback)
    l._listbox._command_callback()
    assert callback_event.is_set()
    callback_event.clear()

    l.update_command(None)
    l._listbox._command_callback()
    assert not callback_event.is_set()

    a.destroy()
github lawsie / guizero / examples / listbox.py View on Github external
from guizero import App, ListBox, Text

def change_color(value):
    t.text_color = value

def update_text():
    if mlistbox.value is None:
        t.value = "Its a ListBox"
    else:
        t.value = "Its a " + " ".join(mlistbox.value) + " ListBox"

a = App()

t = Text(a, text="Its a ListBox", color="black")

listbox = ListBox(
    a,
    items=["red", "green", "blue", "yellow", "purple", "turquoise", "pink", "orange", "black", "brown", "cyan"],
    selected="black",
    command=change_color,
    scrollbar=True,
    width="fill",
    height=150)

mlistbox = ListBox(
    a,
    items=["really", "slightly", "brilliant", "interesting", "but", "and", "rubbish", "stupid"],
    multiselect=True,
    command=update_text,
    width="fill",
    height="fill")