class StatsTableDlg(QtGui.QDockWidget): def __init__(self, preferences, parent=None, info=None): QtGui.QDockWidget.__init__(self, parent) # initialize GUI self.ui = Ui_StatsTableDlg() self.ui.setupUi(self) self.preferences = preferences self.table = '' # signals self.connect(self.ui.btnSave, QtCore.SIGNAL("clicked()"), self.saveTable) self.connect(self.ui.chkShowActiveFeatures, QtCore.SIGNAL("clicked()"), self.__updateTable) def updateTable(self, statsTest): self.statsTest = statsTest self.__updateTable() def __updateTable(self): if self.statsTest.results.profile != None: tableData, tableHeadings = self.statsTest.results.tableData(self.ui.chkShowActiveFeatures.isChecked()) self.table = GenericTable(tableData, tableHeadings, self) self.table.sort(0,QtCore.Qt.AscendingOrder) # start with features in alphabetical order self.ui.tableStatisticalSummary.setModel(self.table) self.ui.tableStatisticalSummary.verticalHeader().setVisible(False) # resize columns to fit context by sampling first 100 rows #self.ui.tableStatisticalSummary.resizeColumnsToContents() for colIndex in xrange(0, self.table.columnCount(None)): fm = self.ui.tableStatisticalSummary.fontMetrics() maxWidth = fm.width(tableHeadings[colIndex]) + 10 for i in xrange(0, 100): # sample first 100 rows to estimate column width, this is strictly for efficiency width = fm.width(self.ui.tableStatisticalSummary.model().data(self.ui.tableStatisticalSummary.model().index(i,colIndex), QtCore.Qt.DisplayRole).toString()) + 10 if width > maxWidth: maxWidth = width self.ui.tableStatisticalSummary.setColumnWidth(colIndex, maxWidth) def saveTable(self): filename = QtGui.QFileDialog.getSaveFileName(self, 'Save table...', self.preferences['Last directory'], 'Tab-separated values (*.tsv);;' + 'Text file (*.txt);;' + 'All files (*.*)') if filename != '': self.preferences['Last directory'] = filename[0:filename.lastIndexOf('/')] try: if self.table != '': self.table.save(filename) except IOError: QtGui.QMessageBox.information(self, 'Failed to save table', 'Write permission for file denied.', QtGui.QMessageBox.Ok)
class StatsTableDlg(QtGui.QDockWidget): def __init__(self, preferences, parent=None, info=None): QtGui.QDockWidget.__init__(self, parent) # initialize GUI self.ui = Ui_StatsTableDlg() self.ui.setupUi(self) self.preferences = preferences self.table = '' # signals self.connect(self.ui.btnSave, QtCore.SIGNAL("clicked()"), self.saveTable) self.connect(self.ui.chkShowActiveFeatures, QtCore.SIGNAL("clicked()"), self.__updateTable) def updateTable(self, statsTest): self.statsTest = statsTest self.__updateTable() def __updateTable(self): if self.statsTest.results.profile != None: tableData, tableHeadings = self.statsTest.results.tableData( self.ui.chkShowActiveFeatures.isChecked()) self.table = GenericTable(tableData, tableHeadings, self) self.table.sort(0, QtCore.Qt.AscendingOrder ) # start with features in alphabetical order self.ui.tableStatisticalSummary.setModel(self.table) self.ui.tableStatisticalSummary.verticalHeader().setVisible(False) self.ui.tableStatisticalSummary.resizeColumnsToContents() def saveTable(self): filename = QtGui.QFileDialog.getSaveFileName( self, 'Save table...', self.preferences['Last directory'], 'Tab-separated values (*.tsv);;' + 'Text file (*.txt);;' + 'All files (*.*)') if filename != '': self.preferences['Last directory'] = filename[0:filename. lastIndexOf('/')] try: if self.table != '': self.table.save(filename) except IOError: QtGui.QMessageBox.information( self, 'Failed to save table', 'Write permission for file denied.', QtGui.QMessageBox.Ok)
def __init__(self, preferences, parent=None, info=None): QtGui.QDockWidget.__init__(self, parent) # initialize GUI self.ui = Ui_StatsTableDlg() self.ui.setupUi(self) self.preferences = preferences self.table = '' # signals self.connect(self.ui.btnSave, QtCore.SIGNAL("clicked()"), self.saveTable) self.connect(self.ui.chkShowActiveFeatures, QtCore.SIGNAL("clicked()"), self.__updateTable)
class StatsTableDlg(QtGui.QDockWidget): def __init__(self, preferences, parent=None, info=None): QtGui.QDockWidget.__init__(self, parent) # initialize GUI self.ui = Ui_StatsTableDlg() self.ui.setupUi(self) self.preferences = preferences self.table = '' # signals self.connect(self.ui.btnSave, QtCore.SIGNAL("clicked()"), self.saveTable) self.connect(self.ui.chkShowActiveFeatures, QtCore.SIGNAL("clicked()"), self.__updateTable) def updateTable(self, statsTest): self.statsTest = statsTest self.__updateTable() def __updateTable(self): if self.statsTest.results.profile != None: tableData, tableHeadings = self.statsTest.results.tableData(self.ui.chkShowActiveFeatures.isChecked()) self.table = GenericTable(tableData, tableHeadings, self) self.table.sort(0,QtCore.Qt.AscendingOrder) # start with features in alphabetical order self.ui.tableStatisticalSummary.setModel(self.table) self.ui.tableStatisticalSummary.verticalHeader().setVisible(False) self.ui.tableStatisticalSummary.resizeColumnsToContents() def saveTable(self): filename = QtGui.QFileDialog.getSaveFileName(self, 'Save table...', self.preferences['Last directory'], 'Tab-separated values (*.tsv);;' + 'Text file (*.txt);;' + 'All files (*.*)') if filename != '': self.preferences['Last directory'] = filename[0:filename.lastIndexOf('/')] try: if self.table != '': self.table.save(filename) except IOError: QtGui.QMessageBox.information(self, 'Failed to save table', 'Write permission for file denied.', QtGui.QMessageBox.Ok)
class StatsTableDlg(QtGui.QDockWidget): def __init__(self, preferences, parent=None, info=None): QtGui.QDockWidget.__init__(self, parent) # initialize GUI self.ui = Ui_StatsTableDlg() self.ui.setupUi(self) self.preferences = preferences self.table = '' # signals self.connect(self.ui.btnSave, QtCore.SIGNAL("clicked()"), self.saveTable) self.connect(self.ui.chkShowActiveFeatures, QtCore.SIGNAL("clicked()"), self.__updateTable) def updateTable(self, statsTest): self.statsTest = statsTest self.__updateTable() def __updateTable(self): if self.statsTest.results.profile != None: tableData, tableHeadings = self.statsTest.results.tableData( self.ui.chkShowActiveFeatures.isChecked()) self.table = GenericTable(tableData, tableHeadings, self) self.table.sort(0, QtCore.Qt.AscendingOrder ) # start with features in alphabetical order self.ui.tableStatisticalSummary.setModel(self.table) self.ui.tableStatisticalSummary.verticalHeader().setVisible(False) # resize columns to fit context by sampling first 100 rows #self.ui.tableStatisticalSummary.resizeColumnsToContents() for colIndex in xrange(0, self.table.columnCount(None)): fm = self.ui.tableStatisticalSummary.fontMetrics() maxWidth = fm.width(tableHeadings[colIndex]) + 10 for i in xrange( 0, 100 ): # sample first 100 rows to estimate column width, this is strictly for efficiency width = fm.width( self.ui.tableStatisticalSummary.model().data( self.ui.tableStatisticalSummary.model().index( i, colIndex), QtCore.Qt.DisplayRole).toString()) + 10 if width > maxWidth: maxWidth = width self.ui.tableStatisticalSummary.setColumnWidth( colIndex, maxWidth) def saveTable(self): filename = QtGui.QFileDialog.getSaveFileName( self, 'Save table...', self.preferences['Last directory'], 'Tab-separated values (*.tsv);;' + 'Text file (*.txt);;' + 'All files (*.*)') if filename != '': self.preferences['Last directory'] = filename[0:filename. lastIndexOf('/')] try: if self.table != '': self.table.save(filename) except IOError: QtGui.QMessageBox.information( self, 'Failed to save table', 'Write permission for file denied.', QtGui.QMessageBox.Ok)