Advertisement
brendan-stanford

Superhero-3.0_White

Oct 6th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. #import libraries
  2. from guizero import App, Box, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Picture
  3. app = App(title="My-Hero", width=700, height=600, bg = "white")
  4.  
  5. #Name generator function
  6. def make_hero():
  7. start_adjectives = cmb_adj1.value
  8. colour = cmb_clr.value
  9. animal = cmb_aml.value
  10. end_adjective = cmb_adj2.value
  11. planet = txt_planet.value
  12. hero = start_adjectives + " " + colour + " " + animal + " " + end_adjective + " from the planet " + planet
  13. lbl_output.value = "You are... the " + hero + "!"
  14.  
  15. #dark mode function
  16. def dark_mode():
  17. app.bg = "black"
  18. txt_adj1.text_color = "white"
  19. cmb_adj1.text_color = "white"
  20. txt_clr.text_color = "white"
  21. cmb_clr.text_color = "white"
  22. txt_aml.text_color = "white"
  23. cmb_aml.text_color = "white"
  24. txt_adj2.text_color = "white"
  25. cmb_adj2.text_color = "white"
  26. txt_pt.text_color = "white"
  27. txt_planet.text_color = "white"
  28. txt_drk.text_color = "white"
  29. chk_drk.text_color = "white"
  30. btn_name.text_color = "white"
  31. lbl_output.text_color = "white"
  32.  
  33. #GUI widgets
  34. box1 = Box(app, width = "fill", border = 2)
  35. pic = Picture(box1, image = "/home/pi/Desktop/super-dog.png", height=50, width=200)
  36.  
  37. txt_adj1 = Text(box1, text="Select your start adjectives", font = "Times", size = 10)
  38. cmb_adj1 = Combo(box1, options = ["Amazing", "Malicious", "Brave", "Stupendous", "Zany"], selected = "Amazing", width=20)
  39.  
  40. txt_clr = Text(box1, text = "Choose your colour", font = "Times", size = 10)
  41. cmb_clr = Combo(box1, options = ["Red", "Blue", "Yellow"], selected = "Red", width=20)
  42.  
  43. txt_aml = Text(box1, text = "Choose your animal", font = "Times", size = 10)
  44. cmb_aml = Combo(box1, options = ["Aardvark", "Bear", "Deer", "Dog", "Owl", "Turtle", "Zebra"], selected = "Aardvark", width = 20)
  45.  
  46. txt_adj2 = Text(box1, text="Select your end adjective", font = "Times", size = 10)
  47. cmb_adj2 = Combo(box1, options = [" of doom", " of power", "of terror", " of awesome"], selected = " of doom", width=20)
  48.  
  49. txt_pt = Text(box1, text = "Enter your home planet", font = "Times", size = 10)
  50. txt_planet = TextBox(box1)
  51.  
  52. #GUI events
  53. box2 = Box(app, width = 500, height = 100, border = 2)
  54. txt_drk = Text(box2, text = "Enable dark mode?", font = "Times", size = 10)
  55. chk_drk = CheckBox(box2, text = "Turn on dark mode!", command = dark_mode)
  56.  
  57. btn_name = PushButton(box2, text="Make my Hero", command = make_hero)
  58. lbl_output = Text(box2, text="A hero will appear here", font = "Times", size = 10)
  59.  
  60. #Show GUI; wait for events
  61. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement