Пример #1
0
 def _load_settings(self):
     config_file = ['conf (*.conf)', 'All files (*)']
     file_name, used_filter = QFileDialog().getOpenFileName(caption='Select the GUI config file',
                                                            filter=';;'.join(config_file))
     if file_name:
         with open(file_name, 'r') as f:
             try:
                 self._controller.apply_action(NewConfigAction(MapPlotConfig.from_yaml(f.read())))
             except yaml.parser.ParserError:
                 pass
             except yaml.scanner.ScannerError:
                 pass
             except ValueError:
                 pass
Пример #2
0
    def _config_from_string(self, text):
        self._flags['updating_config_from_string'] = True
        text = text.replace('\t', ' '*4)
        try:
            if text.strip() != '':
                new_config = MapPlotConfig.from_yaml(text)
                new_config.validate(self._controller.get_data())

                self._controller.apply_action(NewConfigAction(new_config))
                self._update_status_indication(True)

        except Exception as exc:
            self._update_status_indication(False, str(exc))
            pass
        finally:
            self._flags['updating_config_from_string'] = False