本文整理汇总了Python中gooey.GooeyParser.add_mutually_exclusive_group方法的典型用法代码示例。如果您正苦于以下问题:Python GooeyParser.add_mutually_exclusive_group方法的具体用法?Python GooeyParser.add_mutually_exclusive_group怎么用?Python GooeyParser.add_mutually_exclusive_group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gooey.GooeyParser
的用法示例。
在下文中一共展示了GooeyParser.add_mutually_exclusive_group方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: arbitrary_function
# 需要导入模块: from gooey import GooeyParser [as 别名]
# 或者: from gooey.GooeyParser import add_mutually_exclusive_group [as 别名]
def arbitrary_function():
desc = "Example application to show Gooey's various widgets"
file_help_msg = "Name of the file you want to process"
my_cool_parser = GooeyParser(description=desc)
# my_cool_parser.add_argument("FileChooser", help=file_help_msg, widget="FileChooser") # positional
# my_cool_parser.add_argument("DirectoryChooser", help=file_help_msg, widget="DirChooser") # positional
# my_cool_parser.add_argument("FileSaver", help=file_help_msg, widget="FileSaver") # positional
# my_cool_parser.add_argument("MultiFileSaver", help=file_help_msg, widget="MultiFileChooser") # positional
# my_cool_parser.add_argument("directory", help="Directory to store output") # positional
my_cool_parser.add_argument('-c', '--countdown', default=2, type=int, help='sets the time to count down from you see its quite simple!')
my_cool_parser.add_argument('-j', '--cron-schedule', type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
my_cool_parser.add_argument('-v', '--verbose', action='count')
my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
verbosity = my_cool_parser.add_mutually_exclusive_group()
verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
print my_cool_parser._actions
print 'inside of main(), my_cool_parser =', my_cool_parser
args = my_cool_parser.parse_args()
main(args)
示例2: main
# 需要导入模块: from gooey import GooeyParser [as 别名]
# 或者: from gooey.GooeyParser import add_mutually_exclusive_group [as 别名]
def main():
desc = "Example application to show Gooey's various widgets"
file_help_msg = "Name of the file you want to process"
my_cool_parser = GooeyParser(description=desc)
my_cool_parser.add_argument("FileChooser", help=file_help_msg, widget="FileChooser") # positional
my_cool_parser.add_argument("DirectoryChooser", help=file_help_msg, widget="DirChooser") # positional
my_cool_parser.add_argument("FileSaver", help=file_help_msg, widget="FileSaver") # positional
my_cool_parser.add_argument("MultiFileSaver", help=file_help_msg, widget="MultiFileChooser") # positional
my_cool_parser.add_argument("MultiDirChooser", help=file_help_msg, widget="MultiDirChooser") # positional
my_cool_parser.add_argument("directory", help="Directory to store output") # positional
my_cool_parser.add_argument('-d', '--duration', default=2, type=int, help='Duration (in seconds) of the program output')
my_cool_parser.add_argument('-s', '--cron-schedule', type=int, help='datetime when the cron should begin', widget='DateChooser')
my_cool_parser.add_argument("-c", "--showtime", action="store_true", help="display the countdown timer")
my_cool_parser.add_argument("-p", "--pause", action="store_true", help="Pause execution")
my_cool_parser.add_argument('-v', '--verbose', action='count')
my_cool_parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite output file (if present)")
my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
my_cool_parser.add_argument("-w", "--writelog", default="writelogs", help="Dump output to local file")
my_cool_parser.add_argument("-e", "--error", action="store_true", help="Stop process on error (default: No)")
verbosity = my_cool_parser.add_mutually_exclusive_group()
verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
args = my_cool_parser.parse_args()
display_message()
示例3: arbitrary_function
# 需要导入模块: from gooey import GooeyParser [as 别名]
# 或者: from gooey.GooeyParser import add_mutually_exclusive_group [as 别名]
def arbitrary_function():
desc = u"\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u002c \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c "
file_help_msg = u"\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430\u002c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c"
my_cool_parser = GooeyParser(description=desc)
my_cool_parser.add_argument(
u"\u0432\u044b\u0431\u043e\u0440\u0430\u0444\u0430\u0439\u043b\u043e\u0432",
help=file_help_msg,
widget="FileChooser",
) # positional
my_cool_parser.add_argument(
u"\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c",
help=file_help_msg,
widget="MultiFileChooser",
) # positional
my_cool_parser.add_argument(
"-d",
u"--\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c",
default=2,
type=int,
help=u"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0028 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0029 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b",
)
my_cool_parser.add_argument(
"-s",
u"--\u043a\u0440\u043e\u043d \u002d \u0433\u0440\u0430\u0444\u0438\u043a",
type=int,
help=u"\u0414\u0430\u0442\u0430",
widget="DateChooser",
)
my_cool_parser.add_argument("-c", "--showtime", action="store_true", help="display the countdown timer")
my_cool_parser.add_argument("-p", "--pause", action="store_true", help="Pause execution")
my_cool_parser.add_argument("-v", "--verbose", action="count")
my_cool_parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite output file (if present)")
my_cool_parser.add_argument("-r", "--recursive", choices=["yes", "no"], help="Recurse into subfolders")
my_cool_parser.add_argument("-w", "--writelog", default="writelogs", help="Dump output to local file")
my_cool_parser.add_argument("-e", "--error", action="store_true", help="Stop process on error (default: No)")
verbosity = my_cool_parser.add_mutually_exclusive_group()
verbosity.add_argument("-t", "--verbozze", dest="verbose", action="store_true", help="Show more details")
verbosity.add_argument("-q", "--quiet", dest="quiet", action="store_true", help="Only output on error")
# print my_cool_parser._actions
# print 'inside of main(), my_cool_parser =', my_cool_parser
args = my_cool_parser.parse_args()
main(args)
示例4: main
# 需要导入模块: from gooey import GooeyParser [as 别名]
# 或者: from gooey.GooeyParser import add_mutually_exclusive_group [as 别名]
def main():
'''
does stuff with parser.parse_args()
'''
desc = "Mock application to test Gooey's functionality"
file_help_msg = "Name of the file you want to process"
my_cool_parser = GooeyParser(description=desc)
my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser") # positional
my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output") # positional
# my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!', widget='DateChooser')
my_cool_parser.add_argument('-c', '--cron-schedule', default=10, type=int, help='Set the datetime when the cron should begin', widget='DateChooser')
my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
my_cool_parser.add_argument('-v', '--verbose', action='count')
my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders')
my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes")
verbosity = my_cool_parser.add_mutually_exclusive_group()
verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
print my_cool_parser._actions
print 'inside of main(), my_cool_parser =', my_cool_parser
args = my_cool_parser.parse_args()
print sys.argv
print args.countdown
print args.showtime
start_time = _time()
print 'Counting down from %s' % args.countdown
while _time() - start_time < args.countdown:
if args.showtime:
print 'printing message at: %s' % _time()
else:
print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest()
_sleep(.5)
print 'Finished running the program. Byeeeeesss!'
raise ValueError("Something has gone wrong! AHHHHHHHHHHH")
示例5: main
# 需要导入模块: from gooey import GooeyParser [as 别名]
# 或者: from gooey.GooeyParser import add_mutually_exclusive_group [as 别名]
def main():
desc = 'Converts *.spc binary files to text using the spc module'
parser = GooeyParser(description=desc)
parser.add_argument('filefolder', widget='DirChooser', help='Input directory containing spc file')
fformat = parser.add_mutually_exclusive_group()
fformat.add_argument('-c', '--csv', help='Comma separated output file (.csv) [default]',
action='store_true')
fformat.add_argument('-t', '--txt', help='Tab separated output file (.txt)',
action='store_true')
args = parser.parse_args()
if args.txt:
exten = '.txt'
delim = '\t'
else:
# defaults
exten = '.csv'
delim = ','
flist = []
# only directory here
ffn = os.path.abspath(args.filefolder)
for f in os.listdir(ffn):
flist.append(os.path.join(ffn, f))
# process files
for fpath in flist:
if fpath.lower().endswith('spc'):
foutp = fpath[:-4] + exten
try:
print(fpath, end=' ')
f = spc.File(fpath)
f.write_file(foutp, delimiter=delim)
print('Converted')
except:
print('Error processing %s' % fpath)
else:
print('%s not spc file, skipping' % fpath)
示例6: main
# 需要导入模块: from gooey import GooeyParser [as 别名]
# 或者: from gooey.GooeyParser import add_mutually_exclusive_group [as 别名]
def main():
desc = "Example application to show Gooey's various widgets"
my_cool_parser = GooeyParser(description=desc)
my_cool_parser.add_argument("Example", help="fill ", widget="FileChooser") # positional
verbosity = my_cool_parser.add_mutually_exclusive_group()
verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details")
verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error")
print my_cool_parser._actions
print 'inside of main(), my_cool_parser =', my_cool_parser
args = my_cool_parser.parse_args()
print sys.argv
print args.countdown
print args.showtime
start_time = _time()
print 'Counting down from %s' % args.countdown
while _time() - start_time < args.countdown:
if args.showtime:
print 'printing message at: %s' % _time()
else:
print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest()
_sleep(.5)
print 'Finished running the program. Byeeeeesss!'
示例7: main
# 需要导入模块: from gooey import GooeyParser [as 别名]
# 或者: from gooey.GooeyParser import add_mutually_exclusive_group [as 别名]
def main():
p = GooeyParser(
description='Post-Process RASDRviewer/RASDRproc spectrum data output files')
p.add_argument( "--version", action='version', version='%(prog)s '+DEF_VERSION)
# NB: need to order these with the most used options first
# http://stackoverflow.com/questions/20165843/argparse-how-to-handle-variable-number-of-arguments-nargs
p.add_argument( "file", widget="FileChooser")
p.add_argument('-b', '--background', type=str, metavar='PATH', default='', widget="FileChooser",
help='Specify how to perform background subtraction;'+
'if the word automatic is used, then the background will be taken'+
'from the average of all lines in the file. Otherwise, it is taken'+
'as a file to process. The file must have the same frequency plan as the foreground file.')
p.add_argument('-a', '--average', type=int, metavar='N', default=DEF_AVERAGE,
help='Specify the number of spectra to average for each plot')
p.add_argument('-s', '--smooth', type=int, metavar='N', default=0,
help='Smooth final plot using a sliding window of N points')
p.add_argument('--fcenter', dest='fc', type=float, default=0.0,
help='Define the offset for the center frequency in Hz') #default=%f'%0.0)
p.add_argument('--statistics', type=str, metavar='PATH', default=None, widget="FileChooser",
help='Dump statistical information to a file in comma-separated-values format')
p.add_argument('-i', '--info', action='store_true', default=False,
help='Produce information about a file only; do not generate any plots')
p.add_argument('-g', '--gui', action='store_true', default=False,
help='Create interactive PLOTS')
g = p.add_mutually_exclusive_group()
g.add_argument("-v", "--verbose", default=False, help="Turn on verbose output", action="store_true")
g.add_argument("-q", "--quiet", default=False, help='Suppress progress messages', action="store_true")
# call matplotlib.use() only once
p.set_defaults(matplotlib_use = False)
p.add_argument('-c', '--cancel-dc', dest='canceldc', action='store_true', default=False,
help='Cancel out component at frequency bin for 0Hz')
p.add_argument('-d', '--delimiter', type=str, metavar='CHAR', default=DEF_DELIM,
help='Specify the delimiter character to use"')
p.add_argument('-e', '--localtime', action='store_true', default=False,
help='Indicate that .csv file has timestamps in RASDRviewer\'s "LocalTime" format')
p.add_argument('-k', '--calibration', type=float, metavar='CONST', default=DEF_CALIB,
help='Specify the calibration constant for the system; 0.0=uncal') #default=%f'%DEF_CALIB)
p.add_argument('-l', '--line', action='store_true', default=False,
help='Perform line-by-line processing instead of loading entire file(s); NOTE: much slower but tolerates low memory better.')
## p.add_argument('-m', '--milliwatt', dest='dbm', action='store_true', default=False,
## help='Plot in decibels referenced to 1mW (dBm/Hz)')
## p.add_argument('-t', '--datetime', action='store_true', default=False,
## help='Indicate that timestamps in the .csv file are in Excel\'s datetime format')
p.add_argument('--debug', action='store_true', default=False,
help='Drop into ipython shell at predefined point(s) to debug the script')
p.add_argument('--hold', action='store_true', default=False,
help='Perform a maximum value HOLD during averaging and plot it as a second line')
p.add_argument('--bplot', action='store_true', default=False,
help='If using background file, choose whether to plot the background reference in a difffert color')
p.add_argument('--ptype', type=str, metavar='TYPE', default='log',
help='Control plot vertical scale (linear or log)')
p.add_argument('--atype', type=str, metavar='TYPE', default='log',
help='Control averaging method (linear or log)')
# http://www.dtic.mil/dtic/tr/fulltext/u2/657404.pdf
## for handling RASDRviewer versions
v = DEF_VERSION.split('.')
ver = v[0]+'.'+v[1]+'.'+v[2]
p.add_argument('--format', type=str, metavar='X.Y.Z', default=ver,
help='Specify the RASDRviewer .csv output format to interpret')
opts = p.parse_args(sys.argv)
execute(opts)
示例8: main
# 需要导入模块: from gooey import GooeyParser [as 别名]
# 或者: from gooey.GooeyParser import add_mutually_exclusive_group [as 别名]
def main():
desc = "Example application to show Gooey's various widgets"
parser = GooeyParser(description=desc, add_help=False)
parser.add_argument('--textfield', default=2, widget="TextField", gooey_options={
'validator': {
'test': 'int(user_input) > 5',
'message': 'number must be greater than 5'
}
})
parser.add_argument('--textarea', default="oneline twoline", widget='Textarea')
parser.add_argument('--password', default="hunter42", widget='PasswordField')
parser.add_argument('--commandfield', default="cmdr", widget='CommandField')
parser.add_argument('--dropdown',
choices=["one", "two"], default="two", widget='Dropdown')
parser.add_argument('--listboxie',
nargs='+',
default=['Option three', 'Option four'],
choices=['Option one', 'Option two', 'Option three',
'Option four'],
widget='Listbox',
gooey_options={
'height': 300,
'validate': '',
'heading_color': '',
'text_color': '',
'hide_heading': True,
'hide_text': True,
}
)
parser.add_argument('-c', '--counter', default=3, action='count', widget='Counter')
#
parser.add_argument("-o", "--overwrite", action="store_true",
default=True,
widget='CheckBox')
### Mutex Group ###
verbosity = parser.add_mutually_exclusive_group(
required=True,
gooey_options={
'initial_selection': 1
}
)
verbosity.add_argument(
'--mutexone',
default=True,
action='store_true',
help="Show more details")
verbosity.add_argument(
'--mutextwo',
default='mut-2',
widget='TextField')
parser.add_argument("--filechooser", default="fc-value", widget='FileChooser')
parser.add_argument("--filesaver", default="fs-value", widget='FileSaver')
parser.add_argument("--dirchooser", default="dc-value", widget='DirChooser')
parser.add_argument("--datechooser", default="2015-01-01", widget='DateChooser')
dest_vars = [
'textfield',
'textarea',
'password',
'commandfield',
'dropdown',
'listboxie',
'counter',
'overwrite',
'mutextwo',
'filechooser',
'filesaver',
'dirchooser',
'datechooser'
]
args = parser.parse_args()
import time
time.sleep(3)
for i in dest_vars:
assert getattr(args, i) is not None
print("Success")