Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # guizero - Hero name generator - John Warr 15/08/2020
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox
- 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
- if checkbox.value == 1:
- title ="Super"
- else:
- title =""
- hero = title + " " + adjective + " " + colour.capitalize() + " " + animal
- lbl_output.text_color = "green"
- lbl_output.value = "You are... The " + hero + "."
- # Your GUI widgets go here
- message1 = Text(app, text="Choose an adjective")
- bgp_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Dude", "Effervescent"], selected="Amazing", width=20)
- message2 = Text(app, text="Enter a colour?")
- txt_colour = TextBox(app, width=20)
- message3 = Text(app, text="Pick an animal")
- cmb_animal = ButtonGroup(app, options=["Aardvark", "Badger", "Dolphin", "Velociraptor", "Goat"], selected="Aardvark", width=20)
- checkbox = CheckBox(app, text="Add Super Title")
- # Set up event triggers here
- btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name, width=20)
- btn_make_name.bg="lightgreen"
- lbl_output = Text(app, text="A hero name will appear here")
- # Show the GUI on the screen, start listening to events.
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment