Make password input box using Tkinter.

I met python about 5 or 6 years ago, but I have never written a code using Tkinter.
Main reason is that I often call function from CUI or Web UI, so I didn’t need GUI.
But, some days ago, I want to make a plugin that need password box GUI.
So, I searched google and found good solution.
tkSimpleDialog provides simple but sufficient GUI.
Snippet is following.

from __future__ import print_function
import Tkinter, tkSimpleDialog
root = Tkinter.Tk()
# set option show = '*'
# That's all !
pswd = tkSimpleDialog.askstring( title = 'PSWDBOX', prompt='Input pwsd!', show ='*' )

pswd can get user input and input string is masked “*”.
😉

Advertisements