EasyGUI - 多密码框
多密码框:用于获取用户输入的多文本单密码形式,即屏蔽输入,输入可以是任意键盘输入,以字符串形式输入。它显示标题、要显示的消息、输入文本的位置组和一对“确定”、“取消”按钮,用于确认输入。我们也可以在用户输入文本的地方设置一些默认文本。它类似于多输入框,但最后一个输入字段被视为密码,即下面的屏蔽文本是密码框的样子
In order to do this we will use multpasswordbox
method
Syntax : multpasswordbox(message, title, fields, default_text)
Argument : It takes 4 arguments, first string i.e message/information to be displayed, second string i.e title of the window, third is list of fields and forth is list of string which is default text
Return : It returns the list of entered text and None if cancel is pressed
例子 :
在此我们将创建一个带有默认文本的多密码框,并根据输入的文本在屏幕上显示特定的消息,下面是实现
# importing easygui module
from easygui import *
# message to be displayed
text = "Enter the details to go further"
# window title
title = "Window Title GfG"
# list of entry fields
fields = ["Email ID", "Geek ID", "Password"]
# default text
default_values = ["email@abc.com", "G-111", "password"]
# creating a multi password box
output = multpasswordbox(text, title, fields, default_values )
# showing details entered by the user
print("Details entered by user")
print("==================================")
# traversing the output
for i in range(len(fields)):
# showing field and entered value
print(fields[i] + " : " + str(output[i]))
输出 :
Details entered by user
==================================
Email ID : email@asd.ccc
Geek ID : G-11122
Password : password
另一个例子 :
在此我们将创建一个没有默认文本的多密码框,并根据输入的文本在屏幕上显示具体的信息,下面是实现
# importing easygui module
from easygui import *
# message to be displayed
text = "Enter the details to go further"
# window title
title = "Window Title GfG"
# list of entry fields
fields = ["Email ID", "Geek ID", "Password"]
# creating a multi password box
output = multpasswordbox(text, title, fields)
# showing details entered by the user
print("Details entered by user")
print("==================================")
# traversing the output
for i in range(len(fields)):
# showing field and entered value
print(fields[i] + " : " + str(output[i]))
输出 :
Details entered by user
==================================
Email ID : aaa
Geek ID : Geek101
Password : alphabeta