Advertisement
Mori007

myheroassignment01

Feb 2nd, 2021
1,177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox
  2.  
  3. app = App(title='Make a hectic hero', layout='auto')
  4.  
  5. # Function
  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.     lbl_ouput.value = "You are... The " + hero + "."
  12.  
  13. message1 = Text(app, text='Choose an adjective...', size=12, font='Arial')
  14. cmb_adjective = Combo(app, options=["Amazing", "Bony", "Outgoing", "Funky, Bravely", "Strong"],selected="Amazing", width=15)
  15.  
  16. message2 = Text(app, text='Enter a color', size=12, font='Arial')
  17. txt_colour = TextBox(app)
  18. message3 = Text(app, text='Pick an animal', size=12, font='Arial')
  19. cmb_animal = Combo(app, options=["Aardvark", "Cat", "Dolphin", "Dog", "Tiger", "Velocipraptor"], selected="Aardvark", width=20)
  20.  
  21. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  22. lbl_ouput = Text(app, text="A hero name will appear here")
  23.  
  24. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement