Advertisement
zhongnaomi

make me hero

Sep 10th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 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. # Function definitions for your events go here.
  5. def pickhero():
  6.     if pickmum.value == 1:
  7.         superhero_name.value= pickmum.text
  8.     if pickdad.value == 1:
  9.         superhero_name.value= pickdad.text
  10.     if pickman.value == 1:
  11.         superhero_name.value= pickman.text
  12. def make_hero_name():
  13.  
  14.     superheroname = superhero_name.value
  15.     adjective = bgp_adjective.value
  16.     colour = txt_colour.value
  17.     animal = cmb_animal.value
  18.     hero = adjective + " " + colour + " " + animal
  19.     lbl_output.value = "You are  " + superheroname + " . The " + hero + "."
  20.    
  21. # Your GUI widgets go here  
  22. message1 = Text(app, text="Choose an adjective")
  23. bgp_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Delightful","Lovely"], selected="Bonny", width=20)
  24. message2 = Text(app, text="Enter a colour?")
  25. txt_colour = TextBox(app)
  26. message3 = Text(app, text="Pick an animal")
  27. cmb_animal = ButtonGroup(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor","Turtle","Dog"], selected="Turtle")
  28. questions_superhero = Text(app, text="Pick a name of superhero?")
  29. pickmum = CheckBox(app, text="supermum", command=pickhero)
  30. pickdad = CheckBox(app, text="superdad", command=pickhero)
  31. pickman = CheckBox(app, text="superman", command=pickhero)
  32. superhero_name = Text (app, text="Your pick superhero's name will appear here")
  33. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  34. lbl_output = Text(app, text="A hero name will appear here")
  35.  
  36. # Show the GUI on the screen, start listening to events.
  37. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement