Python关于easygui库的使用,下面是一些简略的代码提示。

1 篇文章 0 订阅
1 篇文章 0 订阅
#!C:\Users\Administrator\OneDrive\桌面\python尝试文件\5.21\自建目录\venv python
# -*- coding:utf-8 -*-
# @Author Tony\
'''
    msgbox
    easygui.ccbox()
    easygui.choice(),第二个参数可以加入list选项。
    easygui.buttonbox(),建立了一系列的函数供调用
        ccbox(msg='Shall I continue?', title=' ', \
        choices=('C[o]ntinue', 'C[a]ncel'), image=None,
        default_choice='C[o]ntinue', cancel_choice='C[a]ncel')
    ynbox(msg='Shall I continue?', title=' ', \
    choices=('[<F1>]Yes', '[<F2>]No'), image=None,
    default_choice='[<F1>]Yes', cancel_choice='[<F2>]No')其实ynbox和ccbox一样的功能。

    buttonbox(msg='', title=' ', choices=('Button[1]',
    'Button[2]', 'Button[3]'), image=None, images=None,
    default_choice=None, cancel_choice=None, callback=None, run=True)

    easygui.choicebox()
    choicebox(msg='Pick an item', title='', choices=[],\
    preselect=0, callback=None, run=True)

    multchoicebox(msg='Pick an item', title='',\
    choices=[], preselect=0, callback=None, run=True) preselect:预选

    让用户输入消息
    enterbox(msg='Enter something.', title=' ',、
    default='', strip=True, image=None, root=None)
    保留首尾空格的话请设置参数 strip=False

    essygui.integerbox(msg='', title=' ', default=None,、
    lowerbound=0, upperbound=99, image=None, root=None)
    整型数值,否则会要求用户重新输入

    essygui.multpasswordbox()
    essygui.multpasswordbox() 跟 multenterbox() 使用相同的接口,
    但当它显示的时候,最后一个输入框显示为密码的形式(*)

    显示文本
    textbox(msg='', title=' ', text='', codebox=False, callback=None, run=True)
    textbox() 函数默认会以比例字体(参数 codebox=True 设置为等宽字体)来显示文本内容(自动换行)

    essygui.codebox(msg='', title=' ', text='')
    essygui.codebox() 以等宽字体显示文本内容(不自动换行),
    相当于 textbox(codebox=True)

    文件打开目录
    diropenbox(msg=None, title=None, default=None)
    default 参数用于设置默认的打开目录(请确保设置的目录已存在)
    如果用户选择 “Cancel” 则返回 None

    essygui.fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=False)
    default 参数指定一个默认路径,通常包含一个或多个通配符。
    如果设置了 default 参数,fileopenbox() 显示默认的文件路径和格式。
    default 默认的参数是 '*',即匹配所有格式的文件。
    例如:
        default="c:/fishc/*.py" 即显示 C:\fishc 文件夹下所有的 Python 文件。
        default="c:/fishc/test*.py" 即显示 C:\fishc 文件夹下所有的名字以 test 开头的 Python 文件。
    最后是 multiple 参数,如果为 True 则表示可以同时选择多个文件。

    essygui.filesavebox(msg=None, title=None, default='', filetypes=None)
    用于选择文件需要保存的路径(带完整路径哦)

    EasyGUI 通过 exceptionbox() 函数提供了更好的方式去处理异常。
    exceptionbox() 会将堆栈追踪显示在一个 codebox() 中,并且允许你做进一步的处理
'''

# import easygui
# easygui.egdemo()
import easygui
import sys
choices = ['愿意', '不愿意', '有钱的时候就愿意']
reply = easygui.choicebox('你愿意购买资源打包支持小甲鱼吗?', choices = choices)
easygui.buttonbox(msg='选个你喜欢吃的水果吧!', title='buttonbox窗口',\
 choices=('香蕉', '蓝莓', '苹果', '橘子'), image=None, images="蓝屏bug.png",\
 default_choice="香蕉", cancel_choice="橘子", callback=None, run=True)
easygui.enterbox(msg='请输入你想输入的文字', title='输入文本 ', default='这是个输入例子', strip=True, image=None, root=None)
easygui.msgbox("Hello, world!", "一个尝试的窗口")
easygui.msgbox("我一定要学会编程!", ok_button="加油!")
easygui.integerbox(msg='整数输入框', title='标题框', default=None, lowerbound=0, upperbound=99, image=None, root=None)
easygui.multenterbox(msg='如果用户取消操作,则返回域中的列表的值或者 None 值', title='为用户提供多个简单的输入框',\
 fields=['香蕉', '蓝莓', '苹果', '橘子'], values=[45], callback=None, run=True)
easygui.passwordbox(msg='passwordbox() 跟 enterbox() 样式一样', title='输入的内容用星号(*)', default='1997',\
 image=None, root=None)
# 如何多项不填写,则返回['', '', '',]list包含fields相同数目''。
easygui.multpasswordbox(msg='登录得多窗口信息框', title='登录', fields=("用户名", "密码"), values=("", "1997"),\
 callback=None, run=True)
easygui.textbox(msg='以下可以输入一个文本框', title='文本框输入,文本内容(自动换行)',\
 text=["你真的帅!", "不好意思,打扰了。", "你真的欠打,哈哈。", "无语,还不努你学习 "], codebox=False)
# 实现对用户的设置进行存储和恢复这一过程,EasyGUI 提供了一个叫做 EgStore 的类
#使用 settings.store() 方法在硬盘上持久化保存
'''
  class Settings(EgStore):

    def __init__(self, filename):  # 需要指定文件名
        # 指定要记住的属性名称
        self.author = ""
        self.book = ""

        # 必须执行下面两个语句
        self.filename = filename
        self.restore()

'''

完整的请查看:
https://fishc.com.cn/thread-46069-1-1.html

或者:

https://github.com/robertlugg/easygui

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值