与 Gooey 模块一起使用时功能不起作用
Function not working when using it with Gooey module
我正在尝试为 zip 文件提取功能创建 GUI 我确实使用了 zipfile
模块。我是第一次使用Gooey
,我按照文档实现了我想要的,GUI 似乎没问题,但提取功能不起作用。我不知道我错过了什么。任何帮助,将不胜感激!这是正在处理的代码。
from zipfile import ZipFile
from gooey import Gooey, GooeyParser
def extract_all_files(files, path_to_extract_to):
with ZipFile(files, 'r') as file:
file.extractall(path_to_extract_to)
@Gooey(program_name="Archive Manager", program_description="Extract files")
def parse_args():
parser = GooeyParser()
subparsers = parser.add_subparsers(required=True)
extractor = subparsers.add_parser("Extract", help="Extract zip files")
extractor.add_argument('input_file', widget="FileChooser", help="File to extract")
extractor.add_argument('output_file', widget="DirChooser", help="Extracted file location")
return parser.parse_args()
@Gooey
def main():
args = parse_args()
files = args.input_file
path = args.output_file
extract_all_files(files, path)
if __name__ == "__main__":
main()
只需取消注释或删除 Decorator 函数行,程序就会开始运行,我不知道为什么,但是 gooey decorator 有问题!
https://github.com/chriskiehl/Gooey/issues/144
作者也建议在调试时关闭装饰器
Decorator 用于更改函数的功能,以便更改程序名称和程序描述转到它已安装的目录,并将默认程序名称和描述更改为您的。
我正在尝试为 zip 文件提取功能创建 GUI 我确实使用了 zipfile
模块。我是第一次使用Gooey
,我按照文档实现了我想要的,GUI 似乎没问题,但提取功能不起作用。我不知道我错过了什么。任何帮助,将不胜感激!这是正在处理的代码。
from zipfile import ZipFile
from gooey import Gooey, GooeyParser
def extract_all_files(files, path_to_extract_to):
with ZipFile(files, 'r') as file:
file.extractall(path_to_extract_to)
@Gooey(program_name="Archive Manager", program_description="Extract files")
def parse_args():
parser = GooeyParser()
subparsers = parser.add_subparsers(required=True)
extractor = subparsers.add_parser("Extract", help="Extract zip files")
extractor.add_argument('input_file', widget="FileChooser", help="File to extract")
extractor.add_argument('output_file', widget="DirChooser", help="Extracted file location")
return parser.parse_args()
@Gooey
def main():
args = parse_args()
files = args.input_file
path = args.output_file
extract_all_files(files, path)
if __name__ == "__main__":
main()
只需取消注释或删除 Decorator 函数行,程序就会开始运行,我不知道为什么,但是 gooey decorator 有问题!
https://github.com/chriskiehl/Gooey/issues/144
作者也建议在调试时关闭装饰器
Decorator 用于更改函数的功能,以便更改程序名称和程序描述转到它已安装的目录,并将默认程序名称和描述更改为您的。