Question about using dictionaries and QTableWidget

S

Sara Lochtie

I have a table that gets new entries added to it in real time. Each entry has an ID and I am storing the ID in a dictionary. What I am trying to do is to have each ID in its own row and update within that row instead of adding a new one each time.

What I've done is store the ID in a dictionary and only added a new ID to the dictionary if it is not equal to any previous IDs.

I would like to assign the row number for each key in the dictionary to its value.

This is what I have:

ID = int(epc[86:100],2)
idEntry = self.idEntry

if ID not in idEntry.keys():
idEntry[ID] = self.nextRow
self.nextRow += 1



lastRow = self.table.rowCount()
self.table.setRowCount(self.nextRow)

for entryPos in range(0, self.nextRow):
for fieldPos in range(6):
entryPos = idEntry.get(ID)
item = QtGui.QTableWidgetItem(str(data[entryPos][fieldPos]))

self.table.setItem(entryPos, fieldPos, item)


'''
for k in idEntry.keys():
key = str(k)
value = idEntry.get(ID)
for v in idEntry.values():
if data[value][1] == key:
self.table.setItem(value, fieldPos, item)
'''
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top