python 界面一

1.EasyGui 安装

1.下载EasyGui在cmd下切换到EasyGui文件夹目录下
2.使用python.exe 安装EasyGui
D:\python\easygui-0.96>D:\python\Python36\python.exe setup.py install

2.导入使用

在使用时文件名字不能以easygui命名
详细介绍参照小甲鱼翻译EasyGui

1.导入easygui包
import easygui as gui

2.按钮的使用

1.ccbox()的使用 ccbox(msg, title, choices=(’ ‘,’ ‘), image = None)
import easygui as g
import sys
def ccbox():
    if g.ccbox('这是ccbox的内容','这是ccbox的标题',choices=('确定','取消')):
        g.msgbox('选择了确定按钮')
    else:
        sys.exit(0)
ccbox()

2.msgbox()的使用 msgbox(msg, title, ok_button=’ok’, image=None)
import easygui as g
def msgbox(msg,title):
    g.msgbox(msg, title, ok_button='ok',image=None)

msgbox(msg = 'content',title = 'title')

3.ynbox()的使用 ynbox(msg, title, choices=(‘Yes’,’No’), image=None)
import easygui as g
def ynbox(msg,title):
    g.ynbox(msg, title, choices=('Yes','No'),image=None)

ynbox(msg = 'content',title = 'title')

4.buttonbox()的使用 buttonbox(msg, title, choices=(’ ‘,’ ‘,’ ‘), image=None)
import easygui as g
def buttonbox(msg,title):
    g.buttonbox(msg, title, choices=('button1','button2','button3'),image=None)

buttonbox(msg = 'content',title = 'title')

3.选择使用

1.choicebox()单选的使用 choicebox(msg, title, choices=(’ ‘,’ ‘,’ ‘))
import easygui as g
def choicebox(msg,title):
    g.choicebox(msg, title, choices=('choice1','mchoice2','nchoice3'))

choicebox(msg = 'content',title = 'title')

2.multchoicebox()多选的使用 multchoicebox(msg, title, choices = (’ ‘, ’ ‘,’ ‘…))
import easygui as g
def multchoicebox(msg,title,select):
    msg = g.multchoicebox(msg, title, choices = select)
    print(msg) # ['s1', 's3']选择1,3
choices = ('s1','s2','s3','s4')
multchoicebox(msg = 'content',title = 'title',select = choices)

4.用户输入

1.enterbox()的使用 enterbox(msg, title, default=”, strip = False, image=None)

strip = False 保留得到字符串的首位空格
strip = True 去掉得到字符串的首位空格

import easygui as g
def enterbox(msg,title):
    msg = g.enterbox(msg, title, default='',strip = False,image=None)
    print(msg) # python

enterbox(msg = 'content',title = 'title')

2.integerbox()的使用 integerbox(msg, title, default=”, lowerbound=0, upperbound=99, image=None)
import easygui as g
def integerbox(msg,title,minNum,maxNum):
    msg = g.integerbox(msg, title,default='', lowerbound=minNum, upperbound=maxNum, image=None)
    print(msg) # 85
integerbox('content', 'title',0,99)

3.multenterbox()的使用 multenterbox(msg, title, fields, values=())
import easygui as g
fields = ['*姓名','年龄','学历']
msg = '填写下面信息(*为必填项)'
title = '个人信息'
def multenterbox(msg, title, fields):
    fieldvalue = g.multenterbox(msg, title,fields)
    while True:
        if fieldvalue == None:
            break
        errmsg = ''
        for item in range(len(fields)):
            option = fields[item].strip()
            if fieldvalue[item].strip() == "" and option[0] == "*":
                errmsg +=('[%s]为必填项。\n\n' % fields[item])
        if errmsg == '':
            break
        fieldvalue = g.multenterbox(errmsg, title,fields, fieldvalue)

    print('个人信息:%s'  % str(fieldvalue))

multenterbox(msg,title,fields)

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值