tabnation

python captcha gui

Mar 8th, 2025
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import messagebox
  3. from PIL import Image, ImageTk
  4.  
  5. def check_text():
  6. correct_string = "tabnation"
  7. user_input = entry.get()
  8. if user_input == correct_string:
  9. messagebox.showinfo("Result", "Correct!")
  10. else:
  11. messagebox.showerror("Result", "Incorrect!")
  12.  
  13. # Create main window
  14. root = tk.Tk()
  15. root.title("Image and Text Checker")
  16. root.geometry("400x400")
  17.  
  18. # Load and display image
  19. image_path = "CAPTCHA.png"
  20. image = Image.open(image_path)
  21. image = image.resize((280, 90))
  22. photo = ImageTk.PhotoImage(image)
  23.  
  24. image_label = tk.Label(root, image=photo)
  25. image_label.pack(pady=10)
  26.  
  27. # Create entry field
  28. entry = tk.Entry(root, font=("Arial", 14))
  29. entry.pack(pady=10)
  30.  
  31. # Create submit button
  32. submit_button = tk.Button(root, text="Submit", command=check_text)
  33. submit_button.pack(pady=10)
  34.  
  35. # Run the GUI loop
  36. root.mainloop()
  37.  
Advertisement
Add Comment
Please, Sign In to add comment