Advertisement
xavicano

Untitled

Jul 30th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 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.  
  7. def make_hero_name():
  8.     superb=""
  9.     adjective = bgp_adjective.value
  10.     colour = txt_colour.value
  11.     animal = cmb_animal.value
  12.     hero = adjective + " " + colour + " " + animal
  13.     if checkbox.value==1:
  14.         superb=" superb"    
  15.     lbl_output.value = "You are"+superb+"... The " + hero + "."
  16.  
  17.  
  18. # Your GUI widgets go here
  19. message1 = Text(app, text="Choose an adjective")
  20. bgp_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Delightful", "Dangerous","Dierce"], selected="Amazing", width=20)
  21.  
  22. message2 = Text(app, text="Enter a colour?")
  23. txt_colour = TextBox(app)
  24.  
  25. message3 = Text(app, text="Pick an animal")
  26. cmb_animal = ButtonGroup(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor"], selected="Aardvark")
  27.  
  28. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  29. lbl_output = Text(app, text="A hero name will appear here")
  30.  
  31. checkbox = CheckBox(app, text="Superb")
  32.  
  33. # Set up event triggers here
  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