title: Adding a scrollbar to a frame using Tkinter (Python)
body: <p>I've a simple GUI thats shows the users some options, after putting the number of the initial options to be shown. In this case, 4:</p>
  
  <p><img src="https://i.stack.imgur.com/G9NkZ.png" alt="initial"></p>
  
  <p>By clicking on <code>Add row</code> you can add a row to the GUI. The thing is that if the user wants 100 options, the GUI becomes extra big and all the options are not shown.
  <img src="https://i.stack.imgur.com/S7nhi.png" alt="big"></p>
  
  <p>So I would like to have a scrollbar only on the options space, not the rest parts. Sorry for the bad Photoshop, but I would like to have something like this:
  <img src="https://i.stack.imgur.com/F3kxw.png" alt="desiredsolution"></p>
  
  <p>The options space is the <code>FrameTwo</code>, so I would like to have the entire <code>FrameTwo</code> inside of scrollbar like the image above.</p>
  
  <pre><code># -*- coding: utf-8 -*-
  from Tkinter import *
  import Image
  import ImageTk
  import tkFileDialog
  import datetime
  
  class Planificador(Frame):
      def __init__(self,master):
          Frame.__init__(self, master)
          self.master = master
          self.initUI()
  
      def initUI(self):
          self.master.title("Plan")
          self.frameOne = Frame(self.master)
          self.frameOne.grid(row=0,column=0)
          self.frameTwo = Frame(self.master)
          self.frameTwo.grid(row=1, column=0)
          self.frameThree = Frame(self.master)
          self.frameThree.grid(row=2, column=0)
  
          # Borrar esto?
          self.txt = Text(self)
          self.txt.pack(fill=BOTH, expand=1)
  
          self.piezastext = Label(self.frameOne, text = " Amount of pieces ", justify="center")
          self.piezastext.grid(row=1, column=0)
          self.entrypiezas = Entry(self.frameOne,width=3)
          self.entrypiezas.grid(row=2, column=0, pady=(5,5))
          self.aceptarnumpiezas = Button(self.frameOne,text="Click me", command=self.aceptar_piezas,width=8)
          self.aceptarnumpiezas.grid(row=6, column=0, pady=(5,5))
  
      def aceptar_piezas(self):
          try:
              val = int(self.entrypiezas.get())
              self.aceptar_piezas_ok()
          except ValueError:
              showerror('Error', "Introduce un numero")
  
      def aceptar_piezas_ok(self):
          self.num_piezas = self.entrypiezas.get()
  
          self.piezastext.grid_remove()
          self.entrypiezas.grid_remove()
          self.aceptarnumpiezas.grid_remove()
  
          self.optionmenus_piezas = list()
          self.numpiezas = []
          self.numerolotes = []
          self.optionmenus_prioridad = list()
          self.lotes = list()
  
          self.mispiezas = ['One', 'Two', 'Three', 'Four', 'Five']
  
          self.n = 1
          while self.n &lt;= int(self.num_piezas):
              self.textopieza = Label(self.frameTwo, text = "Pieza: ", justify="left")
              self.textopieza.grid(row=self.n, column=0)
  
              var = StringVar()
              menu = OptionMenu(self.frameTwo, var, *self.mispiezas)
              menu.config(width=10)
              menu.grid(row=self.n, column=1)
              var.set("One")
              self.optionmenus_piezas.append((menu, var))
  
              self.numpiezastext = Label(self.frameTwo, text = "Numero de piezas: ", justify="center")
              self.numpiezastext.grid(row=self.n, column=2, padx=(10,0))
              self.entrynumpiezas = Entry(self.frameTwo,width=6)
              self.entrynumpiezas.grid(row=self.n, column=3, padx=(0,10))
              self.entrynumpiezas.insert(0, "0")
  
              self.textoprioridad = Label(self.frameTwo, text = "Prioridad: ", justify="center")
              self.textoprioridad.grid(row=self.n, column=4)
              var2 = StringVar()
              menu2 = OptionMenu(self.frameTwo, var2, "Normal", "Baja", "Primera pieza", "Esta semana")
              menu2.config(width=10)
              menu2.grid(row=self.n, column=5)
              var2.set("Normal")
              self.optionmenus_prioridad.append((menu2, var2))
  
              self.lotestext = Label(self.frameTwo, text = "Por lotes?", justify="center")
              self.lotestext.grid(row=self.n, column=6, padx=(10,0))
              self.var1 = IntVar()
              self.entrynumlotes = Checkbutton(self.frameTwo, variable=self.var1)
              self.entrynumlotes.grid(row=self.n, column=7, padx=(5,10))
              self.lotes.append(self.var1)
              self.numpiezas.append(self.entrynumpiezas)
  
              self.n += 1
  
          self.anadirpiezas = Button(self.frameThree, text="Add row", command=self.addpieza, width=10)
          self.anadirpiezas.grid(row=0, column=2, pady=(10,10))
  
          self.calculotext = Label(self.frameThree, text = "Other stuff ")
          self.calculotext.grid(row=1, column=2, padx=(10,0), pady=(10,10))
  
          self.graspbutton = Button(self.frameThree, text="OPT 1", width=10)
          self.graspbutton.grid(row=2, column=1)
  
          self.parettobutton = Button(self.frameThree, text="OPT 2",width=10)
          self.parettobutton.grid(row=2, column=2, pady=(10,10), padx=(10,0))
  
          self.parettoEvolbutton = Button(self.frameThree, text="OPT 2", width=10)
          self.parettoEvolbutton.grid(row=2, column=3, pady=(10,10), padx=(10,0))
  
  
      def addpieza(self):
              self.textopiezanuevo = Label(self.frameTwo, text = "Pieza: ", justify="left")
              self.textopiezanuevo.grid(row=int(self.num_piezas)+1, column=0)
  
              var = StringVar()
              menu = OptionMenu(self.frameTwo, var, *self.mispiezas)
              menu.grid(row=self.n, column=1)
              menu.config(width=10)
              menu.grid(row=int(self.num_piezas)+1, column=1)
              var.set("One")
              self.optionmenus_piezas.append((menu, var))
  
              self.numpiezastext = Label(self.frameTwo, text = "Numero de piezas: ", justify="center")
              self.numpiezastext.grid(row=int(self.num_piezas)+1, column=2, padx=(10,0))
              self.entrynumpiezas = Entry(self.frameTwo,width=6)
              self.entrynumpiezas.grid(row=int(self.num_piezas)+1, column=3, padx=(0,10))
              self.entrynumpiezas.insert(0, "0")
  
              self.textoprioridad = Label(self.frameTwo, text = "Prioridad: ", justify="center")
              self.textoprioridad.grid(row=int(self.num_piezas)+1, column=4)
              var2 = StringVar()
              menu2 = OptionMenu(self.frameTwo, var2, "Normal", "Baja", "Primera pieza", "Esta semana")
              menu2.config(width=10)
              menu2.grid(row=int(self.num_piezas)+1, column=5)
              var2.set("Normal")
              self.optionmenus_prioridad.append((menu2, var2))
  
              self.lotestext = Label(self.frameTwo, text = "Por lotes?", justify="center")
              self.lotestext.grid(row=int(self.num_piezas)+1, column=6, padx=(10,0))
              self.var1 = IntVar()
              self.entrynumlotes = Checkbutton(self.frameTwo, variable=self.var1)
              self.entrynumlotes.grid(row=int(self.num_piezas)+1, column=7, padx=(5,10))
              self.lotes.append(self.var1)
  
              self.numpiezas.append(self.entrynumpiezas)
              self.num_piezas = int(self.num_piezas)+1
  
  if __name__ == "__main__":
      root = Tk()
      aplicacion = Planificador(root)
      root.mainloop()
  </code></pre>
  
  <p><code>FrameOne</code> is used to put an image I removed to make this example more simple. And <code>FrameThree</code> are the buttons you can see at the bottom of the GUI.</p>
  
  <p>So it would be very helpful if someone could give me a hand and tell me how to put the entire <code>FrameTwo</code> inside of a scrollbar as you can see on the third image.</p>
  
  <p>Thanks in advance.</p>