title: Packing buttons into subframes - Python Tkinter
body: <p>I'm trying to generate a GUI which plots graphs based on a particular option selected at the top of the screen. The graphs are generated by Matplotlib. The problem I am having is getting options buttons aligned on the left hand side of the screen. Basically, I would like "Polynomial Regression" to be listed underneath "Linear Regression" but not aligned <code>pack(side=TOP)</code> as that crushes the graphs as I add more buttons.</p>
  
  <p>After extensive searching, I think I need to make a frame within StartPage, pack that to the left and then pack the option buttons into this window in order with side=TOP. I'm still new to Python and very new to Tkinter, and after many attempts I can't get this to work and I've tied myself in knots. I was following a tutorial that suggested I set up the GUI windows in this way to be able to load multiple pages so I don’t have a clear-cut <code>root</code> in my code (I now don't seem to be able to find others doing it in this way). The best I can get is to pack a subframe into the main frame (pink box), but I cannot get button3 and button4 to be inside the frame without the kernel crashing.</p>
  
  <p><a href="https://i.stack.imgur.com/Dw6he.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dw6he.jpg" alt="enter image description here"></a></p>
  
  <p>The relevant bits of code, minus supporting functions:</p>
  
  <pre><code>class clientProfiler(tk.Tk): 
  
      def __init__(self, *args, **kwargs):
  
          tk.Tk.__init__(self, *args, **kwargs)
          tk.Tk.wm_title(self, "Client Profiler")
  
          container = tk.Frame(self)
          container.pack(side="top", fill="both", expand = True)
          container.grid_rowconfigure(0, weight=1)
          container.grid_columnconfigure(0, weight=1)
  
          # Menu bar
          menubar = tk.Menu(container)
          filemenu = tk.Menu(menubar, tearoff=0)
          filemenu.add_command(label="Save settings", command = lambda: popupmsg("Not supported yet"))
          menubar.add_cascade(label ="File", menu=filemenu)
  
          tk.Tk.config(self, menu=menubar)
  
          self.frames = {}
  
          frame = StartPage(container, self)
          self.frames[StartPage] = frame
          frame.grid(row=0, column=0, sticky="nsew")
  
          self.show_frame(StartPage)
  
      def show_frame(self, cont):
  
          frame = self.frames[cont]
          frame.tkraise()
  
  class StartPage(tk.Frame):
  
      def __init__(self, parent, controller):
          tk.Frame.__init__(self, parent)
          label = tk.Label(self, text="Profiler", font=LARGE_FONT)
          label.pack()
  
          boxLabel = tk.Label(self, text="Client: ", font=NORM_FONT)
          boxLabel.pack(side=TOP)
  
          entrybox = AutocompleteEntry(clientNameList, self)
  
          button2 = ttk.Button(self, text="Go", command=lambda: onClick())
          button3 = ttk.Button(self, text="Linear Regression", command= lambda: linearRegress())
          button4 = ttk.Button(self, text="Polynomial Regression", command = lambda: polyRegress())
          entrybox.pack(side=TOP)
          button2.pack(side=TOP)
          newframe = tk.Frame(self,width=200, height=1000,background="#ffd3d3")
  
          button3.pack(side=LEFT)
          button4.pack(side=LEFT)
  
          newframe.pack(side=LEFT,anchor="nw")
  
          canvas = FigureCanvasTkAgg(f, self)
          canvas.get_tk_widget().pack(fill=tk.BOTH, expand = True)
  
          toolbar = NavigationToolbar2TkAgg(canvas, self)
          toolbar.update()
          canvas._tkcanvas.pack(fill=tk.BOTH, expand = True)
  
  if __name__ == "__main__":
  
      ### Load the app window
      app = clientProfiler()
      app.geometry("1280x720")
      app.mainloop()
  </code></pre>
  
  <p>Is anyone able to help me get button3 and button4 into a separate frame packed to the left on StartPage? Many thanks in advance.         </p>