Advertisement
zhongnaomi

gui 9

Jan 2nd, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, Box
  3. app = App(title="Hero-o-matic")
  4.  
  5. # Function definitions for your events go here.
  6. def make_hero_name():
  7.     adjective = bgp_adjective.value
  8.     colour = txt_colour.value
  9.     animal = cmb_animal.value
  10.     hero = adjective + " " + colour + " " + animal
  11.     lbl_output.value = "You are... The " + hero + "."
  12. # Your GUI widgets go here
  13.    
  14. box1 = Box(app, align="centre", width="fill", border=1)
  15. message1 = Text(box1, text="Choose an adjective")
  16. bgp_adjective = ButtonGroup(box1, options=["Amazing", "Bonny", "Charming", "Delightful","funny","lovely"], selected="Amazing")
  17. box2 = Box(app, align="centre", width="fill", border=1)
  18. message2 = Text(box2, text="Enter a colour?")
  19. txt_colour = TextBox(box2)
  20. box3 = Box(app, align="centre", width="fill", border=1)
  21. message3 = Text(box3, text="Pick an animal")
  22. cmb_animal = Combo(box3, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor","tutle","dog"], selected="Aardvark", width=20)
  23. box4 = Box(app, align="centre", width="fill", border=1)
  24. box4.font="Bookman Old Style"
  25. btn_make_name = PushButton(box4, text='Make me a hero',command=make_hero_name)
  26. btn_make_name.bg = "pink"
  27. box5 = Box(app, align="centre", width="fill", border=1)
  28. box5.bg="green"
  29. box5.text_size = 15
  30. lbl_output = Text(box5, text="A hero name will appear here")
  31.  
  32. # Set up event triggers here
  33.  
  34.  
  35. # Show the GUI on the screen, start listening to events.
  36. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement