maroph icon

heroname.py

maroph | PRO | 12/06/19 04:50:15 PM UTC | 0 ⭐ | 365 👁️ | Never ⏰ | []
Python |

1 KB

|

None

|

0 👍

/

0 👎

from guizero import App, ButtonGroup, CheckBox, Combo, info, PushButton, Text
 
app = App(title="Hero name generator")
 
 
def btn_go_clicked():
    if checkbox.value == 1:
        name = "Your SUPER hero name"
    else:
        name = "Your hero name"
    info(name, bg_adjective.value + " " + combo_color.value + " " + combo_animal.value)
 
 
lbl_adjective = Text(app, text="Choose an adjective...")
bg_adjective = ButtonGroup(app, options=["Busy", "Crazy", "Crying", "Funny", "Happy", "Lazy", "Powerful"], selected="Powerful")
 
lbl_color = Text(app, text="Enter a color...")
combo_color = Combo(app, options=["Black", "Blue", "Green", "Red", "Pink", "Yellow", "Violet"], selected="Pink")
 
lbl_animal = Text(app, text="Pick an animal...")
combo_animal = Combo(app, options=["Bear", "Deer", "Hamster", "Panther", "Skunk", "Snake"], selected="Hamster")
 
checkbox = CheckBox(app, text="Add SUPER to hero to name")
 
btn_go = PushButton(app, command=btn_go_clicked, text="Generate hero name")
 
app.display()

Comments