本文整理汇总了Python中gooey.GooeyParser类的典型用法代码示例。如果您正苦于以下问题:Python GooeyParser类的具体用法?Python GooeyParser怎么用?Python GooeyParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GooeyParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: arbitrary_function
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(
'foo',
metavar=u"\u0432\u044b\u0431\u043e\u0440\u0430\u0444\u0430\u0439\u043b\u043e\u0432",
help=file_help_msg,
widget="FileChooser")
my_cool_parser.add_argument(
'bar',
metavar=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")
my_cool_parser.add_argument(
'-d',
metavar=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',
metavar=u'--\u043a\u0440\u043e\u043d \u002d \u0433\u0440\u0430\u0444\u0438\u043a',
help=u'\u0414\u0430\u0442\u0430',
widget='DateChooser')
args = my_cool_parser.parse_args()
main(args)
示例2: main
def main():
parser = GooeyParser(prog="example_progress_bar_1")
_ = parser.parse_args(sys.argv[1:])
for i in range(100):
print("progress: {}%".format(i + 1))
sys.stdout.flush()
sleep(0.1)
示例3: main
def main():
desc = "Example application to show Gooey's various widgets"
parser = GooeyParser(prog="example_progress_bar_1")
_ = parser.parse_args(sys.argv[1:])
import time
time.sleep(1)
print('Success')
示例4: _parser
def _parser():
parser = GooeyParser(description='Look up an object in VizieR'
' and print mean/median'
' values of given parameters')
parser.add_argument('object', help='Object, e.g. HD20010', nargs='+')
parser.add_argument('-p', '--params', default=True, action='store_true',
help='List of parameters (Teff, logg, [Fe/H] be default)')
parser.add_argument('-m', '--method', choices=['median', 'mean', 'both'], default='both',
help='Which method to print values (mean or median). Default is both')
parser.add_argument('-c', '--coordinate', default=False, action='store_true',
help='Return the RA and DEC (format for NOT\'s visibility plot)')
return parser.parse_args()
示例5: main
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
def main():
parser = GooeyParser(
prog='',
description="Detecting rare cell-types from single-cell "
"gene expression data",
epilog="Contributors: Lan Jiang, "
"Qian Zhu and Gregory Giecold.\nFor further help or information, "
"please contact us at [email protected],"
"[email protected] or [email protected]")
subparsers = parser.add_subparsers(dest='datatype',
help="Type of your input genomics dataset")
qPCR_parser = subparsers.add_parser('qpcr')
qPCR_parser.add_argument('Input', type=str, widget='FileChooser',
help='Select a file to process:')
qPCR_parser.add_argument('-e', '--epsilon', nargs='?',
type=float, const=0.25, default=0.25,
help='DBSCAN epsilon parameter:')
qPCR_parser.add_argument('-m', '--minPts', nargs='?',
type=int, const=5, default=5,
help='DBSCAN minPts parameter:')
qPCR_parser.add_argument('-O', '--Output', nargs='?', type=str,
default=path.join(getcwd(), 'GiniClust_results'),
help="Specify GiniClust's output directory:")
RNASeq_parser = subparsers.add_parser('rna')
RNASeq_parser.add_argument('Input', type=str, widget='FileChooser',
help='Select a file to process:')
RNASeq_parser.add_argument('-e', '--epsilon', nargs='?',
type=float, const=0.5, default=0.5,
help='DBSCAN epsilon parameter:')
RNASeq_parser.add_argument('-m', '--minPts', nargs='?',
type=int, const=3, default=3,
help='DBSCAN minPts parameter:')
RNASeq_parser.add_argument('-O', '--Output', nargs='?', type=str,
default=path.join(getcwd(), 'GiniClust_results'),
help="Specify GiniClust's output directory:")
command = 'Rscript'
path2Rscript = path.join(getcwd(), 'GiniClust_Main.R')
args = parser.parse_args()
if args.datatype == 'qpcr':
datatype_str = 'qPCR'
else:
datatype_str = 'RNA-seq'
cmd = [command, path2Rscript]
cmd += ['-f', args.Input, '-t', datatype_str, '-o', args.Output, '-e', str(args.epsilon), '-m', str(args.minPts)]
subprocess.check_output(cmd, universal_newlines=True)
示例7: _parser
def _parser():
'''The argparse stuff'''
parser = GooeyParser(description='CRIRES spectrum to an 1D spectrum')
parser.add_argument('fname', action='store', widget='FileChooser', help='Input fits file')
parser.add_argument('--output', default=False,
help='Output to this name. If nothing is given, output will be: "wmin-wmax.fits"')
parser.add_argument('-u', '--unit', default='angstrom',
choices=['angstrom', 'nm'],
help='The unit of the output wavelength')
parser.add_argument('-c', '--clobber', default=True, action='store_false',
help='Do not overwrite existing files.')
args = parser.parse_args()
return args
示例8: main
def main():
parser = GooeyParser(description="PowerPoint Exporter")
parser.add_argument('powerpoint', widget="FileChooser")
parser.add_argument('output', help="Folder to place resulting images", widget="DirChooser")
parser.add_argument('width', help="Width of resulting image (0-3072)")
parser.add_argument('height', help="Height of resulting image (0-3072)")
args = parser.parse_args()
if not (os.path.isfile(args.powerpoint) and os.path.isdir(args.output)):
raise "Invalid paths!"
export_presentation(args.powerpoint, args.output, args.width, args.height)
print "Done!"
示例9: main
def main():
print 'minUP GUI'
desc = \
'A program to analyse minION fast5 files in real-time or post-run.'
print desc
parser = GooeyParser(description=desc)
for x in xs[1:]:
if len(x) > 1:
mkWidget(parser, x, settings)
# This is updated every time to update the values of the variables...
try:
vs = vars(parser.parse_args())
with open('settings.json', 'w') as f:
# print json.dumps(vs, indent=4, sort_keys=True)
f.write(json.dumps(vs, indent=4, sort_keys=True))
except:
return ()
# Build a dict of the var:vals
print '------------------'
ps = []
for k in vs:
ps.append(('-' + lut[k], toStr(vs[k])))
ps = map(fixAligner, ps)
aligner = vs['Aligner_to_Use']
ps = map(lambda o: fixAlignerOpts(aligner, o), ps)
ps = sorted(filter(isActive, ps))
params = ' '.join(map(showParam, ps))
# cmd = 'ls /a'
# cmd = 'c:\Python27\python.exe .\minup.v0.63.py ' +params
cmd = '.\\minUP.exe ' + params # + ' 2>&1'
print cmd
'''
fl = open("cmd.sh", 'w')
fl.write(cmd)
fl.close()
'''
run(cmd)
示例10: parse_args_gooey
def parse_args_gooey():
'''parse command line arguments'''
parser = GooeyParser(description="Convert pgm image to png or jpg")
parser.add_argument("directory", default=None,
help="directory containing PGM image files", widget='DirChooser')
parser.add_argument("--output-directory", default=None,
help="directory to use for converted files", widget='DirChooser')
parser.add_argument("--format", default='png', choices=['png', 'jpg'], help="type of file to convert to (png or jpg)")
return parser.parse_args()
示例11: main
def main():
# get some settings from setting file
settings = SettingFileReader()
defaultOutput = settings.getSetting("defaultSettings", "output")
defaultWidth = settings.getSetting("defaultSettings", "width")
defaultFramerate = settings.getSetting("defaultSettings", "framerate")
defaultBitrateKb = settings.getSetting("defaultSettings", "bitratekb")
description = "Download tracks and playlists from Youtube."
#parser = argparse.ArgumentParser(description=description)
parser = GooeyParser(description=description)
parser.add_argument('-output', required=True, help='Folder to save the tracks' , widget="DirChooser")
parser.add_argument('-track', required=False, default=None, help='Youtube track ID' )
parser.add_argument('-playlist', required=False, default=None, help='Youtube playlist ID' )
parser.add_argument('-audio', action="store_true", default=False, help="Download only the audio part (usualy m4a format)")
args = parser.parse_args()
# the user must have chosen between a track and a Playlist.
# Though none of them is mandatory, so we have to check.
if(not args.track and not args.playlist):
print("[ERROR] You must fill at least one of those fields:\n\t- Track - to download a single track\n\t- Playlist - to download a entire playlist")
else:
pw = PafyWrapper()
# download a track
if(args.track):
try:
pw.downloadTrack(args.track, path=args.output, audio=args.audio)
except ValueError as e:
print("[INVALID URL]" + e)
if(args.playlist):
#try:
print(args.playlist)
pw.downloadPlaylist(args.playlist, path=args.output, audio=args.audio)
示例12: main
def main():
my_cool_parser = GooeyParser(description='This Demo will raise an error!')
my_cool_parser.add_argument(
"explode",
metavar='Should I explode?',
help="Determines whether or not to raise the error",
choices=['Yes', 'No'],
default='Yes')
args = my_cool_parser.parse_args()
if 'yes' in args.explode.lower():
print('Will throw error in')
for i in range(5, 0, -1):
print(i)
time.sleep(.7)
raise Exception(BOOM)
print(NO_BOOM)
print('No taste for danger, eh?')
示例13: main
def main():
parser = GooeyParser(description="Compares Images!")
parser.add_argument('directoryName', help="Name of the directory to process.", widget = "DirChooser")
parser.add_argument('masterName', help="Name of the master image. Please put master image in the chosen directory.", widget = "FileChooser")
parser.add_argument('--showOriginalImage', help = "(optional), default is False", nargs = "?", default = False)
parser.add_argument('--showRegionOfInterest', help = "(optional), default is true", nargs = "?", default = True)
parser.add_argument('--verbose', help = "Show Full Information, default is False", nargs = "?", default = False)
# parser.add_argument('outputFileName', help="name of the output file")
# parser.add_argument('extension', help = "(optional)name of extension (ex: JPG)")
args = parser.parse_args()
test_dirj = args.directoryName
masterName = args.masterName
showOriginalImage = args.showOriginalImage
showRegionOfInterest = args.showRegionOfInterest
if showOriginalImage == False:
showOriginalImage = False
else:
showOriginalImage = True
if showRegionOfInterest == True or showRegionOfInterest == "True" or showRegionOfInterest == "true":
showRegionOfInterest = True
else:
showRegionOfInterest = False
verbose = args.verbose
if verbose != False or verbose != "false" or verbose != "False":
verbose = True
else:
verbose = False
# extensionFinal = pconfig.extension if (extension == "") else ("*" + extension)
extensionFinal = pconfig.extension
controlInfo = imageProcessor(masterName, test_dirj, showOriginalImage, showRegionOfInterest, verbose = verbose, control = True)
controlScore = controlInfo[1]
info = []
for fileName in glob.glob(os.path.join(test_dirj, extensionFinal)):
if fileName.lower() != os.path.join(test_dirj, masterName).lower():
imageInfo = imageProcessor(fileName, test_dirj, showOriginalImage, showRegionOfInterest, controlScore = controlScore)
info.append(imageInfo)
print "Output File Name:" + writeInfo(info,test_dirj, controlInfo)
print "done"
示例14: main
def main():
parser = GooeyParser(description='Package your Gooey applications into standalone executables')
parser.add_argument(
"program_name",
metavar='Program Name',
help='Destination name for the packaged executable'
)
parser.add_argument(
"source_path",
metavar="Program Source",
help='The main source file of your program',
widget="FileChooser"
)
parser.add_argument(
"output_dir",
metavar="Output Directory",
help='Location to store the generated files',
widget="DirChooser"
)
args = parser.parse_args()
if not os.path.exists(args.source_path):
raise IOError('{} does not appear to be a valid file path'.format(args.source_path))
if not os.path.exists(args.output_dir):
raise IOError('{} does not appear to be a valid directory'.format(args.output_dir))
with open(os.path.join(local_path(), 'build_template'), 'r') as f:
spec_details = f.read().format(program_name=args.program_name, source_path=args.source_path)
fileno, path = tempfile.mkstemp(prefix='gooeybuild', suffix='.spec')
with open(path, 'w') as f:
f.write(spec_details)
cmd = 'pyinstaller "{0}" --distpath="{1}"'.format(path, args.output_dir)
print cmd
from pexpect.popen_spawn import PopenSpawn
child = PopenSpawn(cmd)
child.logfile = sys.stdout
child.wait()
print dedent('''
___ _ _ ______ _
/ _ \| | | | _ \ | |
/ /_\ \ | | | | | |___ _ __ ___| |
| _ | | | | | | / _ \| '_ \ / _ \ |
| | | | | | | |/ / (_) | | | | __/_|
\_| |_/_|_| |___/ \___/|_| |_|\___(_)
''')
print 'Wrote Executable file to {}'.format(args.output_dir)
示例15: main
def main():
mk_savedir() # Make directory to store user's save files
parser = GooeyParser(
description='An example of polling for updates at runtime')
g = parser.add_argument_group()
stuff = g.add_mutually_exclusive_group(
required=True,
gooey_options={
'initial_selection': 0
}
)
stuff.add_argument(
'--save',
metavar='Save Progress',
action='store_true',
help='Take a snap shot of your current progress!'
)
stuff.add_argument(
'--load',
metavar='Load Previous Save',
help='Load a Previous save file',
dest='filename',
widget='Dropdown',
choices=list_savefiles(),
gooey_options={
'validator': {
'test': 'user_input != "Select Option"',
'message': 'Choose a save file from the list'
}
}
)
args = parser.parse_args()
if args.save:
save_file()
else:
read_file(os.path.join('saves', args.filename))
print('Finished reading file!')