istvanrefle

Untitled

Dec 25th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, Box, PushButton, TextBox, ListBox, Slider
  3.  
  4. app = App(title="SuperHero 2.0", width=400, height=600)
  5.  
  6. # Function definitions for your events go here.
  7. def make_hero_name():
  8. rank = str(sld_ranking.value)
  9. adjective = bgp_adjective.value
  10. colour = txt_colour.value
  11. animal = cmb_animal.value
  12. physique = lst_physique.value
  13. hero = rank + ". " + adjective + " " + colour + " " + physique + " " + animal
  14. lbl_output.value = "You are... The " + hero + "."
  15.  
  16. def highlight():
  17. text_box.bg = "lightblue"
  18.  
  19. def lowlight():
  20. text_box.bg = "white"
  21.  
  22. # Your GUI widgets go here
  23. messageSlider = Text(app, text="Ranking")
  24. sld_ranking = Slider (app, start=1, end=5)
  25.  
  26. message1 = Text(app, text="Choose an adjective")
  27. bgp_adjective = ButtonGroup(app, options=["Amazing", "Bonny", "Charming", "Delightful"], selected="Amazing")
  28.  
  29. message2 = Text(app, text="Enter a colour?")
  30. txt_colour = TextBox(app)
  31.  
  32. message4 = Text(app, text="Choose a physique of Hero")
  33. lst_physique = ListBox(app, items=["Fitness", "Warrior", "Perfect", "Athletic", "Beautiful"], selected="Perfect")
  34.  
  35. message3 = Text(app, text="Pick an animal")
  36. cmb_animal = Combo(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor"], selected="Aardvark", width=20)
  37.  
  38. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  39. lbl_output = Text(app, text="A hero name will appear here")
  40.  
  41. # Set up event triggers here
  42.  
  43.  
  44.  
  45. # Show the GUI on the screen, start listening to events.
  46. app.display()# Write your code here :-)
  47. # Write your code here :-)
Advertisement
Add Comment
Please, Sign In to add comment