qtablewidget

writing a QTableWidget to a .csv or .xls

萝らか妹 提交于 2019-11-26 14:39:30
问题 Is it possible to write the contents of a QTableWidget to a csv? I found a question about writing to an .xls using xlwt, but can't seem to get it to work using my code. def saveFile(self): filename = unicode(QtGui.QFileDialog.getSaveFileName(self, 'Save File', '', ".xls(*.xls)")) wbk = xlwt.Workbook() self.sheet = wbk.add_sheet("sheet") self.write() wbk.save(filename) def write(self): for col in range (self.coordinates.columnCount()): for row in range(self.coordinates.rowCount()): text=str

get cell value based on header string and selected row

二次信任 提交于 2019-11-26 11:27:54
问题 For example, I have a PyQt QTableWidget which has 3 columns and 2 rows. The column headers are labeled A, B, and C. A B C 1 2 3 4 5 6 This is the excerpt from my current source: class myform(QtGui.QMainWindow): def __init__(self, parent=None): super(myform, self).__init__(parent) self.ui = Ui_mygui() self.ui.setupUi(self) self.ui.mytablewidget.cellClicked.connect(self.cell_was_clicked) @QtCore.pyqtSlot() # prevents executing following function twice def cell_was_clicked(self): row = self.ui

pyqt - populating QTableWidget with csv data

江枫思渺然 提交于 2019-11-26 06:46:31
问题 I have a QTableWidget, i export the data from this table to a csv file. But now, i want to Open a existing csv file and populate my table with this data. how can i do it? This is my export code, i want a \"populate\" code, and i really dont know how to do it.. i know how to read a csv but i dont know how to populate my table with this csv data. def export(self): nomeArquivo = \"nomeArquivo\" filename = unicode(QFileDialog.getSaveFileName(self, \"Document - Choose Export File\", nomeArquivo+\"