title: How to avoid tkinter from popping up a window during import?
body: <p>Is there a way to run <code>root = tk.Tk()</code> without popping out a window?</p>
  <p>I am using Python3.8.3 with tkinter UI. I am trying to run a script (I will call it side script, apologies if there is a better term for that) from my main script. The idea is, user will click a button on main script window and side script window will appear. If I run the side script alone, it works fine. If I call side script from main script, then I get error because root is a local variable. I can solve this error by defining root as global variable in the side script. However when I do it, importing side results in an empty tkinter window.</p>
  <p>If side script is:</p>
  <pre><code>def main():
      root = tk.Tk()
      app = MainApp(root)
      root.mainloop()
  
  if __name__ == &quot;__main__&quot;:
      main()
  else:
      pass
  </code></pre>
  <p><em>Error: name 'root' is not defined, when called from main script</em></p>
  <p>If side script is:</p>
  <pre><code>root = tk.Tk()
  
  def main():
      app = MainApp(root)
      root.mainloop()
  
  if __name__ == &quot;__main__&quot;:
      main()
  else:
      pass
  </code></pre>
  <p>root is now a global variable, but then <em>blank tkinter window pops up</em> during importing of this line <code>root = tk.Tk()</code></p>
  <p>Can you recommend me a good way to overcome this?</p>