Advertisement
Buzzbow

superhero

Aug 17th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox
  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 = cmb_animal.value
  10.  
  11. if cb_speedy.value == 1:
  12. speedy = ", Speedy"
  13. else:
  14. speedy = ""
  15. if cb_agile.value == 1:
  16. agile = ", Agile"
  17. else:
  18. agile= ""
  19. if cb_can_fly.value == 1:
  20. can_fly = ", Can fly "
  21. else:
  22. can_fly = " "
  23.  
  24. hero = adjective + " " + colour + " " + speedy + agile+ can_fly + animal
  25. lbl_output.value = "You are... The " + hero + "."
  26.  
  27. # Your GUI widgets go here
  28. message1 = Text(app, text="Choose an adjective")
  29. cmb_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Fantastic", "Emotional", "Delightful"], selected="Amazing", width = 20)
  30.  
  31. message2 = Text(app, text="Enter a colour?")
  32. txt_colour = TextBox(app)
  33.  
  34. message3 = Text(app, text="Pick an animal")
  35. cmb_animal = Combo(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Okapi", "Elephant", "Lion", "Tiger", "Velociraptor"], selected="Aardvark", width=20)
  36.  
  37.  
  38. message4 = Text(app, text = "choose an ability")
  39. cb_speedy = CheckBox(app, text="Add Speedy")
  40. cb_agile = CheckBox(app, text="Add Agile")
  41. cb_can_fly = CheckBox(app, text="Add Can fly")
  42. lbl_output = Text(app, text="A hero name will appear here")
  43. # Set up event triggers here
  44. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  45.  
  46.  
  47. # Show the GUI on the screen, start listening to events.
  48. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement