Can't find any info about how to make password visible or hide with Custom Tkinter.
import tkinter as tk
import customtkinter
def toggle_password():
if txt.cget('show') == '':
txt.config(show='*')
else:
txt.config(show='')
root = tk.Tk()
root.geometry("200x200")
txt = customtkinter.CTkEntry(root, width=20)
txt.pack()
toggle_btn = customtkinter.CTkButton(root, text='Show Password', width=15, command=toggle_password)
toggle_btn.pack()
root.mainloop()
CodePudding user response:
The show
method isn't directly supported by the CtkEntry
widget. You will need to configure the Entry
widget that is internal to the CtkEntry
widget.
def toggle_password():
if txt.entry.cget('show') == '':
txt.entry.config(show='*')
else:
txt.entry.config(show='')