Advertisement
Vesna_To

GUI2

Aug 3rd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 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. " +txt_pet.value + " is a nice name for a pet :)")
  8. def btn_cat_clicked():
  9. info("Message", "Nice. Cats are very playful! ")
  10. def btn_dog_clicked():
  11. info("Message","Lovely! Dogs are faithful animals :) ")
  12. def btn_other_clicked():
  13. info("Message", "Wow...Now I'm curious...")
  14. # Your GUI widgets go here
  15. lbl_name = Text(app, text="Hello. What's your name?")
  16. txt_name = TextBox(app)
  17. lbl_pet = Text(app, text="What's your pet's name?")
  18. txt_pet = TextBox(app)
  19. btn_go = PushButton(app, command=btn_go_clicked, text="Done")
  20. lbl_pet = Text(app, text="Is your pet a cat, dog or other animal?")
  21. btn_cat =PushButton(app, command=btn_cat_clicked, text="Cat")
  22. btn_dog =PushButton(app, command=btn_dog_clicked, text="Dog")
  23. btn_other =PushButton(app, command=btn_other_clicked, text="Other")
  24.  
  25. # Show the GUI on the screen
  26. app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement