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
- app = App(title="My Version of Hero-o-matic", width=720, height=480, bg="#ffcccc")
- # Function definitions for your events go here.
- def makeIt():
- heroName = tbx_nam.value+", the "+btg_adj.value+" "+tbx_col.value+" "+cmb_ani.value
- txt_output.value = heroName
- txt_output.show()
- # Your GUI widgets go here
- txt_title = Text(app,"Hero Name Generator", size=36)
- txt_nam = Text(app, text="Type your name:")
- tbx_nam = TextBox(app, width = 15)
- txt_adj = Text(app, text="Choose an adjective:")
- btg_adj = ButtonGroup(app, options=["Artful", "Brazen", "Confusing", "Droll", "Engaging"], selected="Amazing")
- txt_col = Text(app, text="Enter a colour:")
- tbx_col = TextBox(app, width = 15)
- txt_ani = Text(app, text="Pick an animal")
- cmb_ani = Combo(app, options=["Ankylosaurus", "Brachiosaurus", "Ceratosaurus", "Dimetrodon", "Einiosaurus"], selected="Aardvark", width=20)
- btn_makeName = PushButton(app, text='Make my hero name now',command=makeIt)
- txt_output = Text(app, text="Hero name will appear here", size=28)
- txt_output.hide()
- # 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