Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox
  3. app = App(title="Central Europe Hero-o-matic :-) ")
  4.  
  5. # Function definitions for your events go here.
  6. def make_hero_name():
  7. ckb_second_adjective_str=""
  8. if ckb_second_adjective.value == 1:
  9. ckb_second_adjective_str = ckb_second_adjective.text
  10. adjective = bgp_adjective.value
  11. colour = txt_colour.value
  12. animal = cmb_animal.value
  13. hero = adjective + " " + colour + " " + ckb_second_adjective_str + " " + animal
  14. lbl_output.text_size = 14
  15. lbl_output.value = "You are... The " + hero + "."
  16.  
  17. # GUI widgets go here
  18. message1 = Text(app, text="Choose an adjective")
  19. bgp_adjective = Combo(app, options=["Patriotic", "Persistent","Heroic","Brave", "Steadfast", "National"], selected="Patriotic", width=20)
  20.  
  21. message2 = Text(app, text="Enter a colour?")
  22. txt_colour = TextBox(app)
  23.  
  24. message3 = Text(app, text="Pick an animal")
  25. cmb_animal = Combo(app, options=["Wolf", "Wolverine" , "Bear", "Boar", "Eagle", "Moose", "Deer"], selected="Wolverine", width=20)
  26.  
  27. message4 = Text(app, text="Choose a second adjective")
  28. ckb_second_adjective = CheckBox(app, text="Mighty")
  29.  
  30. lbl_output = Text(app, text="A hero name will appear here")
  31.  
  32. # Set up event triggers here
  33. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  34. # Show the GUI on the screen, start listening to events.
  35. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement