Ejemplo n.º 1
0
    def save_to_file(self):
        """Save table values to file."""
        df = _utils.table_to_data_frame(self.tbl_table)
        if df is None:
            _QMessageBox.critical(self, 'Failure', 'Empty table.',
                                  _QMessageBox.Ok)
            return

        filename = _QFileDialog.getSaveFileName(
            self,
            caption='Save measurements file.',
            directory=self.directory,
            filter="Text files (*.txt *.dat)")

        if isinstance(filename, tuple):
            filename = filename[0]

        if len(filename) == 0:
            return

        try:
            if (not filename.endswith('.txt')
                    and not filename.endswith('.dat')):
                filename = filename + '.txt'
            df.to_csv(filename, sep='\t')

        except Exception:
            _traceback.print_exc(file=_sys.stdout)
            msg = 'Failed to save data to file.'
            _QMessageBox.critical(self, 'Failure', msg, _QMessageBox.Ok)
Ejemplo n.º 2
0
 def update_table_analysis_dialog(self):
     """Update table analysis dialog."""
     self.table_analysis_dialog.update_data(
         _utils.table_to_data_frame(self.tbl_table))
Ejemplo n.º 3
0
 def show_table_analysis_dialog(self):
     """Show table analysis dialog."""
     df = _utils.table_to_data_frame(self.tbl_table)
     self.table_analysis_dialog.accept()
     self.table_analysis_dialog.show(df)
Ejemplo n.º 4
0
 def copy_to_clipboard(self):
     """Copy table data to clipboard."""
     df = _utils.table_to_data_frame(self.tbl_table)
     if df is not None:
         df.to_clipboard(excel=True)