title: Python script - tkinter and dash within function / external script (___main___)
body: <p>I've started working on a project using tkinter to collect under a simple interface and menu few scripts I have written.
  I’m sure there is a simple solution to the problem but I can’t figure out the way out.
  One of the script I’ve used is based on an example available on the web that uses Dash to select and display statistics from a csv dataframe/pandas.</p>
  
  <p>The dash scripts refreshes the web page when runs as main </p>
  
  <pre><code>if __name__ == '__main__':
      app.run_server(debug=True)
  </code></pre>
  
  <p>and in the menu script tkinter:</p>
  
  <pre><code>if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>In the way I’ve understood searching through the web the menu tkinter relies on the loop in the script and the <code>__main__</code> statement of the script to work. Eventually I’ve discovered it was impossible to embed the dash script within the tkinter loop because the two <code>__main__</code> calls clash. </p>
  
  <p>I’ve tried to run the dash script pointing from the main script to an external script but when I run it I found myself with 2 tkinter menu windows (I couldn’t expect less..) because both scripts call for main (?). I’m sure everything stands with my short understanding of the use of <code>__main__</code> and purpose of the main loops in scripts. Could someone point me in the right direction?
  Many thanks</p>