Advertisement
Vesna_To

hero

Aug 3rd, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox
  3. app = App(title="Hero-o-matic")
  4.  
  5. # Function definitions for your events go here.
  6. def make_hero_name():
  7. adjective = cmb_adjective.value
  8. colour = txt_colour.value
  9. animal = btg_animal.value
  10. gender = btg_gender.value
  11. hero = adjective + " " + colour + " " + animal + " " + gender
  12. lbl_output.value = "You are... The " + hero + "."
  13.  
  14. # Your GUI widgets go here
  15. message1 = Text(app, text="Pick an adjective")
  16. cmb_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Delightful", "Incredible", "Fantastic"], selected="Incredible", width=25)
  17.  
  18. message2 = Text(app, text="Enter a colour?")
  19. txt_colour = TextBox(app)
  20.  
  21. message3 = Text(app, text="Choose an animal")
  22. btg_animal = ButtonGroup(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor", "Dog", "Lion", "Bat"], width=20)
  23.  
  24. message4= Text (app, text="Choose a gender:")
  25. btg_gender = ButtonGroup(app, options=["Man", "Woman"])
  26.  
  27.  
  28. # Set up event triggers here
  29. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  30. lbl_output = Text(app, text="A hero name will appear here")
  31.  
  32. # Show the GUI on the screen, start listening to events.
  33. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement