def on_open_profile(self, category): dlg = wx.FileDialog(self, _("Select profile file to load"), profile.get_base_path(), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("JSON files (*.json)|*.json") if dlg.ShowModal() == wx.ID_OK: profile_file = dlg.GetPath() profile.settings.load_settings(profile_file, categories=[category]) self.update_profile_to_all_controls() dlg.Destroy()
def on_save_profile(self, category): dlg = wx.FileDialog(self, _("Select profile file to save"), profile.get_base_path(), category.replace('_settings', ''), style=wx.FD_SAVE) dlg.SetWildcard("JSON files (*.json)|*.json") if dlg.ShowModal() == wx.ID_OK: profile_file = dlg.GetPath() if not profile_file.endswith('.json'): if sys.is_linux(): # hack for linux, as for some reason the .json is not appended. profile_file += '.json' profile.settings.save_settings(profile_file, categories=[category]) dlg.Destroy()
def on_export_log(self, event): dlg = wx.FileDialog(self, _("Select log file to save"), profile.get_base_path(), style=wx.FD_SAVE) dlg.SetWildcard("Log files (*.log)|*.log") if dlg.ShowModal() == wx.ID_OK: log_file = dlg.GetPath() if not log_file.endswith('.log'): if sys.is_linux(): # hack for linux, as for some reason the .log is not appended. log_file += '.log' with open(log_file, 'w') as _file: with open('horus.log', 'r') as _log: _file.write(_log.read()) log_file dlg.Destroy()