Python GUI编程(Tkinter)12、Listbox控件中下

import tkinter

win = tkinter.Tk()
win.title("sunck")
#win.geometry("400x400+200+20")

#EXTENDED 可以使listbox支持shift和control
lb = tkinter.Listbox(win, selectmode=tkinter.EXTENDED)
for item in ["good", "nice", "handsome", "vg", "vn","good1", "nice1", "handsome1", "vg1", "vn1","good3", "nice3", "handsome3", "vg3", "vn3"]:
lb.insert(tkinter.END, item)

#按住shift,可以实现连选
#按住control,可以实现多选
#滚动条
sc = tkinter.Scrollbar(win)
sc.pack(side=tkinter.RIGHT, fill=tkinter.Y)
lb.configure(yscrollcommand=sc.set)
lb.pack(side=tkinter.LEFT, fill=tkinter.BOTH)
#额外给属性赋值
sc['command'] = lb.yview

win.mainloop()
posted @ 2020-05-19 16:04  i勤能补拙  阅读(286)  评论(0编辑  收藏  举报