5 Réponses
+ 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()
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
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
0
hey! please can you explain me this code
0
from where u belongs to