Advertisement
MarkO-FL

Untitled

Aug 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 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", width=500, height =500, bg="orange",)
  4.  
  5. welcome_message = Text(app, text="HeroGen", size=25, font="Corbel", color="white")
  6. secondmessage = Text(app, text="Bring your animal hero to life!", color="white", font="Corbel")
  7.  
  8. # Function definitions for your events go here.
  9. def make_hero_name():
  10.     adjective = bgp_adjective.value
  11.     colour = txt_colour.value
  12.     animal = bgp_animal.value
  13.     verb = bgp_verb.value
  14.     hero = adjective + " " + verb + " " + colour + " " + animal + " "
  15.     lbl_output.value = "Your hero is - The "+ hero + " "
  16.  
  17. # Your GUI widgets go here
  18. message1 = Text(app, text="Step 1: Choose an adjective", font="Corbel" )
  19. bgp_adjective = ButtonGroup(app, options=["strong", "brave", "confident",], selected="strong")
  20.  
  21. message2 = Text(app, text="Step 2: Enter a colour", font="Corbel" , )
  22. txt_colour = TextBox(app)
  23.  
  24. message3 = Text(app, text="Step 3: Pick an animal", font="Corbel" )
  25. bgp_animal = ButtonGroup(app, options=["bear", "rabbit", "dog",], selected="bear")
  26.  
  27. message4 = Text(app, text="Step 3: Choose a verb" ,font="Corbel" )
  28. bgp_verb = ButtonGroup(app, options=["running", "swimming", "climbing",], selected="running")
  29.  
  30. # Set up event triggers here
  31. box =Box(app)
  32. box.bg ="white"
  33. btn_make_name = PushButton(box, text='Click to create your hero', command=make_hero_name,)
  34. lbl_output = Text(app, text="A hero name will appear here", bg="yellow", font="Corbel", size="15" )
  35.  
  36. # Show the GUI on the screen, start listening to events.
  37. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement