title: Dash open tkinter file select dialog on click button
body: <p>I am trying to open a file dialog to select some local files. Apparently, Dash does not have this option build in, so I try to do it with tkinter. I find the Dash syntax very confusing with all these strange dependencies. When I run the example below, the file dialog opens as soon as I start the script, but not when I click the button. I desire the opposite behavior. The file selector dialog should open when I click the button and not when after starting the script.</p>
  
  <pre><code>from tkinter import Tk, filedialog
  
  ...
  
  ### Load files
  @app.callback(
      Output('B_add-files', 'value'),
      [Input('B_add-files', 'n_clicks')],
      [State('files-check', 'value')] )
  def select_files(n_clicks, options):
      if n_clicks is not None:
          root = Tk()
          root.withdraw()
          root.call('wm', 'attributes', '.', '-topmost', True)
          if 'by-dir' not in options:
              files = filedialog.askopenfilename(multiple=True)
              files = [abspath(i) for i in files]
              for i in files:
                  assert isfile(i)
          else:
              dir_ = filedialog.askdirectory()
              if isinstance(dir_ , tuple):
                  dir_ = []
              if len(dir_) != 0:
                  files = glob(join(dir_, join('**', '*.mzXML')), recursive=True)
              else:
                  files = []
          if len(files) != 0:
              mint.files += files
          root.destroy()
      return str(n_clicks)
  </code></pre>
  
  <p>This code now works most of the time. Only, if I click on the button multiple times, sometime the server stops and I get the error:</p>
  
  <blockquote>
    <p>Tcl_AsyncDelete: async handler deleted by the wrong thread</p>
  </blockquote>