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, TextBox, PushButton, Text, info
- app = App()
- # Function definitions for your events go here.
- def btn_go_clicked():
- info("Greetings", f"Hello, {txt_name.value}. You are {txt_age.value} years old.")
- def btn_year_clicked():
- year = 2020 - int(txt_age.value)
- info("Birth Year", f"You were born in {year} or possibly {year-1}.")
- # Your GUI widgets go here
- lbl_name = Text(app, text="Hello. What's your name?")
- txt_name = TextBox(app)
- lbl_age = Text(app,text="How old are you?")
- txt_age = TextBox(app)
- btn_go = PushButton(app, command=btn_go_clicked, text="Done")
- btn_date = PushButton(app, command=btn_year_clicked, text="Click me")
- # Show the GUI on the screen
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement