I save the table with pictures, and the memory address PyQt4.QtGui.QTableWidgetItem object at 0x00000000041A3F78 gets in the cells instead of the picture, and when I load the table I get it. Here are the functions, if you need to throw off all the code.
def save_file(self): filename = (QFileDialog.getSaveFileName(self, 'Сохранить', '', ".xls(*.xls)")) wbk = xlwt.Workbook() sheet = wbk.add_sheet("схема", cell_overwrite_ok=True) self.s_f(sheet) wbk.save(filename) def s_f(self, sheet): for currentColumn in range(self.table.columnCount()): for currentRow in range(self.table.rowCount()): my_icon = self.table.item(currentRow, currentColumn) sheet.write(currentRow, currentColumn, str(my_icon or '')) -------------------------------------------------- ------------------
def open_file(self): filename = QFileDialog.getOpenFileName(self, 'Открыть', '', '.xls(*.xls)') book = xlrd.open_workbook(filename) sheet = book.sheet_by_index(0) data = [[sheet.cell_value(r, c)for c in range(sheet.ncols)]for r in range(sheet.nrows)] for row, columnvalues in enumerate(data): for column, value in enumerate(columnvalues): item = QTableWidgetItem() item.setData(Qt.DisplayRole, str(value)) self.table.setItem(row, column, item) What did I miss?
value? Way? Try to see what will returnmy_icon.icon()- mkkik