我想创建一个由列表框选定项中的更改或单选按钮选定项中的更改触发的事件。有可能吗?我使用这个代码:def getScript(event):
state = rb.get()
listScript = []
processor = ()
processor = lb1.get(lb1.curselection())
if processor :
if (state == 1):
print processor
if (state == 2):
pass
if (state == 3):
pass
frame2 = Frame(top)
frame2.pack(fill = X)
rb = IntVar()
R1 = Radiobutton(frame2, text = "Parallel Test",
variable = rb, value = 1, command = getScript)
R2 = Radiobutton(frame2, text = "Non Parallel Test",
variable = rb, value = 2, command = getScript)
R3 = Radiobutton(frame2, text = "Specific Test",
variable = rb, value = 3, command = getScript)
R1.grid(row = 0, column = 0, padx = 10)
R2.grid(row = 0, column = 1, padx = 10)
R3.grid(row = 0, column = 2, padx = 10)
frame3 = Frame(top)
frame3.pack(fill = X)
space_frame3 = Frame(frame3, width = 10)
l5 = Label(frame3, text = "Processor Unit")
l6 = Label(frame3, text = "Script for test")
lb1 = Listbox(frame3, height = 7, exportselection = 0)
lb1.bind('<>',getScript)
scrollbar = Scrollbar(frame3)
lb2 = Listbox(frame3, height = 7, width = 40,
yscrollcommand = scrollbar.set, exportselection = 0)
只要在选择列表框中的项目之前选择了单选按钮,一切都会好起来的。但每次我选择另一个单选按钮,它就会返回:TypeError: getScript() takes exactly 1 argument (0 given)