用法首先要进行的就是安装easygui,大家可以在网上搜索相应的安装方法,这里就简单的介绍一个最简单的安装方法,使用安装神器pip
只需在终端或者命令行输入:pip install easygui 稍等一会大家就可以引用自己easygui了,开始自己的easygui之旅了。
开始

import easygui
NAMEeasygui - Hello from easygui/__init__.pyFILE/usr/local/lib/python2.7/dist-packages/easygui/__init__.pyPACKAGE CONTENTSboxes (package)easyguiCLASSES__builtin__.objecteasygui.boxes.egstore.EgStoreclass EgStore(__builtin__.object)|  A class to support persistent storage.|  |  You can use ``EgStore`` to support the storage and retrieval|  of user settings for an EasyGui application.|  |  **First: define a class named Settings as a subclass of EgStore** ::|  |      class Settings(EgStore):|          def __init__(self, filename):  # filename is required|              # specify default values for variables that this application wants to remember|              self.user_id = ''|              self.target_server = ''|              settings.restore()|  *Second: create a persistent Settings object** ::|  |      settings = Settings('app_settings.txt')|      settings.user_id = 'obama_barak'|      settings.targetServer = 'whitehouse1'|      settings.store()|  |      # run code that gets a new value for user_id, and persist the settings|      settings.user_id = 'biden_joe'|      settings.store()|  |  **Example C: recover the Settings instance, change an attribute, and store it again.** ::|  |      settings = Settings('app_settings.txt')|      settings.restore()|      print settings|      settings.user_id = 'vanrossum_g'|      settings.store()|  |  Methods defined here:|  |  __getstate__(self)|      All attributes will be pickled|  |  __init__(self, filename)|      Initialize a store with the given filename.|      |      :param filename: the file that backs this store for saving and loading|  |  __repr__(self)|  |  __setstate__(self, state)|      Ensure filename won't be unpickled|  |  __str__(self)|      "Format this store as "key : value" pairs, one per line.|  |  kill(self)|      Delete this store's file if it exists.|  |  restore(self)|  |  store(self)|      Save this store to a pickle file.|      All directories in :attr:`filename` must already exist.|  |  ----------------------------------------------------------------------|  Data descriptors defined here:|  |  __dict__|      dictionary for instance variables (if defined)|  |  |  __weakref__|      list of weak references to the object (if defined)FUNCTIONSabouteasygui()shows the easygui revision historyboolbox(msg='Shall I continue?', title=' ', choices=('[Y]es', '[N]o'), image=None, default_choice='Yes', cancel_choice='No')Display a boolean msgbox.The returned value is calculated this way::if the first choice is chosen, or if the dialog is cancelled:returns Trueelse:returns False:param str msg: the msg to be displayed:param str title: the window title:param list choices: a list or tuple of the choices to be displayed:param str image: Filename of image to display:param str default_choice: The choice you want highlightedwhen the gui appears:param str cancel_choice: If the user presses the 'X' close, which buttonshould be pressed:return: True if first button pressed or dialog is cancelled, False ifsecond button is pressedbuttonbox(msg='', title=' ', choices=('Button[1]', 'Button[2]', 'Button[3]'), image=None, images=None, default_choice=None, cancel_choice=None, callback=None, run=True)Display a msg, a title, an image, and a set of buttons.The buttons are defined by the members of the choices global_state.:param str msg: the msg to be displayed:param str title: the window title:param list choices: a list or tuple of the choices to be displayed:param str image: (Only here for backward compatibility):param str images: Filename of image or iterable or iteratable of iterable to display:param str default_choice: The choice you want highlighted when the gui appears:return: the text of the button that the user selected
:buttonbox(msg='', title=' ', choices=('Button[1]', 'Button[2]', 'Button[3]'), image=None, images=None, default_choice=None, cancel_choice=None, callback=None, run=True)Display a msg, a title, an image, and a set of buttons.The buttons are defined by the members of the choices global_state.:param str msg: the msg to be displayed:param str title: the window title:param list choices: a list or tuple of the choices to be displayed:param str image: (Only here for backward compatibility):param str images: Filename of image or iterable or iteratable of iterable to display:param str default_choice: The choice you want highlighted when the gui appears:return: the text of the button that the user selectedccbox(msg='Shall I continue?', title=' ', choices=('C[o]ntinue', 'C[a]ncel'), image=None, default_choice='Continue', cancel_choice='Cancel')Display a msgbox with choices of Continue and Cancel.The returned value is calculated this way::if the first choice ("Continue") is chosen,or if the dialog is cancelled:return Trueelse:return FalseIf invoked without a msg argument, displays a genericrequest for a confirmationthat the user wishes to continue.  So it can be used this way::if ccbox():pass # continueelse:sys.exit(0)  # exit the program:param str msg: the msg to be displayed:param str title: the window title:param list choices: a list or tuple of the choices to be displayed:param str image: Filename of image to display:param str default_choice: The choice you want highlightedwhen the gui appears:param str cancel_choice: If the user presses the 'X' close,which button should be pressed:return: True if 'Continue' or dialog is cancelled, False if 'Cancel'choicebox(msg='Pick an item', title='', choices=[], preselect=0, callback=None, run=True)Present the user with a list of choices.return the choice that he selects.:param str msg: the msg to be displayed:param str title: the window title:param list choices: a list or tuple of the choices to be displayed:param preselect: Which item, if any are preselected when dialog appears:return: List containing choice selected or None if cancelledcodebox(msg='', title=' ', text='')Display some text in a monospaced font, with no line wrapping.This function is suitable for displaying code and text that isformatted using spaces.The text parameter should be a string, or a list or tuple of lines to bedisplayed in the textbox.:param str msg: the msg to be displayed:param str title: the window title:param str text: what to display in the textboxdiropenbox(msg=None, title=None, default=None)A dialog to get a directory name.Note that the msg argument, if specified, is ignored.Returns the name of a directory, or None if user chose to cancel.If the "default" argument specifies a directory name, and thatdirectory exists, then the dialog box will start with that directory.:param str msg: the msg to be displayed:param str title: the window title:param str default: starting directory when dialog opens:return: Normalized path selected by useregdemo = easygui_demo()Run the EasyGui demo.
:  You may optionally specify some default text, which will appear in theenterbox when it is displayed.Example::reply = enterbox(....)if reply:...else:...:param str msg: the msg to be displayed.:param str title: the window title:param str default: value returned if user does not change it:param bool strip: If True, the return value will haveits whitespace stripped before being returned:return: the text that the user entered, or None if he cancelsthe operation.exceptionbox(msg=None, title=None)Display a box that gives information aboutan exception that has just been raised.The caller may optionally pass in a title for the window, or amsg to accompany the error information.Note that you do not need to (and cannot) pass an exception objectas an argument.  The latest exception will automatically be used.:param str msg: the msg to be displayed:param str title: the window title:return: Nonefileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=False)A dialog to get a file name.**About the "default" argument**The "default" argument specifies a filepath that (normally)contains one or more wildcards.fileopenbox will display only files that match the default filepath.:param str msg: the msg to be displayed:param str title: the window title:return: Nonefileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=False)A dialog to get a file name.**About the "default" argument**The "default" argument specifies a filepath that (normally)contains one or more wildcards.fileopenbox will display only files that match the default filepath.If omitted, defaults to "\*" (all files in the current directory).WINDOWS EXAMPLE::...default="c:/myjunk/*.py"will open in directory c:\myjunk\ and show all Python files.WINDOWS EXAMPLE::...default="c:/myjunk/test*.py"will open in directory c:\myjunk\ and show all Python fileswhose names begin with "test".Note that on Windows, fileopenbox automatically changes the pathseparator to the Windows path separator (backslash).**About the "filetypes" argument**If specified, it should contain a list of items,where each item is either:- a string containing a filemask          # e.g. "\*.txt"- a list of strings, where all of the strings except the last oneare filemasks (each beginning with "\*.",such as "\*.txt" for text files, "\*.py" for Python files, etc.).and the last string contains a filetype descriptionEXAMPLE::filetypes = ["*.css", ["*.htm", "*.html", "HTML files"]  ].. note:: If the filetypes list does not contain ("All files","*"), it will be added.If the filetypes list does not contain a filemask that includesthe extension of the "default" argument, it will be added.For example, if default="\*abc.py"and no filetypes argument was specified, then"\*.py" will automatically be added to the filetypes argument.:param str msg: the msg to be displayed.:param str title: the window title:param str default: filepath with wildcards:param object filetypes: filemasks that a user can choose, e.g. "\*.txt":param bool multiple: If true, more than one file can be selected:return: the name of a file, or None if user chose to cancelfilesavebox(msg=None, title=None, default='', filetypes=None)A file to get the name of a file to save.Returns the name of a file, or None if user chose to cancel.The "default" argument should contain a filename (i.e. thecurrent name of the file to be saved).  It may also be empty,or contain a filemask that includes wildcards.The "filetypes" argument works like the "filetypes" argument tofileopenbox.:param str msg: the msg to be displayed.:param str title: the window title:param str default: default filename to return:param object filetypes: filemasks that a user can choose, e.g. " \*.txt":return: the name of a file, or None if user chose to cancelindexbox(msg='Shall I continue?', title=' ', choices=('Yes', 'No'), image=None, default_choice='Yes', cancel_choice='No')Display a buttonbox with the specified choices.:param str msg: the msg to be displayed.:param str title: the window title:param str default: default filename to return:param object filetypes: filemasks that a user can choose, e.g. " \*.txt":return: the name of a file, or None if user chose to cancelindexbox(msg='Shall I continue?', title=' ', choices=('Yes', 'No'), image=None, default_choice='Yes', cancel_choice='No')Display a buttonbox with the specified choices.:param str msg: the msg to be displayed:param str title: the window title:param list choices: a list or tuple of the choices to be displayed:param str image: Filename of image to display:param str default_choice: The choice you want highlightedwhen the gui appears:param str cancel_choice: If the user presses the 'X' close,which button should be pressed:return: the index of the choice selected, starting from 0integerbox(msg='', title=' ', default=None, lowerbound=0, upperbound=99, image=None, root=None)Show a box in which a user can enter an integer.In addition to arguments for msg and title, this function acceptsinteger arguments for "default", "lowerbound", and "upperbound".The default, lowerbound, or upperbound may be None.When the user enters some text, the text is checked to verify that itcan be converted to an integer between the lowerbound and upperbound.If it can be, the integer (not the text) is returned.If it cannot, then an error msg is displayed, and the integerbox isredisplayed.If the user cancels the operation, None is returned.:param str msg: the msg to be displayed:param str title: the window title:param int default: The default value to return:param str title: the window title:param str ok_button: text to show in the button:param str image: Filename of image to display:param tk_widget root: Top-level Tk widget:return: the text of the ok_buttonmultchoicebox(msg='Pick an item', title='', choices=[], preselect=0, callback=None, run=True)Same as choicebox, but the user can select many items.multenterbox(msg='Fill in values for the fields.', title=' ', fields=[], values=[], callback=None, run=True)Show screen with multiple data entry fields.If there are fewer values than names, the list of values is padded withempty strings until the number of values is the same as the numberof names.If there are more values than names, the list of valuesis truncated so that there are as many values as names.Returns a list of the values of the fields,or None if the user cancels the operation.Here is some example code, that shows how values returned frommultenterbox can be checked for validity before they are accepted::msg = "Enter your personal information"title = "Credit Card Application"fieldNames = ["Name","Street Address","City","State","ZipCode"]fieldValues = []  # we start with blanks for the valuesfieldValues = multenterbox(msg,title, fieldNames)# make sure that none of the fields was left blankwhile 1:if fieldValues is None: breakerrmsg = ""for i in range(len(fieldNames)):if fieldValues[i].strip() == "":errmsg += ('"%s" is a required field.\n\n' % fieldNames[i])if errmsg == "":break # no problems found
:break # no problems foundfieldValues = multenterbox(errmsg, title, fieldNames, fieldValues)print("Reply was: %s" % str(fieldValues)):param str msg: the msg to be displayed.:param str title: the window title:param list fields: a list of fieldnames.:param list values: a list of field values:return: Stringmultpasswordbox(msg='Fill in values for the fields.', title=' ', fields=(), values=(), callback=None, run=True)Same interface as multenterbox.  But in multpassword box,the last of the fields is assumed to be a password, andis masked with asterisks.:param str msg: the msg to be displayed.:param str title: the window title:param list fields: a list of fieldnames.:param list values: a list of field values:return: String**Example**Here is some example code, that shows how values returned frommultpasswordbox can be checked for validity before they are accepted::msg = "Enter logon information"title = "Demo of multpasswordbox"fieldNames = ["Server ID", "User ID", "Password"]fieldValues = []  # we start with blanks for the valuesfieldValues = multpasswordbox(msg,title, fieldNames)# make sure that none of the fields was left blankwhile 1:if fieldValues is None: breakerrmsg = ""for i in range(len(fieldNames)):if fieldValues[i].strip() == "":errmsg = errmsg + ('"%s" is a required field.\n\n' %fieldNames[i])
:print("Reply was: %s" % str(fieldValues))passwordbox(msg='Enter your password.', title=' ', default='', image=None, root=None)Show a box in which a user can enter a password.The text is masked with asterisks, so the password is not displayed.:param str msg: the msg to be displayed.:param str title: the window title:param str default: value returned if user does not change it:return: the text that the user entered, or None if he cancelsthe operation.textbox(msg='', title=' ', text='', codebox=False, callback=None, run=True)Display a message and a text to editParameters----------msg : stringtext displayed in the message area (instructions...)title : strthe window titletext: str, list or tupletext displayed in textAreas (editable)codebox: boolif True, don't wrap and width is set to 80 charscallback: functionif set, this function will be called when OK is pressedrun: boolif True, a box object will be created and returned, but not runReturns-------NoneIf cancel is pressedstrIf OK is pressed returns the contents of textAreaynbox(msg='Shall I continue?', title=' ', choices=('[<F1>]Yes', '[<F2>]No'), image=None, default_choice='[<F1>]Yes', cancel_choice='[<F2>]No')Display a msgbox with choices of Yes and No.The returned value is calculated this way::
:if the first choice ("Yes") is chosen, or if the dialog is cancelled:return Trueelse:return FalseIf invoked without a msg argument, displays a genericrequest for a confirmationthat the user wishes to continue.  So it can be used this way::if ynbox():pass # continueelse:sys.exit(0)  # exit the program:param msg: the msg to be displayed:type msg: str:param str title: the window title:param list choices: a list or tuple of the choices to be displayed:param str image: Filename of image to display:param str default_choice: The choice you want highlightedwhen the gui appears:param str cancel_choice: If the user presses the 'X' close, whichbutton should be pressed:return: True if 'Yes' or dialog is cancelled, False if 'No'DATA__all__ = ['buttonbox', 'diropenbox', 'fileopenbox', 'filesavebox', 't...eg_version = '0.98.0-RELEASED'egversion = '0.98.0-RELEASED'

