代码语言:javascript复制
import PySimpleGUI as sg
if __name__ == '__main__':
layout = [
[sg.InputText('123456', password_char='*', key='pwd_input'), sg.Button('显示', key='show_pwd')]
]
window = sg.Window('密码框', layout)
flag = True
while True:
event, values = window.read()
if event in 'show_pwd':
if flag:
window.find_element('show_pwd').update('隐藏')
window.find_element('pwd_input').update(password_char='')
flag = False
else:
window.find_element('show_pwd').update('显示')
window.find_element('pwd_input').update(password_char='*')
flag = True
有谁知道PySimpleGUI动态更新input元素的密码字符,一开始是*,我想点击眼睛显示密码,再次点击变回*?
pysimplegui部分源码
它报关键字不匹对,查看pysimplegui的源码属性是PasswordCharacter但试了还是没用,求大神指导,困扰我好久了