基于小甲鱼的PyCharm EasyGUI模块的基本使用

本文介绍了如何在PyCharm的Python控制台环境中使用easygui模块进行各种交互操作,包括按钮、消息框、选择对话框等,并展示了文件打开与保存的相关函数。
摘要由CSDN通过智能技术生成

获取: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"])#保存函数:选中一个文件然后选择保存位置

  • 17
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
PyCharm 是一款强大的集成开发环境,可以用于开发不同类型的项目,包括 Python。在 PyCharm 中,我们可以使用 wget 模块来下载文件。 wget 是一个命令行工具,用于从 Web 上下载文件。在 PyCharm 中,我们可以使用 wget 模块来模拟 wget 命令的功能。使用 wget 模块下载文件非常简单,可以按照以下步骤操作: 首先,我们需要确保已经安装了 wget 模块。可以在 PyCharm 的终端中使用pip install wget安装。 接下来,我们可以在 Python 代码中导入 wget 模块,通过调用 wget.download() 方法来下载文件。下载方法中需要指定文件的 URL 和保存路径。 例如,我们可以使用以下代码来下载一个名为 "example.txt" 的文件: ``` import wget url = 'https://www.example.com/example.txt' save_path = '/path/to/save/example.txt' wget.download(url, save_path) ``` 在上述代码中,我们首先导入了 wget 模块。然后,我们指定了要下载的文件的 URL 和要保存的路径,并调用 wget.download() 方法来下载文件。 下载完成后,我们可以在指定的路径中找到下载的文件。通过使用 wget 模块,我们可以方便地实现在 PyCharm 中下载文件的功能。 总而言之,PyCharm 中的 wget 模块可以帮助我们在 Python 代码中下载文件。通过导入 wget 模块,并使用 wget.download() 方法,我们可以轻松地下载文件,并在指定路径中找到下载的文件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值