1.integerbox()函數:只可輸入整數的輸入框,默認輸入范圍為0-99
integerbox(msg="", title=" ", default=None,lowerbound=0, upperbound=99, image=None, root=None)
參數介紹:
msg: 輸入框描述信息提示,不傳時默認為"Enter an interger between lowerbound an upperbound"
title: 輸入框標題,默認為 " "
lowerbound: 用戶可輸入的最小值,默認為0
upperbound: 用戶可輸入的最大值,默認為99
image: 輸入框顯示圖片,默認無
default: 用戶默認輸入值
a.不帶參使用
import easygui as g value = g.integerbox()

b.傳入msg
import easygui as g value = g.integerbox(msg="請輸入0-99的整數")

c.傳入lowerbound upperbound,修改輸入范圍
import easygui as g value = g.integerbox(msg="請輸入1-200的整數", lowerbound=1, upperbound=200)

d.傳入窗口標題,title
import easygui as g value = g.integerbox(msg="請輸入1-200的整數", title="數字輸入測試", lowerbound=1, upperbound=200)

e.傳入顯示圖片,image,若未安裝PIL庫,此次image只能傳入.gif格式圖片,若傳入jpg等提示“PIL library isn't installed. If it isn't installed, only .gif files can be used.”
import easygui as g value = g.integerbox(msg="請輸入1-200的整數", title="數字輸入測試", lowerbound=1, upperbound=200, image="abc.gif")

f.傳入用戶默認輸入值,default
import easygui as g value = g.integerbox(msg="請輸入1-200的整數", title="數字輸入測試", default=2, lowerbound=1, upperbound=200, image="abc.gif")

g.輸入字符時會校驗是否合規,如果非整型會提示is not an integer.
2.enterbox()函數:用戶可輸入文本
enterbox(msg="Enter something.", title=" ", default="",strip=True, image=None, root=None)
參數介紹:
msg: 輸入框描述信息提示,默認"Enter something."
title: 輸入框標題,默認為 " "
default: 用戶默認輸入文本
strip: 是否去除空格,默認True
image: 輸入框顯示圖片,默認無
a.不帶參數使用
import easygui as g value = g.enterbox()

b.傳入msg、title、image
import easygui as g value = g.enterbox(msg="請輸入你想說的話", title="情感傾訴", image="abc.gif") g.msgbox(value)
c.傳入用戶默認輸入文本,default
import easygui as g value = g.enterbox(msg="請輸入你想說的話", title="情感傾訴",default="面朝大海,春暖花開", image="abc.gif") g.msgbox(value)
d.傳入strip演示
strip=True
import easygui as g value = g.enterbox(msg="請輸入你想說的話", title="情感傾訴", default="面朝大海,春暖花開", image="abc.gif") g.msgbox(value)
strip=False
import easygui as g value = g.enterbox(msg="請輸入你想說的話", title="情感傾訴", default="面朝大海,春暖花開", strip=False,image="abc.gif") g.msgbox(value)
3.multenterbox()函數:多項輸入
multenterbox(msg="Fill in values for the fields.", title=" ",fields=[], values=[], callback=None, run=True)
參數介紹:
msg: 輸入框描述信息提示,默認“Fill in values for the fields”
title: 輸入框標題,默認為 " "
fields: 輸入框名稱賦值,數組類型,必填,若未傳入時拋出TypeError: cannot unpack non-iterable NoneType object異常
values: 用戶默認輸入文本,數組類型,當傳入時,fields中的每項默認顯示values中的值
run:默認True
a.不傳values
import easygui as g value = g.multenterbox(msg="請填寫對應的英文", title="水果翻譯", fields=["蘋果", "香蕉", "橘子", "草莓"]) g.msgbox(value)![]()
![]()
b.傳入values
import easygui as g value = g.multenterbox(msg="請填寫對應的英文", title="水果翻譯", fields=["蘋果", "香蕉", "橘子", "草莓"], values=['apple', 'banana', 'orange', 'strawberry']) g.msgbox(value)
run=True
import easygui as g value = g.multenterbox(msg="請填寫對應的英文", title="水果翻譯", fields=["蘋果", "香蕉", "橘子", "草莓"], values=['apple', 'banana', 'orange', 'strawberry'], run=True) print(type(value)) print(value)


run=False
import easygui as g value = g.multenterbox(msg="請填寫對應的英文", title="水果翻譯", fields=["蘋果", "香蕉", "橘子", "草莓"], values=['apple', 'banana', 'orange', 'strawberry'], run=False) print(type(value)) print(value)
