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
- app = App(title="Hero-o-matic")
- app.bg = "blue"
- # Function definitions for your events go here.
- def make_hero_name():
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = cmb_animal.value
- fruit = cmb_fruit.value
- hero = adjective + " " + colour + " " + animal+" "+fruit
- 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", "Delightful", "Speedy"], selected="Amazing")
- message1.text_color = "yellow"
- message2 = Text(app, text="Enter a colour?")
- txt_colour = TextBox(app)
- message2.text_color = "yellow"
- message3 = Text(app, text="Pick an animal")
- cmb_animal = Combo(app, options=["Aardvark", "Cat", "Dolphin", "Tiger", "Velociraptor", "Walrus","Seal"], selected="Aardvark", width=20)
- message3.text_color = "yellow"
- message4 = Text(app, text="Pick an fruit")
- cmb_fruit = Combo(app, options=["Banana", "Apple", "Plum", "Pear", "Orange", "Grape","Tangerine"], selected="Banana", width=20)
- message4.text_color = "yellow"
- # Set up event triggers here
- btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
- lbl_output = Text(app, text="A hero name will appear here")
- btn_make_name.text_size = 15
- btn_make_name.text_color = "red"
- # Show the GUI on the screen, start listening to events.
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment