'Tkinter checkbox to negate asterisks in entry field
I have an entry field meant for passwords like this:
Input = Entry(MainWindow, show="*")
It hides whatever you type. I created a checkbox "show password" that when pressed, is supposed to reveal what is in the entry box.
CheckBox = Checkbutton(MainWindow, text="Show password", variable=Checked, command=Stars)
Where the function Stars is meant to turn on or off the aterisks in the entry field. I'm having trouble writing the function Stars and making it do what I want.
I tried
def Stars():
print("check box")
if (Checked.get()):
Input.config(show=None)
else:
Input.config(show="*")
Any ideas?
Solution 1:[1]
Try with:
def Stars():
Input.config(show='')
Solution 2:[2]
Same situation here, this code worked for me:
def stars():
Input.config(show="")
if (Checked.get()):
Input.config(show=None)
else:
Input.config(show="*")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pier Paolo |
Solution 2 | Tyler2P |