从复选框列表访问值传递给函数

时间:2019-05-27 16:12:19

标签: checkbox tkinter

我创建了一个复选框列表。当我单击一个复选框时,所有复选框的值都会通过该函数而不是已选中的复选框。

def vendorData(self, recs, rowide):

    self.chkVendorValue = "vendor"+rowide
    self.refEntryText = "ref" + rowide
    self.titleEntryText = "title" + rowide
    self.isbnEntryText = "isbn" + rowide
    self.qtyEntryText = "qty" + rowide
    currpoinfo = str(recs[4]) + "_" + str(recs[1])
    self.arrSelect[self.arrMatrixHead[self.i]] = Checkbutton(self.InsideFrame, variable=self.chkVendorValue, onvalue=1,
                        offvalue=0, font=config.allLabels(), justify=LEFT, command = self.chkSelected(currpoinfo))

    self.arrSelect[self.arrMatrixHead[self.i]].pack()
    self.arrSelect[self.arrMatrixHead[self.i]].place(x=config.xrow, y=config.ycol, width=20, height=25)

#---------------------------说明模块----------------- --------------     def chkSelected(自我,porifid):         #print(“ chkvalue:”,self.chkVendorValue)

    print("porefid", porefid)
    if porefid != "0" and porefid != "":
        poinfo =  porefid.split("_",2)

chkvalue:vendorrow0 毛孔2_9780306407062 chkvalue:vendorrow1 毛孔2_9781552096246 chkvalue:vendorrow2 孔隙1_9781849733816 我只需要一对值而不是3。

0 个答案:

没有答案