File: listbox.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 (33 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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")

a.display()