crzcas

GUI superhero generator

Mar 3rd, 2021
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox
  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.     adjective = combo_adjective.value
  9.     colour = txt_colour.value
  10.     animal = cmb_animal.value
  11.     hero = adjective + " " + colour + " " + animal
  12.     lbl_output.value = "You are... The " + hero + "."
  13.  
  14. # Your GUI widgets go here
  15. message1 = Text(app, text="Choose an adjective")
  16.  
  17. combo_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Delightful", "Wonderful", "Surprising"], selected="Amazing")
  18.  
  19. message2 = Text(app, text="Enter a colour?")
  20. txt_colour = TextBox(app)
  21.  
  22. message3 = Text(app, text="Pick an animal")
  23. cmb_animal = Combo(app, options=["Aardvark", "Cat", "Dolphin", "Tiger", "Velociraptor", "Walrus"], selected="Aardvark", width=20)
  24.  
  25. # Set up event triggers here
  26. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  27. lbl_output = Text(app, text="A hero name will appear here")
  28.  
  29. # Show the GUI on the screen, start listening to events.
  30. app.display()
Advertisement
Add Comment
Please, Sign In to add comment