4
我想單擊列表框來執行功能。這是我的想法:Tkinter Listbox
from Tkinter import *
import Tkinter
def immediately():
print Lb1.curselection()
top = Tk()
Lb1 = Listbox(top)
Lb1.insert(1, "Python")
Lb1.insert(2, "Perl")
Lb1.insert(3, "C")
Lb1.insert(4, "PHP")
Lb1.insert(5, "JSP")
Lb1.insert(6, "Ruby")
Lb1.pack()
Lb1.bind('<Button-1>', lambda event :immediately())
top.mainloop()
但這個功能打印之前執行選擇......你會看到什麼是problrm當你運行該代碼。
的可能重複[當Tkinter的列表框選擇改變獲取回調?] (http://stackoverflow.com/questions/6554805/getting-a-callback-when-a-tkinter-listbox-selection-is-changed) – drevicko 2013-11-02 00:08:39