Python胶

2024-04-20 12:40:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python脚本,使用Gooey。你知道吗

举个例子:

import argparse
from gooey import Gooey, GooeyParser

@Gooey
def main(): 
    parser = GooeyParser()

    parser.add_argument('--arg1', dest='arg1', action='store_true', help='Here is a description of this argument')
    parser.set_defaults(arg1=True)

    parser.add_argument('--arg2', dest='arg2', action='store_true', help='Here is a description of this other argument')
    parser.set_defaults(arg1=True)

    parser.add_argument('--arg3', dest='arg3', action='store_true', help='Here is a description of yet another argument')
    parser.set_defaults(arg1=True)

    # ... etc

    parser.parse_args()


if __name__ == "__main__":
   main()

我有很多布尔参数。现在,其中的每一个都在GUI中显示为:

[blank line]
arg_name
[blank line]
[CHECKBOX] Here is a description of this argument
[blank line]

一遍又一遍地重复。这会占用很多空间。有没有办法浓缩所有这些,让我得到:

[CHECKBOX] Here is a description of this argument
[CHECKBOX] Here is a description of this other argument
[CHECKBOX] Here is a description of yet another argument
...

Tags: ofstoreaddparserhereismainaction