コード例 #1
0
ファイル: statsTableDlg.py プロジェクト: jnesme/STAMP
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)
コード例 #2
0
ファイル: statsTableDlg.py プロジェクト: mlangill/STAMP
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)
コード例 #3
0
    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)
コード例 #4
0
ファイル: statsTableDlg.py プロジェクト: beiko-lab/STAMP
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)
コード例 #5
0
ファイル: statsTableDlg.py プロジェクト: jnesme/STAMP
	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)
コード例 #6
0
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)