Oct-29-2020, 06:18 PM
I just started using guizero in a game I am developing using pygame. It took some experimentation to get the ListBox to do what I wanted (it's in a different file than my main. So I thought I'd share the code to help others new to the subject. The real key was putting the command function inside the ListBox creation function. This function is called from my main function right after the initial Game class was created.
from guizero import App, ListBox, Text def get_game_type(game): def pick_one(value): game.game_type = value app.destroy() choices = None app = App(width=200, height=150) t = Text(app, 'Choose Game Type') choices = ListBox(app, ["New", "Saved"], height=80, width=80, command=pick_one) print(choices.height) app.display()