title: Multiple application/file/windows instances running on tkinter
body: <p>Here is a sample situation:</p>
  
  <p>I have written a tk GUI that opens and edits e.g. .txt files. I'm currently on a mac, but I might also want to run this on windows. Currently the main Application class creates its own internal <code>tk.Tk()</code> like so </p>
  
  <pre><code>    import tkinter as tk
  
  class App:
      def __init__(self):
          self.root = tk.Tk()
          tk.Label(master=self.root,text="content").pack()
  
  if __name__ == '__main__':
      a=App()
      a.root.mainloop()
  </code></pre>
  
  <p>I want to add multi file capabilities to the application. In the current system this would result in 2 <code>tk.Tk()</code> instances running which I couldn't get to work and people say is unpredictable. </p>
  
  <p>I want to be able to close any of the multiple files and still have the application running until the last window is closed and then the application quit or stays without a window (like on a mac). </p>
  
  <p>My problem is that if I use <code>tk.Toplevel()</code> for each of my windows I have a ugly default <code>tk.Tk()</code> window which I would need to hide which seams inelegant. It would also be messy to determine which file is currently in focus for actions with the menubar.</p>
  
  <p>I'm also considering each file being it's own application instance like on Windows, but that would fill the dock with repeated icons and be inconsistent with the rest of the system.</p>
  
  <p>Here are the possible way I came up with:
  Multiple Tks (Works but more complex examples are unpredictable):</p>
  
  <pre><code>import tkinter as tk
  
  class App:
      def __init__(self):
          self.root = tk.Tk()
          tk.Label(master=self.root,text="content").pack()
          tk.Button(master=self.root,text="new_window",command=self.open).pack()
  
      def open(self):
          App()
  
  if __name__ == '__main__':
      a=App()
      a.root.mainloop()
  </code></pre>
  
  <p>Hidden tk window and multiple Toplevels (Needs hiding the Tk and the osx menubar commands like view->change_colors would need to manaly decide where to direct comands):</p>
  
  <pre><code>import tkinter as tk
  
  class App:
      def __init__(self):
          self.root = tk.Toplevel()
          tk.Label(master=self.root,text="content").pack()
          tk.Button(master=self.root,text="new_window",command=self.open).pack()
  
      def open(self):
          App()
  
  if __name__ == '__main__':
      tk.Tk()
      a=App()
      a.root.mainloop()
  </code></pre>
  
  <p>Each Window is its own Application and fully independant (Dosn't fit in with the other mac applications, the implementation is ugly):</p>
  
  <pre><code>#!/usr/local/bin/python3
  import tkinter as tk
  import sys,os
  
  class App:
      def __init__(self):
          self.root = tk.Tk()
          tk.Label(master=self.root,text="content").pack()
          tk.Button(master=self.root,text="new_window",command=self.open).pack()
  
      def open(self):
          os.system(sys.argv[0]+"&amp;")
  
  if __name__ == '__main__':
      a=App()
      a.root.mainloop()
  </code></pre>
  
  <p>I was alos think of maybe doing it with threads but I think I must be over thinking it so I came here.
  Is there a generally accepted way of doing this in tk?</p>