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, CheckBox
- app = App(title="Central Europe Hero-o-matic :-) ")
- # Function definitions for your events go here.
- def make_hero_name():
- ckb_second_adjective_str=""
- if ckb_second_adjective.value == 1:
- ckb_second_adjective_str = ckb_second_adjective.text
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = cmb_animal.value
- hero = adjective + " " + colour + " " + ckb_second_adjective_str + " " + animal
- lbl_output.text_size = 14
- lbl_output.value = "You are... The " + hero + "."
- # GUI widgets go here
- message1 = Text(app, text="Choose an adjective")
- bgp_adjective = Combo(app, options=["Patriotic", "Persistent","Heroic","Brave", "Steadfast", "National"], selected="Patriotic", width=20)
- message2 = Text(app, text="Enter a colour?")
- txt_colour = TextBox(app)
- message3 = Text(app, text="Pick an animal")
- cmb_animal = Combo(app, options=["Wolf", "Wolverine" , "Bear", "Boar", "Eagle", "Moose", "Deer"], selected="Wolverine", width=20)
- message4 = Text(app, text="Choose a second adjective")
- ckb_second_adjective = CheckBox(app, text="Mighty")
- lbl_output = Text(app, text="A hero name will appear here")
- # Set up event triggers here
- btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
- # Show the GUI on the screen, start listening to events.
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement