# A GUIZero - The Super Splendiferous Superhero name generator (based on FutureLearn Course RPi Foundation) from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, Slider, Picture, ListBox app = App(title="The Super Splendiferous...", height=800, width=700) app.bg = 'yellow' app.text_color = "black" app.font = 'Stencil' dark_light = 1 # Function definitions for my events here def make_hero_name(): skin="" adjective = bgp_adjective.value colour = txt_colour.value animal = cmb_animal.value generation = sli_gen.value birthplace = lstbox_plcbirth.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 + " " + str(generation) + " of " + birthplace lbl_output.value = "You are...The " + hero #Pushbutton that sets dark or light mode def dark_light_mode(): global dark_light if dark_light == 1: dark_light = dark_light * -1 app.bg = 'black' app.text_color = 'yellow' else: dark_light = dark_light * -1 app.bg = 'yellow' app.text_color = 'black' # My GUI widgets here btn_make_name = PushButton(app, text=' Dark\Light Mode ', command=dark_light_mode) message1 = Text(app, text="Choose your amazing adjective:") bgp_adjective = ButtonGroup(app, options=["Happy", "Flappy", "Snappy", "Clappy"], selected="Happy", command=make_hero_name) message2 = Text(app, text="Colour:") txt_colour = TextBox(app, command=make_hero_name) 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", command=make_hero_name) 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) message5 = Text(app, text="Generation:") sli_gen = Slider(app, start=1, end=3, command=make_hero_name) message6 = Text(app, text="Place of Birth:") lstbox_plcbirth = ListBox(app, items=["Birmingham","Cambridge", "Cheltenham", "Dundee", "Ely", "London", "Newcastle", "Peterborough", "Potton", "Safron Waldon"], selected="Birmingham", 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") #Make sure the GIF image is in the same folder as this Python file picture = Picture(app, image='superhero2.gif') # Show the GUI on the screen, start listening to events. app.display()