Advertisement
kalpin

GuiZero2

Aug 3rd, 2020
1,485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # Import the GUI widgets that you'll be using, and create the 'app' for your program.
  2. from guizero import App, TextBox, PushButton, Text, info
  3. app = App()
  4.  
  5. # Function definitions for your events go here.
  6. def btn_go_clicked():
  7.     info("Greetings", f"Hello, {txt_name.value}. You are {txt_age.value} years old.")
  8.    
  9. def btn_year_clicked():
  10.     year = 2020 - int(txt_age.value)
  11.     info("Birth Year", f"You were born in {year} or possibly {year-1}.")
  12.    
  13.        
  14.  
  15. # Your GUI widgets go here
  16. lbl_name = Text(app, text="Hello. What's your name?")
  17. txt_name = TextBox(app)
  18. lbl_age = Text(app,text="How old are you?")
  19. txt_age = TextBox(app)
  20. btn_go = PushButton(app, command=btn_go_clicked, text="Done")
  21. btn_date = PushButton(app, command=btn_year_clicked, text="Click me")
  22. # Show the GUI on the screen
  23. app.display()
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement