Skip to content

Commit

Permalink
Implements for #71 - Windows GUI password prompt support
Browse files Browse the repository at this point in the history
NOTE **optional** requirements update
  • Loading branch information
clach04 committed Dec 31, 2023
1 parent c5ec426 commit d25642f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions puren_tonbo/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def getpass(cls, prompt=None, stream=None):
except ImportError:
tkinter = None

try:
# pywin32
from pythonwin.pywin.dialogs.login import GetPassword as win32_getpassword
except ImportError:
win32_getpassword = None


def easydialogs_getpass(prompt):
password = EasyDialogs.AskPassword('password?', default='')
Expand All @@ -56,6 +62,8 @@ def tk_getpass(prompt):


supported_password_prompt = ('any', 'text', 'gui',) # although GUI may not be possible
if win32_getpassword:
supported_password_prompt += ('win32',)
if EasyDialogs:
supported_password_prompt += ('EasyDialogs',) # case?
if tkinter:
Expand All @@ -81,6 +89,9 @@ def getpassfunc(prompt=None, preference_list=None):
else:
return getpass.getpass()

if win32_getpassword and ('win32' in preference_list or 'gui' in preference_list or 'any' in preference_list):
return win32_getpassword(prompt)

if EasyDialogs and ('EasyDialogs' in preference_list or 'gui' in preference_list or 'any' in preference_list):
return easydialogs_getpass(prompt)

Expand Down

0 comments on commit d25642f

Please sign in to comment.