0

i'm try to make login/ register page in Tkinter (customTkinter). i want to add image captcha but idk why some times captcha show and some time not

from PIL import Image, ImageTk  
import customtkinter as ctk
import random,string,os,re,requests,time,customtkinter
from tempfile import mkdtemp
from captcha.image import ImageCaptcha

app = customtkinter.CTk() 
app.geometry("500x400")
app.title("Doux")
def main():
  image = ImageCaptcha(width = 280, height = 90)
  captcha_text = ''.join(random.choices(string.ascii_letters + string.digits, k=6))
  dir = mkdtemp()
  image.write(captcha_text, dir+ f"\\CAPTCHA-{captcha_text}.png")
  print(captcha_text)
  render = ImageTk.PhotoImage(Image.open(dir + f"/CAPTCHA-{captcha_text}.png").resize((280, 90), Image.Resampling.LANCZOS))
  img = ctk.CTkLabel(app, image=render)
  img.place(relx=0.5, rely=0.35, anchor='center')
app.mainloop()

https://i.stack.imgur.com/jijwR.png

God
  • 31
  • 1
  • 3
  • @DelriusEuphoria Euphoria no – God Jul 21 '22 at 12:53
  • What do you mean when you say no. Why does it not work. You have given us 100 lines of code and indicated no where for us to find the image code. – Delrius Euphoria Jul 21 '22 at 12:54
  • Please edit your question with a more precise problem statement and, in particular, a **short** (and complete) code example illustrating your issue. Have a look at https://stackoverflow.com/help/how-to-ask and https://stackoverflow.com/help/minimal-reproducible-example for tips. – j_4321 Jul 21 '22 at 13:46
  • i think its better now ! – God Jul 21 '22 at 17:21

0 Answers0