Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # guizero - Hero name generator 3 Add another part to the superhero name, perhaps using checkboxes
- from guizero import App, Text, Combo, PushButton, TextBox,CheckBox
- app = App(title="Hero-o-matic")
- # Function definitions for your events go here.
- def pick_animal() :
- if cmb_animal1.value ==1:
- message4.value=cmb_animal1.text
- if cmb_animal2.value ==1:
- message4.value=cmb_animal2.text
- if cmb_animal3.value ==1:
- message4.value=cmb_animal3.text
- if cmb_animal4.value ==1:
- message4.value=cmb_animal4.text
- if cmb_animal5.value ==1:
- message4.value=cmb_animal5.text
- def make_hero_name():
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal=message4.value
- hero = adjective + " " + colour + " " + animal
- 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","funny","lovely"], selected="Amazing")
- message2 = Text(app, text="Enter a colour?")
- txt_colour = TextBox(app)
- message3 = Text(app, text="Pick an animal")
- cmb_animal1 = CheckBox(app, text="Aardvark",command=pick_animal)
- cmb_animal2 = CheckBox(app, text="Badger",command=pick_animal)
- cmb_animal3 = CheckBox(app, text="Cat",command=pick_animal)
- cmb_animal4 = CheckBox(app, text="Velociraptor",command=pick_animal)
- cmb_animal5 = CheckBox(app, text="tutle",command=pick_animal)
- message4 = Text(app,text="A animal's name will appear 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")
- # 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