def saveTheme(self): """ Saves the current theme to the disk, in appDataDir/themes """ if self.cur_theme["builtin"]: return themeName = self.curThemeCmb.currentText().strip() if not themeName: return # Get user theme dir and make sure it exists dir = os.path.join(pyzo.appDataDir, "themes") if not os.path.isdir(dir): os.mkdir(dir) # Try to delete the old file if it exists (useful if it was renamed) try: os.remove(os.path.join(dir, self.cur_theme_key + ".theme")) except Exception: pass # This is the needed because of the SSDF format: # it doesn't accept dots, so we put underscore instead data = { x.replace(".", "_"): y for x, y in self.cur_theme["data"].items() } fname = os.path.join(dir, themeName + ".theme") ssdf.save(fname, {"name": themeName, "data": data}) print("Saved theme '%s' to '%s'" % (themeName, fname))
def saveConfig(): """ saveConfig() Save all configureations to file. """ # Let the editorStack save its state if editors: editors.saveEditorState() # Let the main window save its state if main: main.saveWindowState() # Store config if _saveConfigFile: ssdf.save( os.path.join(appDataDir, "config.ssdf"), config )
def resetConfig(preserveState=True): """ resetConfig() Replaces the config file with the default and prevent Pyzo from storing its config on the next shutdown. """ # Get filenames configFileName1 = os.path.join(pyzoDir, 'resources', 'defaultConfig.ssdf') configFileName2 = os.path.join(appDataDir, 'config.ssdf') # Read, edit, write tmp = ssdf.load(configFileName1) if preserveState: tmp.state = config.state ssdf.save(configFileName2, tmp) global _saveConfigFile _saveConfigFile = False print("Replaced config file. Restart Pyzo to revert to the default config.")
def saveConfig(): """ saveConfig() Save all configureations to file. """ # Let the editorStack save its state if editors: editors.saveEditorState() # Let the main window save its state if main: main.saveWindowState() # Store config if _saveConfigFile: ssdf.save(os.path.join(appDataDir, "config.ssdf"), config)
def saveConfig(): """saveConfig() Save all configureations to file. """ # Let the editorStack save its state if pyzo.editors: pyzo.editors.saveEditorState() # Let the main window save its state if pyzo.main: pyzo.main.saveWindowState() # Store config if pyzo._saveConfigFile: ssdf.save(os.path.join(pyzo.appConfigDir, "config.ssdf"), pyzo.config)
def resetConfig(preserveState=True): """ resetConfig() Replaces the config file with the default and prevent Pyzo from storing its config on the next shutdown. """ # Get filenames configFileName1 = os.path.join(pyzoDir, 'resources', 'defaultConfig.ssdf') configFileName2 = os.path.join(appDataDir, 'config.ssdf') # Read, edit, write tmp = ssdf.load(configFileName1) if preserveState: tmp.state = config.state ssdf.save(configFileName2, tmp) global _saveConfigFile _saveConfigFile = False print( "Replaced config file. Restart Pyzo to revert to the default config.")