Advertisement
scipiguy

GUIZero sample App

Oct 28th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 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","Hello, " + txt_name.value + " - I hope you're having a nice day\nYou like " + txt_biscuit.value + "s apparently!")
  8.    
  9. def btn_joke_clicked():
  10.     info("Joke!", "Hey, " + txt_name.value + " what is brown and sticky?  A stick!")
  11.  
  12. # Your GUI widgets go here
  13. lbl_name = Text(app, text="Hello. What's your name?")
  14. txt_name = TextBox(app)
  15. lbl_biscuit = Text(app, text="What's your favourite biscuit?")
  16. txt_biscuit = TextBox(app)
  17.  
  18. btn_go = PushButton(app, command=btn_go_clicked, text="Done")
  19.  
  20. btn_joke = PushButton(app, command=btn_joke_clicked, text="Tell a joke")
  21.  
  22. # Show the GUI on the screen
  23. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement