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()
Larz60+ write Oct-29-2020, 08:15 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time, please use tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time, please use tags on future posts.