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()
|