JDpaste

Python GUI guizero: demo text fields match

Sep 23rd, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. # This Python code is a demo of the GUI guizero (with PushButton trigger)
  2. # guizero works with tkinter but simpler with extra widgets eg. Slider
  3. # https://lawsie.github.io/guizero/slider/
  4. # passTwice.py
  5. # Test if text fields match.
  6.  
  7. # Import the GUI widgets that you'll be using, and create the 'app' for your program.
  8. from guizero import App, TextBox, PushButton, Text, info
  9. app = App( title="Password checker", bg = "#FFFF00", height = 400, width = 600 )
  10. #-------------------------------------
  11. # Function definitions for your events go here.
  12. def btn_go_clicked():
  13.     if (txt_pwA.value == ""):
  14.         info("Password","Password field is empty")
  15.     else:
  16.         if (txt_pwA.value == txt_pwB.value):
  17.             info("Password","Passwords match OK")
  18.         else:
  19.             info("Password","Passwords DO NOT MATCH")
  20. #-----------------
  21. # Your GUI widgets go here
  22. h1 = Text(app, text="Password checker")
  23.  
  24. h2_A = Text(app, text="Please enter your chosen password ..")
  25. txt_pwA = TextBox(app)
  26. h2_B  = Text(app, text="Please re-enter your password ..")
  27. txt_pwB = TextBox(app)
  28.  
  29. btn_go = PushButton(app, command=btn_go_clicked, text="Test for text match ..", padx=8,pady=7)
  30.  
  31. # change parameters of widgets
  32. # -- adjust --
  33. h1.text_size = 30
  34. h1.text_color = "#56789A"
  35.  
  36. btn_go.bg="#33FF55"
  37.  
  38. #----------
  39. app.display()  # Show the GUI on the screen
Add Comment
Please, Sign In to add comment