【问题标题】:Function not working when using it with Gooey module与 Gooey 模块一起使用时功能不起作用
【发布时间】:2021-09-11 19:19:08
【问题描述】:

我正在尝试使用 zipfile 模块的 zip 文件提取功能的 GUI。这是我第一次使用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()


【问题讨论】:

  • 抱歉,“停止工作”不是有效的、可行的问题陈述。
  • @JonathonReinhart 我的意思是,该功能本身就可以工作,但是当我将它与粘糊糊的东西集成时,它就不行了;t。因为我是新手,所以我希望你们中的一个人能对它有所了解。

标签: python zipfile


【解决方案1】:

只需取消注释或删除装饰器功能行,程序将开始工作,我不知道为什么但是粘糊糊的装饰器有问题!

https://github.com/chriskiehl/Gooey/issues/144

作者还建议在调试的时候关闭装饰器。

装饰器用于更改函数的功能,以便更改程序名称和程序描述转到已安装的目录并更改默认程序名称,使用您的描述。

【讨论】:

  • 是的,这就是问题所在。不知道装修师傅有这样的问题。非常感谢!
猜你喜欢
  • 1970-01-01
  • 2021-01-03
  • 2021-02-13
  • 2016-08-31
  • 1970-01-01
  • 2018-11-22
  • 1970-01-01
  • 1970-01-01
  • 2021-11-25
相关资源
最近更新 更多