โค้ด: เลือกทั้งหมด
from tkinter import *
def selection():
a = Lb.curselection()
print(a)
for i in a:
print(Lb.get(i))
root = Tk()
Lb = Listbox(root,selectmode=EXTENDED)
b = Button(root,text="Click" ,command=selection)
Lb.insert(1,"Python")
Lb.insert(2,"Java")
Lb.insert(3,"Php")
Lb.pack()
b.pack()
root.mainloop()
เมื่อเรากดปุ่มเลือก จะแสดงค่าที่เลือกและตำแหน่งที่เลือก