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
- app = App(title="Create a Hero Name")
- # Function definitions for your events go here.
- def make_hero_name():
- adjective = cmb_adjective.value
- color = txt_color.value
- animal = cmb_animal.value
- hero = adjective + " " + color + " "+ animal
- lbl_output.value = "You are... The " + hero + "."
- if cb_prettify.value == 1:
- lbl_output.text_color = "purple"
- else:
- lbl_output.text_color = "black"
- # Your GUI widgets go here
- message1 = Text(app, text="Choose an adjective")
- cmb_adjective = Combo(app, options=["Amazing", "Spectacular", "Incandescent", "Spooktacular", "Redonculus"], selected="Amazing")
- message2 = Text(app, text="Choose a color")
- txt_color = TextBox(app)
- message3 = Text(app, text="Pick an animal")
- cmb_animal = Combo(app, options=["Narwahl", "Jackalope", "Spider Monkey", "Poodle", "Crustacean"], selected="Crustacean")
- cb_prettify = CheckBox(app, text="Tick the checkbox to make it Pretty!")
- 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")
- # Show the GUI on the screen, start listening to events.
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement