JAWarr

Hero Name Creator V2.2

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