Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # guizero - Hero name generator
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, Box
- app = App(title="Hero-o-matic", width=500, height =500, bg="orange",)
- welcome_message = Text(app, text="HeroGen", size=25, font="Corbel", color="white")
- secondmessage = Text(app, text="Bring your animal hero to life!", color="white", font="Corbel")
- # Function definitions for your events go here.
- def make_hero_name():
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = bgp_animal.value
- verb = bgp_verb.value
- hero = adjective + " " + verb + " " + colour + " " + animal + " "
- lbl_output.value = "Your hero is - The "+ hero + " "
- # Your GUI widgets go here
- message1 = Text(app, text="Step 1: Choose an adjective", font="Corbel" )
- bgp_adjective = ButtonGroup(app, options=["strong", "brave", "confident",], selected="strong")
- message2 = Text(app, text="Step 2: Enter a colour", font="Corbel" , )
- txt_colour = TextBox(app)
- message3 = Text(app, text="Step 3: Pick an animal", font="Corbel" )
- bgp_animal = ButtonGroup(app, options=["bear", "rabbit", "dog",], selected="bear")
- message4 = Text(app, text="Step 3: Choose a verb" ,font="Corbel" )
- bgp_verb = ButtonGroup(app, options=["running", "swimming", "climbing",], selected="running")
- # Set up event triggers here
- box =Box(app)
- box.bg ="white"
- btn_make_name = PushButton(box, text='Click to create your hero', command=make_hero_name,)
- lbl_output = Text(app, text="A hero name will appear here", bg="yellow", font="Corbel", size="15" )
- # Show the GUI on the screen, start listening to events.
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement