from tkinter import *
master = Tk()
# 滚动条响应用户滚动操作
sb = Scrollbar(master)
sb.pack(side=RIGHT, fill=Y)
# 里面滚动造成滚动条变化
theLB = Listbox(master,selectmode=EXTENDED,yscrollcommand=sb.set)
for item in range(20):
theLB.insert(END, item)
theLB.pack(side=LEFT, fill=BOTH)
# 垂直滚动内容变化
sb.config(command=theLB.yview)
mainloop()