我目前正在编写一个 python 脚本来分析 SNMP 数据。我有一个读取 csv 文件并在 CheckListBox 中组织的 CheckBoxes 中显示标题的函数。我想删除第一项,但这样做会导致我的 CheckListBox 不会填充,我无法弄清楚原因。这是代码:
#Generates CheckBoxList with fields from csv (first row)
def onSNMPGen(self,e):
#reads in first row of csv file; this snmpPaths[0] will likely cause issues with multiple paths -- fix later
listItems = []
print "*** Reading in ", self.snmpPaths[0], "....."
with open(self.snmpPaths[0], 'r') as f: #remember to close csv
reader = csv.reader(f)
print "*** Populating Fields ..... "
for row in reader:
#Inserts each field into CheckListBox as an item;
#self.SNMPCheckListBox.InsertItems(row,0)
listItems.append(row)
break
f.close()
#Need to remove 'Time' (first item) from listItems
#listItems.pop(0) # this makes it so my CheckListBox does not populate
#del listItems[0] # this makes it so my CheckListBox does not populate
for key in listItems:
self.SNMPCheckListBox.InsertItems(key,0)