Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, Combo, 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 = bgp_adjective.value
  8. colour = txt_colour.value
  9. animal = cmb_animal.value
  10. hero = adjective + " " + colour + " " + animal
  11. lbl_output.value = "You are... The " + hero + "."
  12.  
  13.  
  14. # Your GUI widgets go here
  15. message1 = Text(app, text="Choose an adjective")
  16. bgp_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Delightful"], selected="Amazing")
  17.  
  18. message2 = Text(app, text="Enter a colour?")
  19. txt_colour = TextBox(app)
  20.  
  21. message3 = Text(app, text="Pick an animal")
  22. cmb_animal = Combo(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor", "Dog", "Pig"], selected="Aardvark")
  23.  
  24. btn_make = PushButton(app, command=make_hero_name, text="Make me a hero")
  25. lbl_output = Text(app, text="A hero name will appear here")
  26.  
  27. # Set up event triggers here
  28.  
  29. # Show the GUI on the screen, start listening to events.
  30. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement