python-Gooey速成GUI程序

1,195 阅读1分钟

1.安装需要的库

  • pip install Gooey

2.导入需要的库

  • from gooey import Gooey, GooeyParser

3.代码部分

    richtext_controls=True,  # 打开终端对颜色支持
    language='chinese',
    header_show_title=False,
    program_name="处理工具v1.0",  # 程序名称
    encoding="utf-8",  # 设置编码格式,打包的时候遇到问题
    #progress_regex=r"^progress: (\d+)%$",  # 正则,用于模式化运行时进度信息
    default_size=(650, 555),
    
    #progress_regex=r"^progress: (?P<current>\d+)/(?P<total>\d+)$",
    
    progress_expr="current / total * 100",
    # 再次执行,清除之前执行的日志
    clear_before_run = True,
    timing_options = {'show_time_remaining':True,'hide_time_remaining_on_complete':False}  
)

def main():
    desc = "工具说明:"+"\n"+"   "+"1.本工具仅作为xxx使用"+"\n"+"
    file_help_msg = "help..."
    
    my_cool_parser = GooeyParser(description=desc)  
    
    my_cool_parser.add_argument(option_strings=['-u', '--username'],dest='账号', widget="TextField")
    my_cool_parser.add_argument(option_strings=['-p', '--password'],dest='密码', widget="TextField")
    my_cool_parser.add_argument(option_strings=['-v', '--verify_number'],dest='验证码', widget="TextField")
    my_cool_parser.add_argument(option_strings=['-f', '--file_path'], dest="待匹配文件路径", widget="FileChooser")
    
    # 获取参数
    args = my_cool_parser.parse_args() 
    print(args)
    
 
def here_is_more():
    pass

4.Demo

image.png

image.png

5.可以使用

  • PyInstaller 打包成exe...