Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A GUIZero - The Super Splendiferous Superhero name generator (based on FutureLearn Course RPi Foundation)
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox
- app = App(title="The Super Splendiferous...", height=400, width=600)
- app.bg = 'yellow'
- app.font = 'Stencil'
- # Function definitions for your events go here.
- def make_hero_name():
- skin=""
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = cmb_animal.value
- print(chk_skin_fur.value)
- if chk_skin_fur.value == 1:
- skin = skin + "furry "
- if chk_skin_scaly.value == 1:
- skin = skin + "scaly "
- if chk_skin_slip.value == 1:
- skin = skin + "slippery "
- hero = adjective + " " + colour + " " + skin + animal
- lbl_output.value = "You are...The " + hero
- # Your GUI widgets go here
- message1 = Text(app, text="Choose your amazing adjective:")
- bgp_adjective = ButtonGroup(app, options=["Happy", "Flappy", "Snappy", "Clappy"], selected="Happy")
- message2 = Text(app, text="Colour:")
- txt_colour = TextBox(app)
- message3 = Text(app, text="Favourite animal:")
- cmb_animal = Combo(app, options=["Anteater", "Bandicote", "Coyote", "Duck", "Eagle", "Frog", "Gerbil", "Hyena", "Iguana", "Jellyfish", "Kakapo", "Llama", "Mole", "Newt"], selected="Anteater")
- message4 = Text(app, text="Skin Type:")
- chk_skin_fur = CheckBox(app, text="Furry ", command=make_hero_name)
- chk_skin_scaly = CheckBox(app, text="Scaly ", command=make_hero_name)
- chk_skin_slip = CheckBox(app, text="Slippery ", command=make_hero_name)
- btn_make_name = PushButton(app, text=' Go! ', command=make_hero_name)
- lbl_output = Text(app, text="Hero name being forged...um any moment now...", bg="red", color="yellow")
- # Show the GUI on the screen, start listening to events.
- app.display()
Add Comment
Please, Sign In to add comment