Advertisement
zhongnaomi

gui 9 make me a hero 2

Sep 10th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 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 = 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. # Your GUI widgets go here
  13. message1 = Text(app, text="Choose an adjective")
  14. bgp_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Delightful","Lovely"], selected="Bonny", width=20)
  15.  
  16. message2 = Text(app, text="Enter a colour?")
  17. txt_colour = TextBox(app)
  18.  
  19. message3 = Text(app, text="Pick an animal")
  20. cmb_animal = ButtonGroup(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor","Turtle","Dog"], selected="Turtle")
  21.  
  22. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  23.  
  24. lbl_output = Text(app, text="A hero name will appear here")
  25.  
  26. # Set up event triggers here
  27.  
  28. # Show the GUI on the screen, start listening to events.
  29. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement