Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # W# guizero - Hero name generator
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, ListBox, Picture
- app = App(title="Hero-o-matic" , width=750, height=750)
- welcome_message = Text(app, text= "HeroGen", size=25, font="Corbel",)
- secondmessage = Text(app, text="Bring your animal hero to life!", size=10, font="Corbel")
- # Function definitions for your events go here.
- def make_hero_name():
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = bgp_animal.value
- activity = lbox_activity.value
- hero = adjective + " " + colour + " " + animal + " "
- lbl_output.value = "You hero is called... The " + hero + " " + "who " + lbox_activity.value + " "
- # Your GUI widgets go here
- message1 = Text(app, text="Step 1: Choose an adjective", size=10, color="navyblue", font="Corbel")
- bgp_adjective = ButtonGroup(app, options=["strong", "brave", "confident",], selected="strong")
- message2 = Text(app, text="Step 2: Enter a colour",size=10, color="navyblue", font="Corbel")
- txt_colour = TextBox(app)
- message3 = Text(app, text="Step 3: Pick an animal", size=10, color="navyblue", font="Corbel")
- bgp_animal = ButtonGroup(app, options=["bear", "rabbit", "dog",], selected="bear")
- message4 = Text(app, text="Step 4: Choose an activity", size=10, color="navyblue", font="Corbel")
- lbox_activity = ListBox(app, items=["runs", "swims", "climbs",], selected="runs")
- btn_make_name = PushButton(app, text='Make me a hero', command=make_hero_name)
- lbl_output = Text(app, text="A hero name will appear here")
- # Set up event triggers here
- # Show the GUI on the screen, start listening to events.
- app.display()# Write your code here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement