我想制作一个由列表框选定项的更改或单选按钮选定项的更改触发的事件。可能吗?我使用这段代码:
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('<<ListboxSelect>>',getScript)
scrollbar = Scrollbar(frame3)
lb2 = Listbox(frame3, height = 7, width = 40,
yscrollcommand = scrollbar.set, exportselection = 0)
只要我在选择列表框中的项目之前选择了一个单选按钮,一切都会很好。但是每次我选择另一个单选按钮时,它都会返回:
TypeError: getScript() takes exactly 1 argument (0 given)