- 2

text based captcha using python

How to create a simple text based captcha on python GUI interface?

2nd Nov 2016, 1:19 PM
Sarthak Sahoo
5 Respuestas
+ 1
from tkinter import * import random master=Tk() images=[PhotoImage("img1.gif"),PhotoImage("img2.gif")] words=["word1","word2"] ran=random.randint(0,1) captcha=Label(master,image=images[ran]) captcha.pack() entry=Entry(master) entry.pack() def check(): if entry.get() == words[ran]: master.destroy() print("correct") else: ran=random.randint(0,1) captcha["image"]=images[ran] button=Button(master,command=check) button.pack()
16th Feb 2017, 1:37 PM
Cameron Green
Cameron Green - avatar
0
you could create multiple images of the text for the captcha then randomly select one and have a entry box then have a button that gets the value from the entry box and if the value equals the text from the image then your done if not another randomly generated image pops up
16th Feb 2017, 1:25 PM
Cameron Green
Cameron Green - avatar
0
from tkinter import * import random master=Tk() l1=PhotoImage(file="C:\\Users\\hp\\Desktop\\imagename1.png") l2=PhotoImage(file="C:\\Users\\hp\\Desktop\\imagename2.png") o=l1.subsample(10,10) images=[o,l2] words=["qGphJ","83tsu"] ran=random.randint(0,1) captcha=Label(master,image=images[ran]) captcha.pack() entry=Entry(master) entry.pack() def check(): if entry.get() == words[ran]: master.destroy() print("correct") else: ran1=random.randint(0,1) captcha["image"]=images[ran1] button=Button(master,command=check,text="submit") button.pack() master.mainloop() #Lpu punjab
26th Sep 2018, 1:34 PM
yash
yash - avatar
0
hey! please can you explain me this code
12th Oct 2018, 1:33 PM
Ankit Soni
0
from where u belongs to
12th Oct 2018, 2:02 PM
yash
yash - avatar