Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # guizero - Hero name generator - John Warr 15/08/2020 Boxes Version 2
- from guizero import *
- app = App(title="Hero-o-matic V2", width=800, height=800, layout="auto", visible=True)
- box1 = Box(app, align="top", width="fill", height="fill", border=2)
- box1.bg="green"
- box2 = Box(app, align="top", width="fill", height="fill", border=2)
- box2.bg="orange"
- box3 = Box(app, align="top", width="fill", height="fill", border=2)
- box3.bg="red"
- box3.text_size=18
- picture = Picture(box1, image="DAVE2.GIF")
- # Function definitions for your events go here.
- def make_hero_name():
- #dark mode
- if checkbox.value == 1:
- app.bg="black"
- app.text_color="yellow"
- else:
- box1.bg="green"
- box2.bg="orange"
- box3.bg="red"
- app.text_color="black"
- # hero options
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = cmb_animal.value
- code = listbox.value
- #slider options
- if slider.value == 1:
- tbird ="1"
- elif slider.value == 2:
- tbird ="2"
- elif slider.value == 3:
- tbird ="3"
- elif slider.value == 4:
- tbird ="4"
- else:
- tbird="5"
- #output
- hero = adjective + " " + colour.capitalize() + " " + animal + " " + code + " of Thunderbird " + tbird
- lbl_output.text_color = "darkgreen"
- lbl_output.value = "You are... The " + hero + "."
- # Your GUI widgets go here
- message1 = Text(box2, text="Choose an adjective")
- bgp_adjective = Combo(box2, options=["Amazing", "Bonny", "Charming", "Dude", "Effervescent"], selected="Amazing", width=20)
- message2 = Text(box2, text="Enter a colour?")
- txt_colour = TextBox(box2, width=20)
- message3 = Text(box2, text="Pick an animal")
- cmb_animal = ButtonGroup(box2, options=["Aardvark", "Badger", "Dolphin", "Velociraptor", "Goat"], selected="Aardvark", width=20)
- message4 = Text(box2, text="Pick a code")
- listbox = ListBox(box2, items=["PLC", "LTD", "INC", "INDUSTRIES"], selected="PLC", width=80, height=80)
- message5 = Text(box2, text="Choose a Thunderbird")
- slider = Slider(box2, start=1, end=5, width=200)
- checkbox = CheckBox(box3, text="Dark Mode")
- # Set up event triggers here
- btn_make_name = PushButton(box3, text='Make me a hero', command=make_hero_name, width=20)
- btn_make_name.bg="lightgreen"
- lbl_output = Text(box3, 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