title: Tkinter scrollbar for frame
body: <p>My objective is to add a vertical scroll bar to a frame which has several labels in it. The scroll bar should automatically enabled as soon as the labels inside the frame exceed the height of the frame. After searching through, I found <a href="https://stackoverflow.com/questions/3085696/adding-a-scrollbar-to-a-grid-of-widgets-in-tkinter">this</a> useful post. Based on that post I understand that in order to achieve what i want, (correct me if I am wrong, I am a beginner) I have to create a <code>Frame</code> first, then create a <code>Canvas</code> inside that frame and stick the scroll bar to that frame as well. After that, create another frame and put it inside the canvas as a window object. So, I finally come up with this:</p>
  
  <pre><code>from Tkinter import *
  
  def data():
      for i in range(50):
         Label(frame,text=i).grid(row=i,column=0)
         Label(frame,text="my text"+str(i)).grid(row=i,column=1)
         Label(frame,text="..........").grid(row=i,column=2)
  
  def myfunction(event):
      canvas.configure(scrollregion=canvas.bbox("all"),width=200,height=200)
  
  root=Tk()
  sizex = 800
  sizey = 600
  posx  = 100
  posy  = 100
  root.wm_geometry("%dx%d+%d+%d" % (sizex, sizey, posx, posy))
  
  myframe=Frame(root,relief=GROOVE,width=50,height=100,bd=1)
  myframe.place(x=10,y=10)
  
  canvas=Canvas(myframe)
  frame=Frame(canvas)
  myscrollbar=Scrollbar(myframe,orient="vertical",command=canvas.yview)
  canvas.configure(yscrollcommand=myscrollbar.set)
  
  myscrollbar.pack(side="right",fill="y")
  canvas.pack(side="left")
  canvas.create_window((0,0),window=frame,anchor='nw')
  frame.bind("&lt;Configure&gt;",myfunction)
  data()
  root.mainloop()
  </code></pre>
  
  <ol>
  <li>Am I doing it right? Is there better/smarter way to achieve the output this code gave me?</li>
  <li>Why must I use grid method? (I tried place method, but none of the labels appear on the canvas.)</li>
  <li>What so special about using <code>anchor='nw'</code> when creating window on canvas?</li>
  </ol>
  
  <p>Please keep your answer simple, as I am a beginner.</p>