EasyGui的用法简介相关推荐

  1. MSSQL Sql加密函数 hashbytes 用法简介

    原文:MSSQL Sql加密函数 hashbytes 用法简介 转自:http://www.maomao365.com/?p=4732 一.mssql sql hashbytes 函数简介 hashb ...

  2. Postman用法简介-Http请求模拟工具

    Postman用法简介-Http请求模拟工具 在我们平时开发中,特别是需要与接口打交道时,无论是写接口还是用接口,拿到接口后肯定都得提前测试一下,这样的话就非常需要有一个比较给力的Http请求模拟工具 ...

  3. InputStreamReader 和 OutputStreamWriter类用法简介,及演示。

    InputStreamReader 和 OutputStreamWriter类用法简介. 一.InputStreamReader类 InputStreamReader 将字节流转换为字符流.是字节流通 ...

  4. php中__FILE__常量用法简介

    php中__FILE__常量用法简介 http://blog.csdn.net/xbei07/article/details/5616020#comments出处 1.php中的__FILE__常量返 ...

  5. java test 用法,pytest基本用法简介

    1.安装pytest,打开dos窗口输入: pip install pytest 2.通过pycharm工具下载 3.创建pytest测试用例步骤 # 定义测试类 class testdivide: ...

  6. SAP Gateway与OData用法简介

    本文将分别从基础原理和实际应用两个角度介绍SAP Gateway与OData相关的知识点. 1 相关的事务代码(t-code) SEGW - SAP Gateway Service Builder / ...

  7. Matlab中 intlinprog函数用法简介

    Matlab中 intlinprog函数用法简介 本来想要自己亲手写一遍的,发现了一优质博文基本上跟我做过的例题大差不差,所以就直接放上链接. 参考链接 https://www.cnblogs.com ...

  8. intersect的用法简介

    intersect的用法简介 在Oracle中,"A minus B"用于将结果集B中含有的记录从结果集A中移除,即用于获取存在于结果集A中而不存在于结果集B中的记录:" ...

  9. Oracle SQL调优系列之no_unnest和unnest用法简介

    Oracle调优之no_unnest和unnest用法简介 本博客介绍Oracle SQL调优的一种常用也是很实用的方法,也即/*+no_unnest */和/*+ unnest*/,介绍Oracle ...

