1.EasyGui 安装
1.下载EasyGui在cmd下切换到EasyGui文件夹目录下
2.使用python.exe 安装EasyGui
1
| D:\python\easygui-0.96>D:\python\Python36\python.exe setup.py install
|
2.导入使用
在使用时文件名字不能以easygui命名
详细介绍参照小甲鱼翻译EasyGui
1.导入easygui包
2.按钮的使用
1.ccbox()的使用 ccbox(msg, title, choices=(‘ ‘,’ ‘), image = None)
1 2 3 4 5 6 7 8
| import easygui as g import sys def ccbox(): if g.ccbox('这是ccbox的内容','这是ccbox的标题',choices=('确定','取消')): g.msgbox('选择了确定按钮') else: sys.exit(0) ccbox()
|

1 2 3 4 5
| 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)
1 2 3 4 5
| import easygui as g def ynbox(msg,title): g.ynbox(msg, title, choices=('Yes','No'),image=None) ynbox(msg = 'content',title = 'title')
|

1 2 3 4 5
| 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=(‘ ‘,’ ‘,’ ‘))
1 2 3 4 5
| 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 = (‘ ‘, ‘ ‘,’ ‘…))
1 2 3 4 5 6
| 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 去掉得到字符串的首位空格
1 2 3 4 5 6
| import easygui as g def enterbox(msg,title): msg = g.enterbox(msg, title, default='',strip = False,image=None) print(msg) enterbox(msg = 'content',title = 'title')
|

2.integerbox()的使用 integerbox(msg, title, default=’’, lowerbound=0, upperbound=99, image=None)
1 2 3 4 5
| import easygui as g def integerbox(msg,title,minNum,maxNum): msg = g.integerbox(msg, title,default='', lowerbound=minNum, upperbound=maxNum, image=None) print(msg) integerbox('content', 'title',0,99)
|

3.multenterbox()的使用 multenterbox(msg, title, fields, values=())
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| 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)
|
