I'm learning Python3 and tkinter. I was trying to show password with binding <Button>
and hide password with binding <ButtonRelease>
, but I didn't have any solution. All I can do is to show the password, then the error occurred:
Here is my code:
import tkinter as tk
def show(e):
passwd_entry.config(show="")
# def hide(event):
# passwd_entry.config(show="*")
root = tk.Tk()
passwd_entry = tk.Entry(root, show='*', width=20)
passwd_entry.pack(side=tk.LEFT)
toggle_btn = tk.Button(root, text='Show Password', width=15, command=show)
toggle_btn.pack(side=tk.LEFT)
toggle_btn.bind("<Button>", show)
# toggle_btn.bind("<ButtonRelease>", hide)
root.mainloop()
This is the error when I click button
:
TypeError: show() missing 1 required positional argument: 'e'