problem to set the colour of the 0 column
-
Hi
When i colour the column 1 of QTableWidget I have no issue at all. see the picture
once i change the coloumn in the cycle for number at 0
self.ui.table_testpoint.item(r, 0).setBackground(QtGui.QColor(204, 255, 255))
I have the error : AttributeError: 'NoneType' object has no attribute 'setBackground'
below my code. Please dont look the indentations.
with open(namefile, newline='') as csvfile: reader = csv.DictReader(csvfile) self.ui.table_testpoint.setRowCount(lines) #insert the index coloum in the table r = 0 for row in reader: self.ui.table_testpoint.setItem(r, 1, QTableWidgetItem(row["V1"])) self.ui.table_testpoint.setItem(r, 3, QTableWidgetItem(row["V2"])) self.ui.table_testpoint.setItem(r, 5, QTableWidgetItem(row["Freq"])) self.ui.table_testpoint.setItem(r, 6, QTableWidgetItem(row["load"])) self.ui.table_testpoint.setItem(r, 11, QTableWidgetItem(row["StepTime"])) try: self.ui.table_testpoint.item(r, 0).setBackground(QtGui.QColor(204, 255, 255)) except: print(f"no color set for row {r}") r +=1
-
Hi
When i colour the column 1 of QTableWidget I have no issue at all. see the picture
once i change the coloumn in the cycle for number at 0
self.ui.table_testpoint.item(r, 0).setBackground(QtGui.QColor(204, 255, 255))
I have the error : AttributeError: 'NoneType' object has no attribute 'setBackground'
below my code. Please dont look the indentations.
with open(namefile, newline='') as csvfile: reader = csv.DictReader(csvfile) self.ui.table_testpoint.setRowCount(lines) #insert the index coloum in the table r = 0 for row in reader: self.ui.table_testpoint.setItem(r, 1, QTableWidgetItem(row["V1"])) self.ui.table_testpoint.setItem(r, 3, QTableWidgetItem(row["V2"])) self.ui.table_testpoint.setItem(r, 5, QTableWidgetItem(row["Freq"])) self.ui.table_testpoint.setItem(r, 6, QTableWidgetItem(row["load"])) self.ui.table_testpoint.setItem(r, 11, QTableWidgetItem(row["StepTime"])) try: self.ui.table_testpoint.item(r, 0).setBackground(QtGui.QColor(204, 255, 255)) except: print(f"no color set for row {r}") r +=1