from tkinter import * |
root = Tk() |
#初始化滚动条,放到右边 |
sb = Scrollbar(root) |
sb.pack(side = RIGHT, fill = Y) |
#初始化选项列表,放到左边 |
lb = Listbox(root, yscrollcommand = sb. set ) |
for i in range ( 1000 ): |
lb.insert(END, i) |
lb.pack(side = LEFT, fill = BOTH) |
#关联滚动条 |
sb.config(command = lb.yview) |
mainloop() |