Advertisement
Mori007

MyreziseWIdget

Feb 7th, 2021
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, Box
  2.  
  3. app = App(title='Make a hectic hero', bg='yellow', layout='auto')
  4.  
  5. # Function
  6. def make_hero_name():
  7.     adjective = cmb_adjective.value
  8.     colour = txt_colour.value
  9.     animal = btg_animal.value
  10.     hero = adjective +" "+ colour +" "+ animal
  11.     lbl_ouput.value = "You are... The " + hero + "."
  12.  
  13.  
  14. message1 = Text(app, text='Choose an adjective...', size=12, font='Arial', color='blue')
  15. cmb_adjective = Combo(app, options=["Amazing", "Bony", "Outgoing", "Funky, Bravely", "Strong"],selected="Amazing", width=15)
  16.  
  17.  
  18. message2 = Text(app, text='Enter a color', size=12, font='Arial', color='green')
  19. txt_colour = TextBox(app)
  20.  
  21.  
  22. box1 = Box(app, width='fill')
  23. message3 = Text(box1, text='Pick an animal', size=12, font='Arial')
  24. btg_animal = ButtonGroup(box1, options=["Aardvark", "Cat", "Dolphin", "Dog", "Tiger", "Velocipraptor"], selected="Aardvark", width=20)
  25. box1.bg = 'red'
  26.  
  27. btn_make_name = PushButton(app, text='Make me a hero', width='35', height='1', command=make_hero_name,)
  28. btn_make_name.bg ='white'
  29. btn_make_name.text_size = '16'
  30. box2 = Box(app, width='fill', height='fill')
  31. lbl_ouput = Text(box2, text="A hero name will appear here", color='blue')
  32. lbl_ouput.font = 'Verdana'
  33.  
  34. box2.bg = "gray"
  35. box2.text_size = 16
  36.  
  37. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement