title: Best way to structure a tkinter application?
body: <p>The following is the overall structure of my typical python tkinter program.</p>
  
  <pre><code>def funA():
      def funA1():
          def funA12():
              # stuff
  
      def funA2():
          # stuff
  
  def funB():
      def funB1():
          # stuff
  
      def funB2():
          # stuff
  
  def funC():
      def funC1():
          # stuff
  
      def funC2():
          # stuff
  
  
  root = tk.Tk()
  
  button1 = tk.Button(root, command=funA)
  button1.pack()
  button2 = tk.Button(root, command=funB)
  button2.pack()
  button3 = tk.Button(root, command=funC)
  button3.pack()
  </code></pre>
  
  <p><code>funA</code> <code>funB</code> and <code>funC</code> will bring up another <code>Toplevel</code> windows with widgets when user click on button 1, 2, 3.  </p>
  
  <p>I am wondering if this is the right way to write a python tkinter program? Sure, it will work even if I write this way, but is it the best way? It sounds stupid but when I see the codes other people written, their code is not messed up with bunch of functions and mostly they have classes.</p>
  
  <p>Is there any specific structure that we should follow as good practice? How should I plan before start writing a python program?</p>
  
  <p>I know there is no such thing as best practice in programming and I am not asking for it either. I just want some advice and explanations to keep me on the right direction as I am learning Python by myself.</p>