Advertisement
davidhellam

Python: Hero-o-matic 1

Aug 10th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. # guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox
  3.  
  4. app = App(title="My Version of Hero-o-matic", width=720, height=480, bg="#ffcccc")
  5.  
  6. # Function definitions for your events go here.
  7.  
  8. def makeIt():
  9.     heroName = tbx_nam.value+", the "+btg_adj.value+" "+tbx_col.value+" "+cmb_ani.value
  10.     txt_output.value = heroName
  11.     txt_output.show()
  12.  
  13. # Your GUI widgets go here
  14. txt_title = Text(app,"Hero Name Generator", size=36)
  15.  
  16. txt_nam = Text(app, text="Type your name:")
  17. tbx_nam = TextBox(app, width = 15)
  18.  
  19. txt_adj = Text(app, text="Choose an adjective:")
  20. btg_adj = ButtonGroup(app, options=["Artful", "Brazen", "Confusing", "Droll", "Engaging"], selected="Amazing")
  21.  
  22. txt_col = Text(app, text="Enter a colour:")
  23. tbx_col = TextBox(app, width = 15)
  24.  
  25. txt_ani = Text(app, text="Pick an animal")
  26. cmb_ani = Combo(app, options=["Ankylosaurus", "Brachiosaurus", "Ceratosaurus", "Dimetrodon", "Einiosaurus"], selected="Aardvark", width=20)
  27.  
  28. btn_makeName = PushButton(app, text='Make my hero name now',command=makeIt)
  29. txt_output = Text(app, text="Hero name will appear here", size=28)
  30. txt_output.hide()
  31. # Set up event triggers here
  32.  
  33. # Show the GUI on the screen, start listening to events.
  34. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement