samedi 18 mars 2023

How to add image to a customtkinter checkbox?

So I'm trying to make a login page (using customtkinter), I finished most of the code but when it came to show password I wanted to add a image to the checkbox, I tired many methods but none of them worked for me either nothing happened or it throws an error.

This is the checkbox I'm trying to add the image to:

entry2 = ctk.CTkEntry(master=frame1, width=220, placeholder_text="Password", show="*", font=('Segoe Ui', 17))
entry2.pack(padx=10, pady=12)
entry2.place(relx=0.5, rely=login_form_y + 0.06, anchor=ctk.CENTER)

cb_va = ctk.IntVar(value=0)

def my_show():
    if cb_va.get() != 0:
        entry2.configure(show='')
    else:
        entry2.configure(show='*')

checkbox1 = ctk.CTkCheckBox(master=frame1, width=220, text="Show Password", font=('Segoe Ui', 12), variable=cb_va, onvalue=1, offvalue=0, command=my_show)
checkbox1.pack(padx=10, pady=12)
checkbox1.place(relx=0.5, rely=0.62, anchor=ctk.CENTER)

I just started using tkinter and customtkinter a few weeks back for my school project, so I have no idea what to do now.




Aucun commentaire:

Enregistrer un commentaire