Advertisement
MarkO-FL

Untitled

Aug 19th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.68 KB | None | 0 0
  1. # W# guizero - Hero name generator
  2. from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, ListBox, Picture
  3. app = App(title="Hero-o-matic" , width=750, height=750)
  4.      
  5. welcome_message = Text(app, text= "HeroGen", size=25, font="Corbel",)
  6. secondmessage = Text(app, text="Bring your animal hero to life!", size=10, 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.     activity = lbox_activity.value
  14.     hero = adjective + " " + colour + " " + animal + " "
  15.     lbl_output.value = "You hero is called... The "  + hero + " " + "who " + lbox_activity.value + " "
  16.  
  17. # Your GUI widgets go here
  18. message1 = Text(app, text="Step 1: Choose an adjective", size=10, color="navyblue", font="Corbel")
  19. bgp_adjective = ButtonGroup(app, options=["strong", "brave", "confident",], selected="strong")
  20.  
  21. message2 = Text(app, text="Step 2: Enter a colour",size=10, color="navyblue", font="Corbel")
  22. txt_colour = TextBox(app)
  23.  
  24. message3 = Text(app, text="Step 3: Pick an animal", size=10, color="navyblue", font="Corbel")
  25. bgp_animal = ButtonGroup(app, options=["bear", "rabbit", "dog",], selected="bear")
  26.  
  27. message4 = Text(app, text="Step 4: Choose an activity", size=10, color="navyblue", font="Corbel")
  28. lbox_activity = ListBox(app, items=["runs", "swims", "climbs",], selected="runs")
  29.  
  30. btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
  31. lbl_output = Text(app, text="A hero name will appear here")
  32.  
  33.  
  34. # Set up event triggers here
  35.  
  36. # Show the GUI on the screen, start listening to events.
  37. app.display()# Write your code here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement