Advertisement
kalpin

HeroGenerator

Aug 3rd, 2020
1,568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. # Import the GUI widgets that you'll be using, and create the 'app' for your program.
  2. from guizero import App, Text, PushButton, TextBox, info,ButtonGroup,Combo
  3.  
  4. app = App(title="Hero Name Generator",layout="grid")
  5.  
  6.  
  7. # Function definitions for your events go here.
  8. def btn_go_clicked():
  9.     name = f"{bg_adjective.value} {txt_colour.value} {cbo_animal.value}"
  10.     lbl_hero.value = name
  11.    
  12.    
  13. # Your GUI widgets go here
  14. lbl_adjective = Text(app, text="ADJECTIVE    ",grid=[0,0],align="left")
  15. bg_adjective = ButtonGroup(app, options=["Amazing", "Happy", "Awesome","Grumpy"], grid=[1,0],align="left")
  16. lbl_filler1 = Text(app,text="",grid=[0,1])
  17.  
  18. lbl_colour = Text(app,text="COLOUR",grid=[0,2],align="left")
  19. txt_colour = TextBox(app,grid=[1,2])
  20. lbl_colour_instruction = Text(app,text="Enter a colour",grid=[2,2],align="left")
  21. lbl_colour_instruction.text_color="grey"
  22. lbl_filler2 = Text(app,text="",grid=[0,3])
  23.  
  24. lbl_animal = Text(app,text="ANIMAL",grid=[0,4],align="left")
  25. cbo_animal = Combo(app, options=["Chicken", "Cow", "Sheep", "Lion","Monkey"],grid=[1,4])
  26. lbl_filler3 = Text(app,text="",grid=[0,5])
  27.  
  28. btn_go = PushButton(app, command=btn_go_clicked, width="30",text="Go",grid=[0,6,3,1])
  29. lbl_filler4 = Text(app,text="",grid=[0,7])
  30.  
  31. lbl_hero = Text(app,text="",grid=[0,8,3,2])
  32. lbl_hero.text_color="red"
  33.  
  34.  
  35. # Show the GUI on the screen
  36. app.display()
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement