Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import messagebox
- from PIL import Image, ImageTk
- def check_text():
- correct_string = "tabnation"
- user_input = entry.get()
- if user_input == correct_string:
- messagebox.showinfo("Result", "Correct!")
- else:
- messagebox.showerror("Result", "Incorrect!")
- # Create main window
- root = tk.Tk()
- root.title("Image and Text Checker")
- root.geometry("400x400")
- # Load and display image
- image_path = "CAPTCHA.png"
- image = Image.open(image_path)
- image = image.resize((280, 90))
- photo = ImageTk.PhotoImage(image)
- image_label = tk.Label(root, image=photo)
- image_label.pack(pady=10)
- # Create entry field
- entry = tk.Entry(root, font=("Arial", 14))
- entry.pack(pady=10)
- # Create submit button
- submit_button = tk.Button(root, text="Submit", command=check_text)
- submit_button.pack(pady=10)
- # Run the GUI loop
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment