1.利用msgbox(单词messagebox的缩写)给出一个提示信息:

import easygui as g

reply=g.msgbox('This is a basic message box.', 'Title Goes Here')
print(reply)
#http://easygui.sourceforge.net/

运行结果:

import easygui

easygui.msgbox('Hello, world!')

运行结果:

说明:easygui.msgbox('Hello, world!')这一句有个返回值,就是字符'OK'。这个特点是:只能点击OK,返回值确定。

利用ynbox给出yes or no 对话框:
import easygui as g

reply=g.ynbox('Shall I continue?', 'Title', ('Yes', 'No'))
print(reply)
#http://easygui.sourceforge.net/

运行结果:

说明:点'Yes',返回True,点'No',返回False。

导入easygui时起个别名:
import easygui
easygui.msgbox('Hello EasyGui!')
#但是,直接使用import导入,之后使用其中的方法时需要加上easygui的前缀,例如easygui.msgbox()。这样比较麻烦,我们还可以选择导入整个EasyGui的包:
from easygui import *
msgbox('Hello EasyGui!')
#上面的方法效果时一样的。我们还有第三种方法:
import easygui as g
g.msgbox('Hello EasyGui!')
#这个方法的好处是保留了EasyGui的命名空间,且调用时不用写出完整的包名。同时避免了第二种方法导致的函数覆盖的可能
#https://www.zybuluo.com/kingwhite/note/128328

2.给出一个提示信息,并且OK按钮的内容可以更改:

from easygui import *
msgbox('您选的序号是未知序号!',ok_button = '关闭程序')

和第一个一样,返回值是字符串,只是出现的返回值的内容可以修改。


3.打开文件对话框:

import easygui
path = easygui.fileopenbox()

如果选择打开文件,则返回值是所打开文件的全路径,如果选择取消,则返回'None'。


4.选择多个字符串列表中的某个字符串,并返回显示在对话框上面:

import easygui as g
import sys
while True:
g.msgbox('嗨,欢迎进入第一个GUI制作的小游戏~')
msg = '你希望学习到什么知识呢?'
title = '互动小游戏'
choices = ['琴棋书画', '四书五经', '程序编写', '逆向分析']
choice = g.choicebox(msg, title, choices)
# note that we convert the choice to string, in case the user
# cancelled the choice, and we got None.
g.msgbox('你的选择是:' + str(choice), '结果')
msg = '你希望重新开始小游戏么?'
title = '请选择'
if g.ccbox(msg, title): # Show a Continue/Cancel dialog
pass # user choose Continue
else:
sys.exit(0) # user choose Cancel
#https://i.cnblogs.com/EditPosts.aspx?postid=9914202&update=1

5.和4相似的例子:

import easygui as g
import sys
while 1:
g.msgbox("Hello, world!") msg ="What is your favorite flavor?"
title = "Ice Cream Survey"
choices = ["Vanilla", "Chocolate", "Strawberry", "Rocky Road"]
choice = g.choicebox(msg, title, choices) # note that we convert choice to string, in case
# the user cancelled the choice, and we got None.
g.msgbox("You chose: " + str(choice), "Survey Result") msg = "Do you want to continue?"
title = "Please Confirm"
if g.ccbox(msg, title): # show a Continue/Cancel dialog
pass # user chose Continue
else:
sys.exit(0) # user chose Cancel
#http://easygui.sourceforge.net/tutorial.html

6.easygui的buttonbox:

import easygui as g

reply=g.buttonbox('Click on your favorite flavor.', 'Favorite Flavor', ('Chocolate', 'Vanilla', 'Strawberry'))
print(reply)
#http://easygui.sourceforge.net/

7.返回选择的文件夹的名字:

import easygui as g
reply=g.diropenbox()
print(reply)

运行结果:

8.另存为对话框:

import easygui as g
reply=g.filesavebox()
print(reply)

9.输入内容对话框:

import easygui as g
reply=g.enterbox("shuru:")
print(reply)

python的easygui的更多相关文章

  1. Python 模块EasyGui详细介绍

    转载:无知小德 Python 模块EasyGui详细介绍 EasyGui 官网: http://easygui.sourceforge.net 官方的教学文档:http://easygui-docs- ...

  2. 【Python】easygui小甲鱼

    翻译改编自官方文档:http://easygui.sourceforge.net/tutorial/index.html 翻译改编者:小甲鱼,本文欢迎转载,转载请保证原文的完整性! 演示使用 Pyth ...

  3. 一、Python 模块EasyGui详细介绍

    Python 模块EasyGui详细介绍 EasyGui 官网: -http://easygui.sourceforge.net 官方的教学文档: -easygui-docs-0.96\tutoria ...

  4. Python模块 | EasyGui

    (Python模块 | EasyGui | 2021/04/08) 目录 什么是 EasyGUI? [EasyGui中的函数] msbox | 使用示例 ynbox | 使用示例 ccbox | 使用 ...

  5. python使用easygui写图形界面程序

    我 们首先下载一个类库easygui,它是一个Python用于简单开发图形化界面的类库,打开easygui的下载网页 http://sourceforge.net/projects/easygui/? ...

  6. Python 模块EasyGui

    1.msgBox msgbox(msg='(Your message goes here)', title=' ', ok_button='OK', image=None, root=None) ms ...

  7. Python:easygui的安装、导入、使用、设置

    转于:https://blog.csdn.net/sinat_37390744/article/details/55211652 博主:钏的博客 一.下载安装 1)下载0.96的easygui.htt ...

  8. python 模块-easygui.buttonbox

    2018-03-0315:43:11 ): Yes_or_No = easygui.buttonbox("是否良品?", choices=['Yes', 'No', '退出']) ...

  9. centos下python中添加easygui模块

    前提:python中要集成Tkinter,Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包的接口.Tk和Tkinter可以在大多数的Unix平台下使用,同 ...

随机推荐

  1. Mysql 性能监控及调优

    死锁概念: 两个或两个以上的进程在执行过程中,因争夺资源而造成的一种互相等待的现象 1.监控死锁(innotop): (1) 启用 innodb_status_file 在/etc/my.cnf添加如 ...

  2. highcharts 绘制图标的JAVASCRIPT 类库 收藏

    官方站点 : http://www.highcharts.com 演示样例网址 : http://www.highcharts.com

  3. C# 调用API接口处理公共类 自带JSON实体互转类

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  4. 字符串(string)操作的相关方法

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. CentOS6 图形界面(gnome)安装(转)

    CentOS6相对于CentOS5的安装有了不少的进步,有不少默认的选项可以选择,如: Desktop :基本的桌面系统,包括常用的桌面软件,如文档查看工具. Minimal Desktop :基本的 ...

  6. A008-drawable资源

    关于drawable资源笔者之前有写过两篇文章: Android-自己定义图像资源的使用(1) Android-自己定义图像资源的使用(2) 这里笔者就不做过多的赘述.我们从实际开发的角度去理解这个知 ...

  7. webStorm 多列编辑

    webStorm可以像Sublime一样使用列编辑,只是区别在于webStorm只可以编辑连续列表. 按住alt键鼠标选择一列,然后输入文字就会编辑多行,这个功能很赞,比较实用(按住ALT键选中之后, ...

  8. .NET C# Json序列化与反序列化——Newtonsoft.Json学习笔记

    Newtonsoft.Json,一款.NET中开源的Json序列化和反序列化类库(介绍及下载地址:http://json.codeplex.com/). /// <summary>    ...

  9. IPv4(四)子网和子网掩码

    为了完成路由选择,每个数据链路(网络)都必须有一个惟一的地址: 另外,数据链路上的每台主机也必须有一个地址,这个地址不仅标识主机为一个网络成员,还可以把主机与网络上的其他主机区分开来. 粗放使用IPv ...

  10. php解码“&#”编码的中文用函数html_entity_decode()

    遇到类似 ' 这种编码的字,我们可以用html_entity_decode()函数来解码. html_entity_decode() 函数把 HTML 实体转换为字符. 语法 html_entity_ ...