JAWarr

Hero Name Creator V2

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