Advertisement
Vesna_To

hero3

Aug 8th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import *
  3. app = App(title="Hero-o-matic", width=420, height=620, bg="plum1")
  4. app.font_size="11"
  5. # Function definitions
  6. def make_dark_mode ():
  7. if chk_dark.value == 1:
  8. app.bg="black"
  9. app.text_color = "white"
  10.  
  11. else:
  12. app.bg="plum1"
  13. app.text_color = "black"
  14.  
  15. def make_hero_name():
  16. if chk_veg.value == 1:
  17. veg = "vegeterian"
  18. else:
  19. veg = ""
  20. adjective = cmb_adjective.value
  21. colour = txt_colour.value
  22. animal = btg_animal.value
  23. gender = btg_gender.value
  24. hero = adjective + " " + colour + " " + veg + " " + animal + " " + gender
  25. lbl_output.value = "You are... The " + hero + "."
  26.  
  27. #GUI widgets
  28. box_picture=Box(app, border=2)
  29. picture = Picture(box_picture, image="superhero.png")
  30.  
  31. box_dark=Box(app)
  32. box_dark.text_size="11"
  33. chk_dark = CheckBox (box_dark, text="Dark Mode", command=make_dark_mode)
  34.  
  35. box_box=Box(app, height=120, width="fill", border=1)
  36. box_box.bg="plum2"
  37. box_box.font ="Calibri"
  38. box_box.font_size="11"
  39.  
  40. box_adjective=Box(box_box, width=200, height=120, align="left")
  41. message1 = Text(box_adjective, text="Pick an adjective")
  42. cmb_adjective = Combo(box_adjective, options=["Amazing", "Bonny", "Charming", "Delightful", "Incredible", "Fantastic"], selected="Incredible", width=25)
  43.  
  44. box_colour = Box(box_box, width=200, height=120, align="right")
  45. message2 = Text(box_colour, text="Enter a colour?")
  46. txt_colour = TextBox(box_colour, width=25)
  47.  
  48. chk_veg = CheckBox (app)
  49. chk_veg.text_size="11"
  50. chk_veg.text="Vegetarian"
  51.  
  52. box_box2=Box(app, width="fill", height="200", border=1)
  53. box_box2.bg="orchid1"
  54.  
  55. box_animal=Box(box_box2, width="200", height="200", align="left")
  56. message3 = Text(box_animal, text="Choose an animal")
  57. btg_animal = ButtonGroup(box_animal, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor", "Dog", "Lion", "Bat"], width=20)
  58.  
  59. box_gender=Box(box_box2, width="200", height="200", align="top")
  60. message4= Text (box_gender, text="Choose a gender:")
  61. btg_gender = ButtonGroup(box_gender, options=["Man", "Woman"])
  62.  
  63. # event triggers
  64. box=Box(app, width="fill", border=1)
  65. box.bg="plum1"
  66. btn_make_name = PushButton(box, text='Make me a hero', command=make_hero_name)
  67. btn_make_name.bg = "plum3"
  68. lbl_output = Text(box, text="A hero name will appear here")
  69.  
  70.  
  71. # Show the GUI on the screen, start listening to events.
  72. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement