Python EasyGUI - 输入框
Enter Box :用于获取用户的输入,输入可以是任意键盘输入,以字符串形式输入。它显示标题、要显示的消息、输入文本的位置和一对“确定”、“取消”按钮,用于确认输入。我们也可以在用户输入文本的地方设置一些默认文本,下面是输入框的样子
In order to do this we will use enterbox
method
Syntax : enterbox(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 your Geek name !!"
# window title
title = "Window Title GfG"
# default text
d_text = "Enter here.."
# creating a enter box
output = enterbox(text, title, d_text)
# title for the message box
title = "Message Box"
# creating a message
message = "Enterted Name : " + str(output)
# creating a message box
msg = msgbox(message, title)
输出 :
![](https://mangodoc.oss-cn-beijing.aliyuncs.com/geek8geeks/Python_EasyGUI_%E2%80%93_Enter_Box_1.png)
另一个例子 :
在此我们将创建一个输入框,并根据输入的文本在屏幕上显示具体的消息,下面是实现
# importing easygui module
from easygui import *
# message to be displayed
text = "Enter Something"
# window title
title = "Window Title GfG"
# creating a enter box
output = enterbox(text, title)
# title for the message box
title = "Message Box"
# creating a message
message = "Enterted string : " + str(output)
# creating a message box
msg = msgbox(message, title)
输出 :
![](https://mangodoc.oss-cn-beijing.aliyuncs.com/geek8geeks/Python_EasyGUI_%E2%80%93_Enter_Box_2.png)