Advertisement
mrFitzpatrick

AnimalHeroMaker_v2

Aug 2nd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.41 KB | None | 0 0
  1. from guizero import App, Text, PushButton, Combo, TextBox, ButtonGroup, Picture, info, CheckBox
  2.  
  3. app = App(title="Super Turbo Heromaker II - Championship Edition")
  4.  
  5. def size1():
  6.     app.width = 300
  7.     app.height = 180
  8.    
  9.     lbl_intro.visible = False
  10.     btn_ok.visible = False
  11.     if chk_darkMode.value == 1:
  12.         app.bg = 23,23,23
  13.         app.text_color = "white"
  14.     else:
  15.         app.bg = 255,50,0
  16.         app.text_colour = "black"
  17.     chk_darkMode.visible = False
  18.  
  19. def size2():
  20.     app.width = 300
  21.     app.height = 80
  22.    
  23.     lbl_adjective.visible = False
  24.     bgp_adjectives.visible = False
  25.     btn_adjective.visible = False
  26.     if chk_darkMode.value == 1:
  27.         app.bg = 23,23,23
  28.         app.text_color = "white"
  29.     else:
  30.         app.bg = 255,150,0
  31.         app.text_colour = "black"
  32.  
  33. def size3():
  34.     app.width = 300
  35.     app.height = 250
  36.    
  37.     lbl_colour.visible = False
  38.     cmb_colour.visible = False
  39.     btn_colour.visible = False
  40.     if chk_darkMode.value == 1:
  41.         app.bg = 23,23,23
  42.         app.text_color = "white"
  43.     else:
  44.         app.bg = 255,200,0
  45.         app.text_colour = "black"
  46.  
  47. def make_hero_name():
  48.     app.width = 500
  49.     adjective = bgp_adjectives.value
  50.     colour = cmb_colour.value
  51.     animal = bgp_animal.value
  52.     hero_name = adjective + " " + colour + " " + animal
  53.     lbl_output.text_color = cmb_colour.value
  54.     lbl_output.text_size = 20
  55.     lbl_output.value = "Behold, the " + hero_name + "!"
  56.  
  57. #pic_logo = Picture(app, image="superdog.png")
  58. app.bg = 255,0,0
  59. app.width = 300
  60. app.height = 90
  61. chk_darkMode = CheckBox(app, text="Enable Dark Mode")
  62. lbl_intro = Text(app, text="Ready to make your new hero?")
  63. btn_ok = PushButton(app, text="Let's go!", command=size1)
  64.    
  65. lbl_adjective = Text(app, text="Choose an adjective")
  66. bgp_adjectives = ButtonGroup(app, options=["Cheesy","Wobbly","Unfortunate","Slimey","Annoying"])
  67. btn_adjective = PushButton(app, text="ok", command=size2)
  68.  
  69. lbl_colour = Text(app, text="Now choose a colour")
  70. cmb_colour = Combo(app, options=["Yellow","Pink","Brown","Green"])
  71. btn_colour = PushButton(app, text="ok", command=size3)
  72.  
  73. lbl_animal = Text(app, text="Finally, choose an animal")
  74. bgp_animal = ButtonGroup(app, options=["Giraffe","Pig","Bear","Lizard"])
  75.  
  76. btn_generate_name = PushButton(app, text="Make me a hero!", command=make_hero_name)
  77. lbl_output = Text(app, text="A hero name will appear here")
  78.  
  79.  
  80.  
  81. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement