Advertisement
Mori007

myheroassignment02

Feb 2nd, 2021
1,232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox
  2.  
  3. app = App(title='Make a hectic hero', layout='auto')
  4.  
  5. # Function of the Hero animal
  6. def make_hero_name():
  7.     adjective = cmb_adjective.value
  8.     colour = txt_colour.value
  9.     animal = cmb_animal.value
  10.     hero = adjective +" "+ colour +" "+ animal
  11.     if check_animaly.value == 1 :
  12.         side =" You are good on choosing animal"
  13.     if check_animaln.value == 1:
  14.         side =" You are bad on choosing animal"
  15.     lbl_ouput.value = "You are... The " + hero + "\n"+side
  16.  
  17. # Widget that use
  18. message1 = Text(app, text='Choose an adjective...', size=12, font='Arial')
  19. cmb_adjective = Combo(app, options=["Amazing", "Bony", "Outgoing", "Funky, Bravely", "Strong"],selected="Amazing", width=15)
  20.  
  21. message2 = Text(app, text='Enter a color', size=12, font='Arial')
  22. txt_colour = TextBox(app)
  23. message3 = Text(app, text='Pick an animal', size=12, font='Arial')
  24. cmb_animal = Combo(app, options=["Aardvark", "Cat", "Dolphin", "Dog", "Tiger", "Velocipraptor"], selected="Aardvark", width=20)
  25. message4 = Text(app, text='Are animal friendly ?', size=12, font='Arial')
  26. check_animaly = CheckBox(app, text='Yes')
  27. check_animaln = CheckBox(app, text='No')
  28.  
  29. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  30. lbl_ouput = Text(app, text="A hero name will appear here")
  31.  
  32. # Display to the screen
  33. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement