无法找到任何信息,如何使密码可见或隐藏与自定义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()发布于 2022-11-27 14:07:02
show方法不直接受CtkEntry小部件的支持。您需要配置Entry小部件,它是CtkEntry小部件的内部部件。
def toggle_password():
if txt.entry.cget('show') == '':
txt.entry.config(show='*')
else:
txt.entry.config(show='')https://stackoverflow.com/questions/74590427
复制相似问题