最新文章

  1. java 倾斜校正_简述Java图像倾斜方法及实例
  2. tomcat7查看后台管理怎么设置用户名和密码
  3. 编写网关过滤器统一校验登录状态
  4. Linux Capabilities 入门教程--概念篇
  5. Beta冲刺博客集合贴
  6. 使用Scala实现Java项目的单词计数:串行及Actor版本
  7. python检查字典中是否已存在给定键
  8. 大众仪表板上为什么30km,50km处要标红?
  9. java 中PriorityQueue优先级队列使用方法
  10. coreldraw sp2精简版 x4_CorelDRAW X4下载-CorelDRAW X4 SP2 精简版_Win10镜像官网
  11. java 中int常量池_Java基础2:基本数据类型与常量池
  12. pandox怎么用_神器Pandoc的安装与使用 | Flyaway's Blog
  13. Matlab-syms用法
  14. ZZULIOJ 1919 D
  15. 神经网络是部署到终端还是服务器的
  16. GooglePhoto设置壁纸----壁纸裁剪界面配置
  17. 获取referer中的请求参数_javaweb之request获取referer请求头实现防盗链
  18. python绘制糖葫芦_冰糖葫芦怎么画
  19. C语言开发工程师笔试面试题整理(七)——数据库SQL
  20. java debug dll_JavaDebug.dll,下载,简介,描述,修复,等相关问题一站搞定_DLL之家

热门文章

  1. P1005 采药(Tyvj)
  2. zoj-3471 Most powful
  3. 《机器学习实战》chapter02 K-近邻算法(KNN)
  4. 《Head First Python》第四章--持久存储
  5. [LGP4707] 重返现世
  6. 弄懂CNN,然后提升准确率4.21-4.27
  7. RabbitMQ headers Exchange
  8. java实现随机验证码的图片
  9. [算法 笔记]字符串表达式计算(简易版)
  10. 通过扩展改善ASP.NET MVC的验证机制[实现篇]