zoukankan      html  css  js  c++  java
  • 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="您填写的资料如下: "+str(neirong[0])+" "+str(neirong[1])+" "+str(neirong[2])+" "+str(neirong[3])

    g.msgbox(mmsg,"提示!",image=r"C:UsersDaodantouDesktop147.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)

    Daodantou:“不积跬步,无以至千里.”
  • 相关阅读:
    linux下shell显示-bash-4.1#不显示路径解决方法
    update chnroute
    An error "Host key verification failed" when you connect to other computer by OSX SSH
    使用dig查询dns解析
    DNS被污染后
    TunnelBroker for EdgeRouter 后记
    mdadm详细使用手册
    关于尼康黄的原因
    Panda3d code in github
    Python实例浅谈之三Python与C/C++相互调用
  • 原文地址:https://www.cnblogs.com/daodantou/p/10296110.html
Copyright © 2011-2022 走看看