Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import the GUI widgets that you'll be using, and create the 'app' for your program.
- from guizero import App, Text, PushButton, TextBox, info,ButtonGroup,Combo
- app = App(title="Hero Name Generator",layout="grid")
- # Function definitions for your events go here.
- def btn_go_clicked():
- name = f"{bg_adjective.value} {txt_colour.value} {cbo_animal.value}"
- lbl_hero.value = name
- # Your GUI widgets go here
- lbl_adjective = Text(app, text="ADJECTIVE ",grid=[0,0],align="left")
- bg_adjective = ButtonGroup(app, options=["Amazing", "Happy", "Awesome","Grumpy"], grid=[1,0],align="left")
- lbl_filler1 = Text(app,text="",grid=[0,1])
- lbl_colour = Text(app,text="COLOUR",grid=[0,2],align="left")
- txt_colour = TextBox(app,grid=[1,2])
- lbl_colour_instruction = Text(app,text="Enter a colour",grid=[2,2],align="left")
- lbl_colour_instruction.text_color="grey"
- lbl_filler2 = Text(app,text="",grid=[0,3])
- lbl_animal = Text(app,text="ANIMAL",grid=[0,4],align="left")
- cbo_animal = Combo(app, options=["Chicken", "Cow", "Sheep", "Lion","Monkey"],grid=[1,4])
- lbl_filler3 = Text(app,text="",grid=[0,5])
- btn_go = PushButton(app, command=btn_go_clicked, width="30",text="Go",grid=[0,6,3,1])
- lbl_filler4 = Text(app,text="",grid=[0,7])
- lbl_hero = Text(app,text="",grid=[0,8,3,2])
- lbl_hero.text_color="red"
- # Show the GUI on the screen
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement