parameters: (file_type)
return_statement: return file_path if bool(file_path) else None
docstring: Ask the user to select a file
docstring_summary: Ask the user to select a file
docstring_tokens: Ask the user to select a file
function: def ask_file(file_type):
      """ Ask the user to select a file """
      root = Tk()
      root.withdraw()
      root.wm_attributes('-topmost', 1)
      if (file_type is None) or (platform.system() == "Darwin"):
          file_path = askopenfilename(parent=root)
      else:
          if file_type == 'python':
              file_types = [('Python files', '*.py;*.pyw'), ('All files', '*')]
          elif file_type == 'icon':
              file_types = [('Icon files', '*.ico'), ('All files', '*')]
          elif file_type == 'json':
              file_types = [('JSON Files', '*.json'), ('All files', '*')]
          else:
              file_types = [('All files', '*')]
          file_path = askopenfilename(parent=root, filetypes=file_types)
      root.update()
  
      # bool(file_path) will help filter our the negative cases; an empty string or an empty tuple
      return file_path if bool(file_path) else None
function_tokens: def ask_file ( file_type ) : root = Tk ( ) root . withdraw ( ) root . wm_attributes ( '-topmost' , 1 ) if ( file_type is None ) or ( platform . system ( ) == "Darwin" ) : file_path = askopenfilename ( parent = root ) else : if file_type == 'python' : file_types = [ ( 'Python files' , '*.py;*.pyw' ) , ( 'All files' , '*' ) ] elif file_type == 'icon' : file_types = [ ( 'Icon files' , '*.ico' ) , ( 'All files' , '*' ) ] elif file_type == 'json' : file_types = [ ( 'JSON Files' , '*.json' ) , ( 'All files' , '*' ) ] else : file_types = [ ( 'All files' , '*' ) ] file_path = askopenfilename ( parent = root , filetypes = file_types ) root . update ( ) # bool(file_path) will help filter our the negative cases; an empty string or an empty tuple return file_path if bool ( file_path ) else None