EasyGUI - 密码框
密码框:用于从用户那里获取密码形式的输入,即屏蔽输入,输入可以是任何键盘输入,它以字符串的形式输入。它显示标题、要显示的消息、输入文本的位置和一对“确定”、“取消”按钮,用于确认输入。我们也可以在用户输入文本的地方设置一些默认文本,下面是密码框的样子
In order to do this we will use passwordbox
method
Syntax : passwordbox(message, title, default_text)
Argument : It takes 3 arguments, first string i.e message/information to be displayed, second string i.e title of the window and third is string which is default text
Return : It returns the entered text and None if cancel is pressed
例子 :
在此我们将创建一个带有默认文本的密码框,并根据输入的文本在屏幕上显示特定的消息,下面是实现
# importing easygui module
from easygui import *
# message to be displayed
text = "Enter the password to enter GeeksforGeeks"
# window title
title = "Window Title GfG"
# default password
default_password = "geeksforgeeks"
# creating a integer box
output = passwordbox(text, title, default_password)
# title for the message box
title = "Message Box"
# creating a message
message = "Password entered by user : " + str(output)
# creating a message box
msg = msgbox(message, title)
输出 :
另一个例子
在此我们将创建一个没有默认文本的密码框,并根据输入的文本在屏幕上显示具体的信息,下面是实现
# importing easygui module
from easygui import *
# message to be displayed
text = "Enter the new password for GeeksforGeeks"
# window title
title = "Window Title GfG"
# creating a integer box
output = passwordbox(text, title)
# title for the message box
title = "Message Box"
# creating a message
message = "Password entered by user : " + str(output)
# creating a message box
msg = msgbox(message, title)
输出 :