def test_configure_parser_default(): parser = GooeyParser() parser = configure_parser_default(parser) dummy_input = ['/test/input/dir', '/test/output/dir', '1', '2', '30.0', '300.0', '.lif'] args = parser.parse_args(dummy_input) output = list(vars(args)).sort() expected = ['input_directory', 'output_directory', 'glomeruli_channel_number', 'podocyte_channel_number', 'minimum_glomerular_diameter', 'maximum_glomerular_diameter', 'file_extension'].sort() return output == expected
def main(): parser = GooeyParser(description='Example validator') parser.add_argument('secret', metavar='Super Secret Number', help='A number specifically between 2 and 14', gooey_options={ 'validator': { 'test': '2 <= int(user_input) <= 14', 'message': 'Must be between 2 and 14' } }) args = parser.parse_args() print("Cool! Your secret number is: ", args.secret)
def main(): import sys print(sys.argv) my_cool_parser = GooeyParser(description='Hai', add_help=False) description_area = my_cool_parser.add_argument_group( "Introduction", long_intro, gooey_options={ 'show_border': False, 'show_underline': False, } ) # We need at least on description_area.add_argument( '-nothing', gooey_options={ 'visible': False, } ) categories = my_cool_parser.add_argument_group( 'Categories', description='There are 13 species of crocodiles, so there are many different ' + 'sizes of crocodile. The smallest crocodile is the dwarf crocodile. ' + 'It grows to about 5.6 feet (1.7 meters) in length and weighs 13 to 15 pounds ', gooey_options={ 'show_border': False, 'label_color': '#FF9900', 'columns': 2, # 'margin_top': 90 } ) categories.add_argument( '--parent-category', metavar='Parent Category', help='This is a very, very, very long help text ' 'to explain a very, very, very important input value. ' 'Unfortunately, the end of this long message is cropped. ', choices=['a', 'b', 'c'], required=True) args = my_cool_parser.parse_args() print("Hiya!")
def configure_parser(): """Configure parser and add user input arguments. Returns ------- args : argparse arguments Parsed user input arguments. """ parser = GooeyParser(prog='Podocyte Profiler', description=__DESCR__) parser = configure_parser_default(parser) args = parse_args(parser) return args
def configure_parser(): """Configure parser and add user input arguments. Returns ------- args : argparse arguments Parsed user input arguments. """ parser = GooeyParser(prog='Podocyte Profiler', description=__DESCR__) parser.add_argument('input_directory', widget='DirChooser', help='Folder containing files for processing.') parser.add_argument('output_directory', widget='DirChooser', help='Folder to save output analysis files.') parser.add_argument('number_of_image_channels', help='Total number of color channels in image.', type=int, default=2) return parser
def configure_parser(): """Configure parser and add user input arguments. Returns ------- args : argparse arguments Parsed user input arguments. """ parser = GooeyParser(prog='Podocyte Profiler', description=__DESCR__) parser = configure_parser_default(parser) parser.add_argument('xml_extension', help='Extension of image file format (.xml)', type=str, default='.xml') parser.add_argument('counts_directory', widget='DirChooser', help='Folder containing Fiji CellCounter files.') args = parse_args(parser) return args
def main(): import sys print("sys.argv sys.argv sys.argv sys.argv sys.argv sys.argv") print(sys.argv) print('\n\n') print(repr(sys.argv)) 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, add_help=False) my_cool_parser.add_argument('thing', default='.', widget='MultiFileChooser', help="asdfsadfasdfa sdfadf ad") # my_cool_parser.add_argument( # "region_name_list", # help="Which regions do you want to run it for?", # choices=['one' ,'two', 'three'], # nargs="+", # widget="Listbox", # # widget='Counter' # ) my_cool_parser.add_argument( "FileChooser", help=file_help_msg, ) my_cool_parser.add_argument( "Outfile", widget='FileChooser', metavar='Output Target', help='Target output file', gooey_options={'wildcard': 'Some Files (*.png)|*.png'} # gooey_options={ # 'validator': { # 'test': 'user_input == "foo"', # 'message': 'Must be a valid filename' # } # } ) my_cool_parser.add_argument( '--listboxie', metavar='Multiple selection', nargs='+', default=['Option three', 'Option four'], choices=['Option one', 'Option two', 'Option three', 'Option four'], help='Choose an action!', widget='Listbox', gooey_options={ 'height': 500, 'validate': '', 'heading_color': '', 'text_color': '', 'hide_heading': True, 'hide_text': True, }) # search_options = my_cool_parser.add_argument_group( 'Search Options', 'Customize the search options', gooey_options={ 'show_border': True, 'columns': 2 }) x = search_options.add_argument('--query', help='base search string' # , gooey_options={'full_width': True} ) search_options.add_argument('--other', help='Another option in the search group' # , gooey_options={'full_width': True} ) search_options.add_argument('--one-more', help='And another one' # , gooey_options={'full_width': True} ) search_flags = search_options.add_argument_group( 'Flags', gooey_options={'show_border': True}) search_flags.add_argument('--buy-it-now', help="Will immediately purchase if possible", action='store_true') search_flags.add_argument('--auction', help="Place bids up to PRICE_MAX", action='store_true') price_range = search_options.add_argument_group( 'Price_Range', gooey_options={'show_border': True}) price_range.add_argument('--price-min', help='min price') price_range.add_argument('--price-max', help='max price') foobar = search_options.add_mutually_exclusive_group( gooey_options={ 'title': 'Numeric Mutexes', 'show_border': False, 'label_color': '#00ff00' }) foobar.add_argument('--one', help='oneie') foobar.add_argument('--two', help='twoie') foobar.add_argument('--three', help='twoie', action='store_true') my_cool_parser.add_argument("DirChooser", help=file_help_msg, widget="DirChooser") my_cool_parser.add_argument("FileSaver", help=file_help_msg, widget="FileSaver") my_cool_parser.add_argument("MultiFileSaver", help=file_help_msg, widget="MultiFileChooser") # my_cool_parser.add_argument("MultiDirSaver", help="Directories to open", widget='MultiDirChooser') my_cool_parser.add_argument('-j', '--jaws', help='ooop', widget="MultiFileChooser", default="Yo yo!", gooey_options={ 'validator': { 'test': 'len(user_input) > 5', 'message': 'Must be over 5 chars!' } }) my_cool_parser.add_argument( '-d', '--duration', default=2, type=int, help='Duration (in seconds) of the program output') my_cool_parser.add_argument('-u', '--textarea', default="I'm on \na new line", type=str, help='A multiline textarea', widget='Textarea', gooey_options={'height': 100}) 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("-y", "--yolo", action="store_true", widget='BlockCheckbox', 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", default=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('-y', '--listboxie', # nargs='+', # choices=['hello', 'ay', 'yeah', 'boiiiii', 'wssup', 'longest', 'yeahhhboiii', 'ever'], # help='Recurse into subfolders', # widget='Listbox') 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(required=False) verbosity.add_argument('-t', '--verbozze', dest='verbose', action='store_true', help="Show more details") verbosity.add_argument( '-q', '--quiet', dest='quiet', help="Only output on error", # widget='DirChooser' ) # my_cool_parser.add_argument('--sum', dest='accumulate', action='store_const', # const=sum, default=max, # help='sum the integers (default: find the max)') import pprint # stuff = [extract(x) for x in my_cool_parser._action_groups] # mutex_groups = [group for group in my_cool_parser._mutually_exclusive_groups] # # pprint.pprint(reapply_mutex_groups(mutex_groups, stuff)) # my_cool_parser.print_help() args = my_cool_parser.parse_args() print(args) # time.sleep(5) print("Hiya!") for i in range(20): import time print('Howdy', i) time.sleep(.3)
def main(): # Get user input parser = GooeyParser(prog='Podocyte Profiler', description=__DESCR__) parser.add_argument('input_directory', widget='DirChooser', nargs='+', help='Folder containing files for processing.') parser.add_argument('output_directory', widget='DirChooser', nargs='+', help='Folder to save output analysis files.') parser.add_argument('glomeruli_channel_number', nargs='+', help='Fluorescence channel with glomeruli.', type=int, default=1) parser.add_argument('podocyte_channel_number', nargs='+', help='Fluorescence channel with podocytes.', type=int, default=2) parser.add_argument('minimum_glomerular_diameter', nargs='+', help='Minimum glomerular diameter (microns).', type=float, default=30) parser.add_argument('maximum_glomerular_diameter', nargs='+', help='Maximum glomerular diameter (microns).', type=float, default=300) parser.add_argument('file_extension', nargs='+', help='Extension of image file format (.tif, etc.)', type=str, default='.lif') args = parser.parse_args() input_directory = ' '.join(args.input_directory) output_directory = ' '.join(args.output_directory) channel_glomeruli = args.glomeruli_channel_number[0] - 1 channel_podocytes = args.podocyte_channel_number[0] - 1 min_glom_diameter = args.minimum_glomerular_diameter[0] max_glom_diameter = args.maximum_glomerular_diameter[0] ext = args.file_extension[0] # Initialize time_start = time.time() timestamp = time.strftime('%d-%b-%Y_%H-%M%p', time.localtime()) log_file_begins(output_directory, args, timestamp) detailed_stats = pd.DataFrame() output_filename_detailed_stats = os.path.join(output_directory, 'Podocyte_detailed_stats_'+timestamp+'.csv') # Get to work filelist = find_files(input_directory, ext) logging.info(f"{len(filelist)} {ext} files found.") for filename in filelist: logging.info(f"Processing file: {filename}") try: images = pims.open(filename) except Exception: continue for im_series_num in range(images.metadata.ImageCount()): logging.info(f"{images.metadata.ImageID(im_series_num)}") logging.info(f"{images.metadata.ImageName(im_series_num)}") images.series = im_series_num images.bundle_axes = 'zyxc' voxel_volume = images[0].metadata['mpp'] * \ images[0].metadata['mpp'] * \ images[0].metadata['mppZ'] glomeruli_labels = preprocess_glomeruli(images[0][..., channel_glomeruli]) glom_regions = filter_by_size(glomeruli_labels, min_glom_diameter, max_glom_diameter) glom_index = 0 # glom labels will not always be sequential after filtering by size logging.info(f"{len(glom_regions)} glomeruli identified.") if len(glom_regions) > 0: podocytes_view = denoise_image(images[0][..., channel_podocytes]) for glom in glom_regions: podocyte_regions, centroid_offset, wshed = find_podocytes( podocytes_view, glom) df = get_podocyte_statistics(podocyte_regions, centroid_offset, voxel_volume) if df is None: continue logging.info(f"{len(df)} podocytes found for this glomerulus. " + f"Centroid (x,y,z): (" + f"{int(glom.centroid[2])}, " + f"{int(glom.centroid[1])}, " + f"{int(glom.centroid[0])})") df = get_podocyte_avg_statistics(df) df = get_glom_statistics(df, glom, glom_index, voxel_volume) df['image_series_num'] = images.metadata.ImageID(im_series_num) df['image_series_name'] = images.metadata.ImageName(im_series_num) df['image_filename'] = filename detailed_stats = detailed_stats.append(df, ignore_index=True, sort=False) detailed_stats.to_csv(output_filename_detailed_stats) glom_index += 1 # Summarize output and write to file summary_stats = create_summary_stats(detailed_stats) output_filename_summary_stats = os.path.join(output_directory, 'Podocyte_summary_stats_'+timestamp+'.csv') summary_stats.to_csv(output_filename_summary_stats) logging.info(f'Saved statistics to file: {output_filename_summary_stats}') total_gloms_counted = len(summary_stats) log_file_ends(time_start, total_gloms_counted)
def main(): message = ( 'Hi there!\n\n' 'Welcome to Gooey! \nThis is a demo of the flexible layouts and overall' 'customization you can achieve by using argument groups and ' 'the new gooey_options feature.') import sys print(sys.argv) desc = "Gooey transforms your CLI applications into beautiful GUIs!" file_help_msg = "Name of the file you want to process" my_cool_parser = GooeyParser(description=desc, add_help=False) # categories = my_cool_parser.add_argument_group( # 'Input Stage', # gooey_options={ # 'show_border': True, # # 'label_color': '#FF9900', # 'columns': 2, # # 'margin_top': 30 # } # ) # # categories.add_argument( # '--subcategory', # metavar='File', # help='Path the audio file to encode.', # widget='FileChooser', # required=True, # gooey_options={ # }) # # categories.add_argument( # '--subcategory21', # metavar='File', # help='Path the audio file to encode.', # widget='FileChooser', # required=True, # gooey_options={ # }) # categories.add_argument( # '--parent-category', # metavar='Bitrate', # help='The constant or variable bitrate (depending on codec choice)', # choices=['a', 'b', 'c'], # required=True, # gooey_options={ # 'label_color': '#FF9900', # 'label_bg_color': '#0000FF', # # 'help_color': '#ff00ff', # 'help_bg_color': '#ff00ff' # }) search_options = my_cool_parser.add_argument_group( 'Output Stage', 'Specify the desired output behavior for the encoded file.', gooey_options={ 'show_border': True, 'columns': 2, 'margin_top': 25 }) search_options.add_argument( '--query', metavar="Output File", help='The output destination for the encoded file', widget='FileChooser', gooey_options={'full_width': True}) # search_flags = search_options.add_argument_group( 'Resampling', gooey_options={'show_border': True}) search_flags.add_argument( '--buy-it-now', metavar='Lowpass', help="Frequency(kHz), lowpass filter cutoff above freq.", action='store_true', widget='BlockCheckbox', gooey_options={'checkbox_label': 'Enable'}) search_flags.add_argument('--auction', metavar='Resample', help="Sampling frequency of output file(kHz)", action='store_true', widget='BlockCheckbox', gooey_options={'checkbox_label': 'Enable'}) # price_range = search_options.add_argument_group('Price_Range', # gooey_options={'show_border': True} # ) # # price_range.add_argument('--price-min', # help='This' # ) # price_range.add_argument( # '--price-max', # metavar='Priority', # help='sets the process priority (Windows and OS/2-specific)', # choices=[0,1,2,3,4], # default=2 # ) my_cool_parser.print_help() args = my_cool_parser.parse_args() print(args) print("Hiya!") for i in range(20): import time print('Howdy', i) time.sleep(.3)
def main(): import sys print(sys.argv) desc = "Example application to show Gooey's various widgets" file_help_msg = "Name of the file you want to process" parser = GooeyParser(description=desc, add_help=False) # parser.add_argument('--textfield', default=2, widget="TextField", gooey_options={'full_width': True}) # 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': 'ff0000', # 'text_color': '', # 'hide_heading': False, # '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', gooey_options={ 'defaultFile': 'Sup n***a', 'message': 'Sup fam', 'wildcard': 'nig juice' }) 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') parser.add_argument("--multifilechooser", default="2015-01-01", widget='MultiFileChooser') parser.add_argument("--multidirchooser", default="2015-01-01", widget='MultiDirChooser') dest_vars = [ 'textfield', 'textarea', 'password', 'commandfield', 'dropdown', 'listboxie', 'counter', 'overwrite', 'mutextwo', 'filechooser', 'filesaver', 'dirchooser', 'datechooser' ] args = parser.parse_args() for i in dest_vars: assert getattr(args, i) is not None print("Success")
def main(): message = ( 'Hi there!\n\n' 'Welcome to Gooey! \nThis is a demo of the flexible layouts and overall' 'customization you can achieve by using argument groups and ' 'the new gooey_options feature.') import sys print(sys.argv) 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, add_help=False) description_area = my_cool_parser.add_argument_group("About", gooey_options={ 'show_border': True, 'show_underline': False, }) description_area.add_argument('thing', default=message, widget='Textarea', help="asdfsadfasdfa sdfadf ad", gooey_options={ 'height': 100, 'show_help': False, 'show_label': False, 'readonly': True }) categories = my_cool_parser.add_argument_group( 'Categories', description= 'There are 13 species of crocodiles, so there are many different ' + 'sizes of crocodile. The smallest crocodile is the dwarf crocodile. ' + 'It grows to about 5.6 feet (1.7 meters) in length and weighs 13 to 15 pounds ', gooey_options={ 'show_border': False, 'label_color': '#FF9900', 'columns': 2, # 'margin_top': 90 }) categories.add_argument( '--parent-category', metavar='Parent Category', help='This is a very, very, very long help text ' 'to explain a very, very, very important input value. ' 'Unfortunately, the end of this long message is cropped. ', choices=['a', 'b', 'c'], required=True, gooey_options={ 'label_color': '#FF9900', 'label_bg_color': '#0000FF', # 'help_color': '#ff00ff', 'help_bg_color': '#ff00ff' }) categories.add_argument( '--subcategory', metavar='Subcategory', help='Select Subcategory', choices=['a', 'b', 'c'], required=True, gooey_options={ 'label_color': '#FF9900', 'validator': { 'type': 'local', 'test': 'user_input', 'message': 'this is a super long error message wtih multiple ideas and suggestions on how to go about resolving the error ' } # 'help_color': '#ff00ff', # 'help_bg_color': '#ff0000' }) search_options = my_cool_parser.add_argument_group( 'Search Options', 'Customize the search options', gooey_options={ 'show_border': True, 'columns': 2, 'margin_top': 25 }) search_options.add_argument('--query', help='base search string', gooey_options={'full_width': True}) # search_flags = search_options.add_argument_group( 'Flags', gooey_options={'show_border': False}) search_flags.add_argument('--buy-it-now', metavar='Buy it Now', help="Will immediately purchase if possible", action='store_true', widget='BlockCheckbox', gooey_options={ 'label_color': '#4B5F83', 'checkbox_label': 'Enable' }) search_flags.add_argument('--auction', metavar='Auction', help="Place bids up to PRICE_MAX", action='store_true', widget='BlockCheckbox', gooey_options={ 'label_color': '#4B5F83', 'checkbox_label': 'Enable' }) price_range = search_options.add_argument_group( 'Price_Range', gooey_options={'show_border': True}) price_range.add_argument( '--price-min', help='This' # 'is a very, very, very long help text ' # 'to explain a very, very, very important input value. ' ) price_range.add_argument('--price-max', help='max price') args = my_cool_parser.parse_args() print(args) print("Hiya!") for i in range(20): import time print('Howdy', i) time.sleep(.3)
def main(): message = ( 'Hi there!\n\n' 'Welcome to Gooey! \nThis is a demo of the flexible layouts and overall' 'customization you can achieve by using argument groups and ' 'the new gooey_options feature.') import sys print(sys.argv) 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, add_help=False) categories = my_cool_parser.add_argument_group( 'Example 1', description='This is the default group style', gooey_options={ 'show_underline': True, 'show_border': False, # 'label_color': '#FF9900', 'columns': 1, # 'margin_top': 90 }) categories.add_argument( '--subcategoryasdf2asdf', metavar='Parent Category', help='Select Subcategory', choices=['a', 'b', 'c'], required=True, ) categories.add_argument( '--subcategory', metavar='Subcategory', help='Select Subcategory', choices=['a', 'b', 'c'], required=True, ) categories1 = my_cool_parser.add_argument_group( 'Example 2', description='This is an argument group with no horizontal line break', gooey_options={ 'show_underline': False, 'show_border': False, }) categories1.add_argument( '--subcategoryasdf2asdfasdf', metavar='Parent Category', help='Select Subcategory', choices=['a', 'b', 'c'], required=True, ) categories1.add_argument( '--subcategory1', metavar='Subcategory', help='Select Subcategory', choices=['a', 'b', 'c'], required=True, ) categories2 = my_cool_parser.add_argument_group( 'Example 3', description='This is an argument group with show_border = True', gooey_options={ 'show_underline': False, 'show_border': True, # 'label_color': '#FF9900', # 'columns': 2, # 'margin_top': 90 }) categories2.add_argument( '--subcategoryasdf2', metavar='Parent Category', help='Select Subcategory', choices=['a', 'b', 'c'], required=True, ) categories2.add_argument( '--subcategory2', metavar='Subcategory', help='Select Subcategory', choices=['a', 'b', 'c'], required=True, ) my_cool_parser.print_help() args = my_cool_parser.parse_args() print(args) print("Hiya!") for i in range(20): import time print('Howdy', i) time.sleep(.3)