我有一个基于 CLI 的简单程序,我想向其中添加 GUI。最好我也希望保留通过 CLI 运行此脚本的能力。如果可以做到这一点,解决这个问题的最佳方法是什么?免责声明:我对 Tkinter 还比较陌生!
from argparse import ArgumentParser
from ipaddress import IPv4Network
def Main():
""" Main Program """
parser = ArgumentParser(
description='Provided a list of IP addresses, format and output the correct fortigate commands to create them')
parser.add_argument('VDOM', help='Specify a VDOM', type=str)
parser.add_argument(
'File', help='Specify a file. Each entry should be on its own line, and have no extra characters', typ=str)
args = parser.parse_args()
with open(args.File, 'r') as input_file:
array = input_file.read().splitlines()
with open(args.vdom + '.txt', …Run Code Online (Sandbox Code Playgroud) python user-interface tkinter command-line-interface argparse