Skip to content

Commit

Permalink
add echo kwarg to prompt.text()
Browse files Browse the repository at this point in the history
  • Loading branch information
jborbely committed Sep 27, 2019
1 parent 765ba35 commit 1200973
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions msl/qt/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def save(*, title='Save As', directory=None, filters=None, options=None):
return name if name else None


def text(message, *, title=None, font=None, value='', multi_line=False):
def text(message, *, title=None, font=None, value='', multi_line=False, echo=QtWidgets.QLineEdit.Normal):
"""Request text.
Parameters
Expand All @@ -329,6 +329,8 @@ def text(message, *, title=None, font=None, value='', multi_line=False):
The initial value.
multi_line : :class:`bool`, optional
Whether the entered text can span multiple lines.
echo : :class:`int` or `QLineEdit.EchoMode <https://doc.qt.io/qt-5/qlineedit.html#EchoMode-enum>`_, optional
The echo mode for the text value. Useful if requesting a password.
Returns
-------
Expand All @@ -341,7 +343,7 @@ def text(message, *, title=None, font=None, value='', multi_line=False):
if multi_line:
dialog.setOption(QtWidgets.QInputDialog.UsePlainTextEditForTextInput)
else:
dialog.setTextEchoMode(QtWidgets.QLineEdit.Normal)
dialog.setTextEchoMode(QtWidgets.QLineEdit.EchoMode(echo))
ok = dialog.exec_()
return dialog.textValue().strip() if ok else None

Expand Down

0 comments on commit 1200973

Please sign in to comment.