Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # guizero - Hero name generator
- from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox,ListBox
- app = App(title="Hero-o-matic",height=700, width=400)
- # Function definitions for your events go here.
- def pickhero(value):
- superhero_name.value = value
- def make_hero_name():
- superheroname = superhero_name.value
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = cmb_animal.value
- hero = adjective + " " + colour + " " + animal
- lbl_output.value = "You are " + superheroname + " . The " + hero + "."
- def night_or_day_mode():
- if darkmode.value == 1:
- app.bg = "black"
- app.text_color = "white"
- else:
- app.bg = "white"
- app.text_color = "black"
- # Your GUI widgets go here
- darkmode = CheckBox (app, text ="night mode", command = night_or_day_mode)
- message1 = Text(app, text="Choose an adjective")
- bgp_adjective = Combo(app, options=["Amazing", "Bonny", "Charming", "Delightful","Lovely"], selected="Bonny", width=20)
- message2 = Text(app, text="Enter a colour?")
- txt_colour = TextBox(app)
- message3 = Text(app, text="Pick an animal")
- cmb_animal = ButtonGroup(app, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor","Turtle","Dog"], selected="Turtle")
- questions_superhero = Text(app, text="Pick a name of superhero?")
- pick_superhero_name = ListBox(app, items=["supermum", "superdad", "superman"],command =pickhero )
- superhero_name = Text (app, text="Your pick superhero's name will appear here")
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement