scrollbar not working tkinter code example

Example 1: scrollbar in tkinter

from Tkinter import *

root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill = Y )

mylist = Listbox(root, yscrollcommand = scrollbar.set )
for line in range(100):
   mylist.insert(END, "This is line number " + str(line))

mylist.pack( side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview )

mainloop()

Example 2: tkinter make window scrollable

from tkinter import *
class ScrollBar:
    def __init__(self):
        root = Tk()
        h = Scrollbar(root, orient = 'horizontal')
        h.pack(side = BOTTOM, fill = X)
        v = Scrollbar(root)
        v.pack(side = RIGHT, fill = Y)
        t = Text(root, width = 15, height = 15, wrap = NONE,
                 xscrollcommand = h.set,
                 yscrollcommand = v.set)
        for i in range(20):
            t.insert(END,"this is some text\n")
        t.pack(side=TOP, fill=X)
        h.config(command=t.xview)
        v.config(command=t.yview)
        root.mainloop()
s = ScrollBar()