title: Tk(), Toplevel() and winfo_toplevel(). Difference between them and how and when to use effectively?
body: <p>I am trying to understand how a widget is being created. And I found above three functions are getting used in creating a widget, yet I couldn't come up with the difference and the advantage of one over the other. Even though, I had taken a look on <a href="https://stackoverflow.com/questions/29655219/whats-the-difference-between-tkinters-tk-and-toplevel-classes">this answer</a> that still leaves me with confusion (and it hadn't said anything about <code>winfo_toplevel</code> too).</p>
  
  <p>Here is my code.</p>
  
  <pre><code>from tkinter import *
  
  root = Tk()
  root.title("Root widget")
  root.mainloop()
  
  window = Toplevel()
  window.title("Window widget")
  window.mainloop()
  </code></pre>
  
  <p>On running above code "Root" widget is getting created. On closing "Root", two widgets are created with one titled "Window widget" and other being unwanted. On closing unwanted widget, "Window widget" is also getting destroyed. 
  What is actually happening here and how to overcome?</p>
  
  <p>Another sample:</p>
  
  <pre><code>class ldo(Frame):
      def __init__(self, master = None):
          Frame.__init__(self,master)
          self.grid()
          self.appOutline()
  
      def appOutline(self):
          top = self.winfo_toplevel()
          self.menuBar = Menu(top)
          top["menu"] = self.menuBar
          self.subMenu1 = Menu(self.menuBar)
          self.menuBar.add_cascade(label = "File", menu = self.subMenu1)
  
  app = ldo()
  app.master.title("Sample UI")
  app.mainloop()
  </code></pre>
  
  <p>On the other hand, this code is using <code>winfo_toplevel()</code> where the widget looks perfectly fine. Here, my assumption is, <code>Frame</code> plays a role of creating widget and <code>winfo_toplevel()</code> is an enhancing tool to other tkinter items. But would like to know what it does actually. </p>
  
  <p>However, below snippet is not working:</p>
  
  <pre><code>winf = winfo_Toplevel()
  winf.title("Winfo Widget")
  winf.mainloop()
  </code></pre>
  
  <p>And returning such error:</p>
  
  <pre><code>winf = winfo_Toplevel()
  NameError: name 'winfo_Toplevel' is not defined
  </code></pre>
  
  <p>What is the exact difference between Tk(), Toplevel() and winfo_Toplevel(). What and when should one be used effectively. Looking for really a better understanding. </p>