我正在尝试将标签传递给我的列表框的回调函数,但不知何故我无法做到。
我已经尝试过lambdas,但没有成功。
这是我目前的代码段:
VEHICLE_ABBR BLOCK_NO DEPARTURE_TIME Trip
SXXB1410D 21,760,010 19,500 1
SXXB1410D 21,760,010 24,900 2
SXXB1410D 21,760,010 31,020 3
TXXB1102R 21,760,026 19,800 1
TXXB1102R 21,760,026 24,480 2
MXXB1410P 21,760,011 17,500 1
MXXB1410P 21,760,011 19,900 2
JXXB1102K 21,760,027 20,800 1
JXXB1102K 21,760,027 22,480 2
JXXB1102K 21,760,027 23,480 3
SELECT
BLOCK_NO
,VEHICLE_ABBR
,DEPARTURE_TIME
,SUM(CASE WHEN TRIP = 1 THEN 1 ELSE 0 END)
OVER (PARTITION BY BLOCK_NO,VEHICLE_ABBR ORDER BY DEPARTURE_TIME, TRIP ROWS UNBOUNDED PRECEDING) AS TRIP_NUM
FROM
(
SELECT
BLOCK_NO
,VEHICLE_ABBR
,DEPARTURE_TIME
,ROW_NUMBER() OVER (PARTITION BY BLOCK_NO,VEHICLE_ABBR,DEPARTURE_TIME ORDER BY DEPARTURE_TIME ) AS TRIP
FROM tab
) AS dt;
我怎样才能得到类似的东西:
program_list.bind('<<ListboxSelect>>', MainController.select_program)
编辑: 其他功能:
program_list.bind('<<ListboxSelect>>', MainController.select_program(arg1))
答案 0 :(得分:1)
您可以像这样使用lambda:
<强> CHANGED 强>
from tkinter import *
root = Tk()
def on_select(event, arg):
lb = event.widget
idx = lb.curselection()
item = lb.get(idx)
print('%s, %s' % (item, arg))
lst = Listbox(root)
for i in range(5):
lst.insert(END, 'item ' + str(i))
lst.pack()
lst.bind('<<ListboxSelect>>', lambda event: on_select(event, 'another value'))
root.mainloop()