剛剛學tkinter,想要完成的功能為:想用checkbutton組件勾選顯示密碼后便讓*號顯示出原來的密碼,打掉對號后又變回*號,但是用函式后,StringVar型別的appearVar變數不能承載None,所以導致顯示密碼后所有*變為1,求個大神指點江山。
#密碼標簽和entry標簽
tk.Label(window, text='密碼:').place(x=120, y=140)
var_user_pwd = tk.StringVar()
enter_user_pwd = tk.Entry(window, textvariable=var_user_pwd, show='*')
enter_user_pwd.place(x=160, y=140)
appearVar=tk.StringVar()
appearVar.set('*')
def change_show():
enter_user_pwd.config(show=(appearVar.get())
#顯示密碼
bt_appear=tk.Checkbutton(window,text='顯示密碼',variable=appearVar,onvalue=https://bbs.csdn.net/topics/None,offvalue='*',command=change_show)
bt_appear.place(x=310,y=137)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/235758.html
標籤:其他開發語言
上一篇:scrapy.cfg報錯
