如何更新列表框以显示不断变化的计数器?

时间:2015-03-09 15:30:36

标签: python tkinter listbox

我有一个保存邮件的列表框,我希望能够计算发送的每种类型邮件的数量。

如何更新列表框以显示不断变化的计数器?

def addToList(self,event):

    global transList

    ref = len(transList)
    t = TransMsg()

    t.canID = self.IDbox.get()
    t.DLC = self.DLCBox.get()
    t.canType = "s"
    t.msgType = "m"
    t.tData0 = self.tData0Box.get()
    t.tData1 = self.tData1Box.get()
    t.tData2 = self.tData2Box.get()
    t.tData3 = self.tData3Box.get()
    t.tData4 = self.tData4Box.get()
    t.tData5 = self.tData5Box.get()
    t.tData6 = self.tData6Box.get()
    t.tData7 = self.tData7Box.get()
    t.tTimer = self.tTimerBox.get()

    self.clearBoxes()

    transList.append(t)

    self.Translist.insert("end","%s %d %s %s %s %s %s %s %s %s %d %d" %
            ( transList[ref].canID,
             int(transList[ref].DLC),
             transList[ref].tData0,
             transList[ref].tData1,
             transList[ref].tData2,
             transList[ref].tData3,
             transList[ref].tData4,
             transList[ref].tData5,
             transList[ref].tData6,
             transList[ref].tData7,
             int(transList[ref].tTimer)
             transList[ref].Count))

def Enter(self):

        global running
        i_ref = 0
        items = self.Translist.curselection()

        if(int(transList[i_ref].tTimer) <= 0):
            pass
        else:
            if running == 0:
                self.retrans = self.window.after(transList[i_ref].tTimer, self.Enter)
            else:
                running = 0
                self.window.after_cancel(self.retrans)

        for i in items:
           i_ref = int(i)

           system('echo "%s %s 0x%s %d 0x%s 0x%s 0x%s 0x%s 0x%s 0x%s 0x%s 0x%s" >/dev/pcan33' %
                (transList[i_ref].msgType,
                transList[i_ref].canType,
                transList[i_ref].canID,
                int(transList[i_ref].DLC),
                transList[i_ref].tData0,
                transList[i_ref].tData1,
                transList[i_ref].tData2,
                transList[i_ref].tData3,
                transList[i_ref].tData4,
                transList[i_ref].tData5,
                transList[i_ref].tData6,
                transList[i_ref].tData7))

           transList[i_ref].Count += 1
           #update listbox with new count

以下是列表框

的发送和插入的代码

0 个答案:

没有答案