Python Forum
Example of guizero ListBox
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Example of guizero ListBox
#1
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.
Reply
#2
Is there a particular reason why you are using a 3rd party package for GUI (guizero) rathen than one of the proven GUI packages like Qt, tkinter, wxpython etc.?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  guizero repeat command pdihawk 2 2,906 Sep-28-2020, 01:32 PM
Last Post: pdihawk
  Trying to clear a list automatically at certain times (guizero) reneejerden 3 2,844 Jul-26-2019, 05:13 PM
Last Post: Denni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020