JAWarr

Hero Name Creator Boxes V3

Aug 18th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.43 KB | None | 0 0
  1. # guizero - Hero name generator - John Warr 15/08/2020 Boxes Version 2
  2.  
  3. from guizero import *
  4. app = App(title="Hero-o-matic V2", width=800, height=800, layout="auto", visible=True)
  5. box1 = Box(app, align="top", width="fill", height="fill", border=2)
  6. box1.bg="green"
  7. box2 = Box(app, align="top", width="fill", height="fill", border=2)
  8. box2.bg="orange"
  9. box3 = Box(app, align="top", width="fill", height="fill", border=2)
  10. box3.bg="red"
  11. box3.text_size=18
  12.  
  13. picture = Picture(box1, image="DAVE2.GIF")
  14.  
  15. # Function definitions for your events go here.
  16. def make_hero_name():
  17. #dark mode
  18.     if checkbox.value == 1:
  19.         app.bg="black"
  20.        
  21.         app.text_color="yellow"
  22.     else:
  23.         box1.bg="green"
  24.         box2.bg="orange"
  25.         box3.bg="red"
  26.         app.text_color="black"
  27.        
  28. # hero options        
  29.     adjective = bgp_adjective.value
  30.     colour = txt_colour.value
  31.     animal = cmb_animal.value
  32.     code = listbox.value
  33.    
  34. #slider options
  35.     if slider.value == 1:
  36.         tbird ="1"
  37.     elif slider.value == 2:
  38.         tbird ="2"
  39.     elif slider.value == 3:
  40.         tbird ="3"
  41.     elif slider.value == 4:
  42.         tbird ="4"
  43.     else:
  44.         tbird="5"
  45.    
  46. #output
  47.     hero = adjective + " " + colour.capitalize() + " " + animal + " " + code + " of Thunderbird " + tbird
  48.     lbl_output.text_color = "darkgreen"
  49.     lbl_output.value = "You are... The " + hero + "."
  50.  
  51. # Your GUI widgets go here
  52. message1 = Text(box2, text="Choose an adjective")
  53. bgp_adjective = Combo(box2, options=["Amazing", "Bonny", "Charming", "Dude", "Effervescent"], selected="Amazing", width=20)
  54.  
  55. message2 = Text(box2, text="Enter a colour?")
  56. txt_colour = TextBox(box2, width=20)
  57.  
  58. message3 = Text(box2, text="Pick an animal")
  59. cmb_animal = ButtonGroup(box2, options=["Aardvark", "Badger", "Dolphin", "Velociraptor", "Goat"], selected="Aardvark", width=20)
  60.  
  61. message4 = Text(box2, text="Pick a code")
  62. listbox = ListBox(box2, items=["PLC", "LTD", "INC", "INDUSTRIES"], selected="PLC", width=80, height=80)
  63.  
  64. message5 = Text(box2, text="Choose a Thunderbird")
  65. slider = Slider(box2, start=1, end=5, width=200)
  66.  
  67. checkbox = CheckBox(box3, text="Dark Mode")
  68.  
  69. # Set up event triggers here
  70.  
  71. btn_make_name = PushButton(box3, text='Make me a hero', command=make_hero_name, width=20)
  72. btn_make_name.bg="lightgreen"
  73. lbl_output = Text(box3, text="A hero name will appear here")
  74.  
  75. # Show the GUI on the screen, start listening to events.
  76. app.display()
Advertisement
Add Comment
Please, Sign In to add comment