Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. # guizero - Hero name generator , boxes version
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, Picture, ListBox, Box
  3. app = App(title="Central Europe Hero-o-matic :-) ", height=660, width=740)
  4.  
  5. # Function definitions go here.
  6. def make_hero_name():
  7. colour = " "
  8. ckb_second_adjective_str = " "
  9. great_name = " "
  10. if ckb_second_adjective.value == 1:
  11. ckb_second_adjective_str = ckb_second_adjective.text
  12. if str(lbx_add_gname.value) != "None":
  13. great_name = lbx_add_gname.value
  14.  
  15. adjective = cmb_adjective.value
  16. colour = txt_colour.value
  17. animal = cmb_animal.value
  18.  
  19. hero = adjective + " " + colour + " " + ckb_second_adjective_str + " " + animal + " " + great_name
  20. lbl_output.text_size = 20
  21. lbl_output.value = "You are... The " + hero + "."
  22.  
  23. def dark_mode():
  24. if ckb_dark_mode.value == 1:
  25. app.bg = "black"
  26. app.text_color = "white"
  27. else:
  28. app.bg = "light grey"
  29. app.text_color = "black"
  30.  
  31. # GUI widgets go here
  32. box_one = Box(app, align="top", width="fill", border=2)
  33. box_one.bg = "green"
  34. pic = Picture(box_one, image="heroes.jpeg")
  35.  
  36. ckb_dark_mode = CheckBox(app, text="Dark Mode", command=dark_mode)
  37.  
  38. box_two = Box(app, align="top", width="fill", border=2)
  39. box_two.bg = "firebrick"
  40. message1 = Text(box_two, text="Choose an adjective")
  41. cmb_adjective = Combo(box_two, options=["Patriotic", "Persistent","Heroic","Brave", "Steadfast", "National"], selected="Patriotic", width=20)
  42.  
  43. box_three = Box(app, align="top", width="fill", border=2)
  44. box_three.bg = "olive drab"
  45. message2 = Text(box_three, text="Enter a colour?")
  46. txt_colour = TextBox(box_three)
  47.  
  48. box_four = Box(app, align="top", width="fill", border=2)
  49. box_four.bg = "lawn green"
  50. message3 = Text(box_four, text="Pick an animal")
  51. cmb_animal = Combo(box_four, options=["Wolf", "Wolverine" , "Bear", "Boar", "Eagle", "Moose", "Deer"], selected="Wolverine", width=20)
  52.  
  53. box_five = Box(app, align="top", width="fill", border=2)
  54. box_five.bg = "sienna"
  55. message4 = Text(box_five, text="Choose a second adjective")
  56. ckb_second_adjective = CheckBox(box_five, text="Mighty")
  57.  
  58. message5 = Text(box_five, text="Additional great name")
  59. lbx_add_gname = ListBox(box_five, items=["The Great Warrior", "The Best Hunter", "The Sky Conqueror"], height = 80, width=160)
  60.  
  61. lbl_output = Text(app, text="A hero name will appear here")
  62.  
  63. # Set up event triggers here
  64. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  65.  
  66. # Show the GUI on the screen, start listening to events.
  67. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement