Esempio n. 1
0
    def do_save_data(self):
        """
        Save plotted data as data file or image according to the file type
        :return:
        """
        default_dir = self._parent.controller.get_working_dir()
        file_filter = 'PNG (*.png);;JPG (*.jpg);;Post Script (*.ps);;Ascii (*.dat);;HDF5 (*.hdf5)'

        out_file_name = GuiUtility.get_save_file_by_dialog(
            self, 'Specify file name to save data', default_dir, file_filter)

        # identify the file type
        file_postfix = out_file_name.split('.')[-1].lower()

        if file_postfix in ['png', 'jpg', 'jpeg', 'ps', 'pdf']:
            # export image to file
            self.ui.graphicsView_mainPlot.save_image(out_file_name)
        elif file_postfix in ['hdf5', 'h5', 'dat', 'data']:
            # save column data
            self.ui.graphicsView_mainPlot.export_data(out_file_name)
        else:
            GuiUtility.pop_dialog_error(
                self, 'Output file {} with type {} is not supported.'
                ''.format(out_file_name, file_postfix))

        return
Esempio n. 2
0
    def do_save_slicers_to_file(self):
        """
        save current time slicers to a file
        :return:
        """
        # Get splitters
        try:
            split_tup_list = self.ui.tableWidget_segments.get_splitter_list()
        except RuntimeError as e:
            GuiUtility.pop_dialog_error(self, str(e))
            return

        # pop a dialog for the name of the slicer
        file_filter = 'Data Files (*.dat);; All Files (*.*)'
        file_name = GuiUtility.get_save_file_by_dialog(
            self,
            title='Time slicer file name',
            default_dir=self.controller.get_working_dir(),
            file_filter=file_filter)

        if len(file_name) == 0:
            return

        if not (file_name.endswith('.dat') or file_name.endswith('.txt')):
            file_name = '{}.dat'.format(file_name)

        # Call parent method
        if self._myParent is not None:
            # TODO/ISSUE/33/NOW - Let _myParent to handle this! send a signal to parent with list!
            status, err_msg = self.controller.save_time_slicers(
                split_tup_list, file_name)
            if not status:
                GuiUtility.pop_dialog_error(self, err_msg)
                return
        # END-IF

        return