Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # guizero - Hero name generator
- from guizero import App, Box, Text, ButtonGroup, Combo, PushButton, TextBox, CheckBox, ListBox, Picture
- app = App(title="Hero-o-matic",width=500, height=500)
- box1 = Box(app, align="top", width="fill", height=240, border=0)
- box2 = Box(app, align="right", width="fill", height="fill", border=2)
- box3 = Box(app, align="bottom", width="fill", border=3)
- box4 = Box(app, align="bottom", width=125, height=90, border=4)
- picture = Picture(box1, image="fig2.PNG")
- # Function definitions for your events go here.
- def make_hero_name():
- superb=""
- adjective = bgp_adjective.value
- colour = txt_colour.value
- animal = cmb_animal.value
- hero = adjective + " " + colour + " " + animal
- eat =listbox.value
- if checkbox.value==1:
- superb=" superb"
- lbl_output.value = "You are"+superb+"... The " + hero + " that likes to eat "+ eat + "."
- def make_darkmode():
- if darkmode.value==1:
- app.bg="black"
- app.text_color="white"
- else:
- app.bg="gray"
- app.text_color="black"
- # Your GUI widgets go here
- message1 = Text(box2, text="Choose an adjective")
- bgp_adjective = Combo(box2, options=["Amazing", "Bonny", "Charming", "Delightful", "Dangerous","Dierce"], selected="Amazing", width=20, align="center")
- message2 = Text(box3, text="Enter a colour?")
- txt_colour = TextBox(box3)
- message3 = Text(box2, text="Pick an animal",align="left")
- cmb_animal = ButtonGroup(box2, options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor"], selected="Aardvark",align="left")
- btn_make_name = PushButton(box1, text='Make me a hero', command=make_hero_name)
- lbl_output = Text(box1, text="A hero name will appear here")
- checkbox = CheckBox(app, text="Superb")
- listbox = ListBox(box2, items=["Beef", "Chicken", "Fish", "Vegetarian"], scrollbar=True, height="fill", align="right")
- darkmode = CheckBox(box3, text="DarkMode",command=make_darkmode)
- # 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