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")
- # Function definitions for your events go here.
- def make_hero_name():
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = cmb_animal.value
- hero = adjective + " " + colour + " " + animal
- lbl_output.value = "You are... The " + hero + "."
- # Your GUI widgets go here
- box1 = Box(app, align="centre", width="fill", border=1)
- message1 = Text(box1, text="Choose an adjective")
- bgp_adjective = ButtonGroup(box1, options=["Amazing", "Bonny", "Charming", "Delightful","funny","lovely"], selected="Amazing")
- box2 = Box(app, align="centre", width="fill", border=1)
- message2 = Text(box2, text="Enter a colour?")
- txt_colour = TextBox(box2)
- box3 = Box(app, align="centre", width="fill", border=1)
- message3 = Text(box3, text="Pick an animal")
- cmb_animal = Combo(box3, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor","tutle","dog"], selected="Aardvark", width=20)
- box4 = Box(app, align="centre", width="fill", border=1)
- btn_make_name = PushButton(box4, text='Make me a hero',command=make_hero_name)
- lbl_output = Text(box4, text="A hero name will appear here")
- # Set up event triggers here
- # Show the GUI on the screen, start listening to events.
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement