【发布时间】:2017-07-17 11:08:56
【问题描述】:
我在下面有以下示例代码。有没有办法展开列表框,点击时显示 100 个数字中的 10 个? And when selecting one of the numbers, does the listbox hide the others again?
from tkinter import *
root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack(side=RIGHT, fill=Y)
listbox = Listbox(root)
listbox.pack()
for i in range(100):
listbox.insert(END, i)
# attach listbox to scrollbar
listbox.config(yscrollcommand=scrollbar.set, height = 1)
scrollbar.config(command=listbox.yview)
mainloop()
【问题讨论】: