Python模块EasyGui专题学习
Python模塊EasyGui專題學習
1.msgbox(msg,title,ok_button=“OK”,image="",root=None)
代碼
import easygui as g
msg=g.msgbox("大家好","標題",ok_button="知道了")
print(msg) #顯示“知道了” 默認返回OK 總結:返回按鈕文字
2.ccbox(msg,title,choices=("",""),image=None)
代碼(返回True或者False)
import easygui as g
import sys
if g.ccbox("這么晚了,還要繼續么?","提問",choices=("還要","算了")):
g.msgbox("還是不玩了,早些休息吧!")
else:
sys.exit(0)
3.ynbox()與上面ccbox()代碼功能一個樣,省略。
4.buttonbox(msg,title,choices=("Y","N","U"),image,root)
代碼 返回按鈕文本,默認第一個
import easygui as g
me=g.buttonbox("請做出你的選擇","標題",choices=("蘋果","香蕉","西瓜"))
print(me)
5.indexbox(msg,title,choices=("",""),image) 返回的是序列號
import easygui as g
me=g.indexbox("選擇那個哦?","標題",choices=("排骨","青菜","辣椒","冬瓜"))
print(me) #顯示序列號 選擇第一個則顯示0
6.boolbox(msg,title,choices=("YES","NO"),image=None)
代碼 返回True或者False
import easygui as g
me = g.boolbox("","",choices=("YES","NO"))
print(me)
7.buttonbox(msg,title,image,choices=("可愛","不可愛","財迷"))
代碼
import easygui as g
e=g.buttonbox("","",image="xiu.gif",choices=("可愛","不可愛","財迷"))
print(e) #返回按鈕信息
8.choicebox(msg,title,choices=())
代碼 返回 OK 選項內容 或者 None
import easygui as g
e=g.choicebox("請選擇其一!","提示",choices=("飛機","坦克","潛艇","飛船"))
print(e)
9 multchoicebox("請選擇某些!","提示",choices=("飛機","坦克","潛艇","飛船"))
代碼
import easygui as g
e = g.multchoicebox("請選擇某些!","提示",choices=("飛機","坦克","潛艇","飛船"))
print(e)
運行結果:OK ["飛機","坦克"]
10.enterbox(msg,title,.....) 其中strip=True默認 意思是去除空格
代碼 返回輸入的內容
import easygui as g
e=g.enterbox("請輸入文本","提示")
print(e)
11.integerbox(msg,title,lowerbound=,upperbound=,image=,root=None,...)
代碼 只能輸入整數型 而且限制大小范圍
import easygui as g
e=g.integerbox("","",lowerbound=3,upperbound=8)
print(e) # 必須3<=x<=8
12.multenterbox() 提供多個輸入框 不填為空字符串 取消返回列表值或者None
multenterbox(msg,title,fields=,values=)
代碼 代碼 代碼 代碼 代碼 代碼
import easygui as g
msg="請填寫下列信息:"
title="賬號中心"
xiangmu=["*姓名","*電話","QQ","Email"]
neirong=[]
neirong=g.multenterbox(msg,title,xiangmu)
print(neirong)
while True:
if neirong==None:
break
errmsg=""
for i in range(len(xiangmu)):
print(xiangmu[i]+" oooo "+neirong[i])
jianyi=xiangmu[i].strip()
if neirong[i].strip()=="" and jianyi[0]=="*":
errmsg+=("【%s】為必須填寫項目! "%str(xiangmu[i]))
if errmsg=="":
break
neirong=g.multenterbox(errmsg,title,xiangmu,neirong)
mmsg="您填寫的資料如下:\n\n"+str(neirong[0])+"\n"+str(neirong[1])+"\n"+str(neirong[2])+"\n"+str(neirong[3])
g.msgbox(mmsg,"提示!",image=r"C:\Users\Daodantou\Desktop\147.gif")
#print("您填寫的資料如下:%s"%str(neirong))
13.passwordbox(msg,title,image=,root=)
代碼
import easygui as g
e=g.passwordbox("請輸入你的密碼","提示")
print(e)
14.multpasswordbox() 和multenterbox()同接口,最后一個為密碼形式
import easygui as g
e=g.multpasswordbox("請輸入用戶名和密碼","登陸",("用戶:","密碼"))
print(str(e))
15.textbox(msg,title,text="",codebox=0) 最后參數=1不換行,=0換行。
import easygui as g
e=g.textbox("請觀察本文","顯示","請填寫如下信息!其中帶*為必填項目。",codebox=1)
print(e)
16.diropenbox(msg,title,default="") 打開對話框,返回目錄,目錄帶有完整路徑 cancel為None
import easygui as g
d=g.diropenbox("","","C:")
print(d)
17.補充一個 fileopenbox()
import easygui as g
d=g.fileopenbox("文件選擇對話框","選擇一個文件,返回完整目錄!",default="*.gif")
print(d)
轉載于:https://www.cnblogs.com/daodantou/p/10296110.html
總結
以上是生活随笔為你收集整理的Python模块EasyGui专题学习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redis的两种连接方式
- 下一篇: 微不足道的数学发现