获取:pycharm下方交互环境(python console)输入‘pip install easyhgui’即可自动下载最新版
调取:import easygui as name
name.函数()
模块调用
import easygui as eg
1.按钮部分
>>>easygui.egdemo()
#功能演示 >>>为交互环境
1,msgbox
# eg.msgbox(msg = '', title = '', ok_button = '[O]k', image = None, root = None)
2,ccbox
#choices = ('Continue', 'Can')# false true
# Continue_choice = 'True'
# cancel_choice = 'False'
# eg.ccbox(msg = '', title = '', choices = ('Continue', 'Cancel'), image = None,default_choice = Continue_choice, cancel_choice = cancel_choice)
#按键返回True False
3,ynbox
# eg.ynbox(msg = '', title = '', choices = ('[<F1>]Yes', '[<F2>]No'), image = None, default_choice = '[<F1>]Yes', cancel_choice = '[<F2>]No')
#默认值与cc不同
4,buttonbox
# eg.buttonbox(msg = '', title = '', choices = ('Button[1]', 'Button[2]', 'Button[3]'), image = None, default_choice = None, cancel_choice = None, callback = None, run = True)
#取消时选择值为第一个选项
5,indexbox
# eg.indexbox()#第一个选项返回0, 第二个返回0
6,boolbox
# eg.boolbox()#True False
7,choicebox
# eg.choicebox(msg = '', title = '', choices = ('a', 'b', 'c'))
8,multchoicebox
# eg.multchoicebox()#可选择0 1 多个
2.消息输入
1,enterbox
# mag = '请输入信息'
# title = '用户输入标题'
# default = ' ' #输入的信息界面
# strip = True #false返回值保留首尾空格
# image = None # image file true does not exist 镜像文件
# root = None #true exit code 1
# a = cg.enterbox(mag, title, default, strip, image, root)
# print(a)
2, integerbox
# image root 此时函数范围是1-10
# b = cg.integerbox(msg = "", title = '', lowerbound = 0, upperbound = 10)
# print(b)
3, multenterbox
# fields /输入标识
# values /输入值
# callback #不清楚,没试出来什么意思
# run /true-code 0 ,none-code 1
# msg = " "
# title = ' '
# c = cg.multenterbox(fields = ['用户', '账号', '密码'], values = ['wwq', 'vxb', 'wr'], callback = None, run = True)
# print(c)
4, passwordbox
# 密码函数 passwordbox
# d = cg.passwordbox(msg = "", title = "", default = '', root = None)
# print(d)
5, multpasswordbox
# cg.multpasswordbox(msg = "", title = "", fields = ('用户', '账号', '密码'))
3.文件打开与保存
打开txt文件 (需将文件与程序放同一文件目录下)
1, extbox
1. # fil = ip.fileopenbox(default = "123.txt")
# file = open(fil)2.# file = open("gb.txt")
# ip.textbox(msg = '', title = '', text = file.read())
2, codebox
# ip.codebox(msg = '', title = '', text = file.read())#等宽字体输出
#codebox = Ture 等宽字体
# callback run
3, diropenbox
# msg, title, default, filetypes,
# ip.diropenbox(msg = '', title = '', default = 'D:')
4, fileopenbox
#multiple = True 可选择多个文件
# default * 号使用:1./*.py指定文件 2./text*.py text开头文件
# default = None 默认本文件夹,可自定输入
# filetypes 可有多选择,默认all,右下角更换
# multiple = True 可同时选择多个文件
# ip.fileopenbox(msg = '', title = '', filetypes = ["*.py", "*.txt", "*.html"], multiple = True)# ip.fileopenbox(msg = '', title = '', default = 'F:\Project\python\ed1\*.png', filetypes = ["*.png"], multiple = True)
5, filesavebox
# ip.filesavebox(msg = '', title = '', default = 'F:\Project\python\ed1\*.png', filetypes = ["*.png"])#保存函数:选中一个文件然后选择保存位置