MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / save

Method save

PySimpleGUI/PySimpleGUI.py:22635–22661  ·  view source on GitHub ↗

Saves the current settings dictionary. If a filename or path is specified in the call, then it will override any previously specitfied filename to create a new settings file. The settings dictionary is then saved to the newly defined file. :param filename: The fFilename t

(self, filename=None, path=None)

Source from the content-addressed store, hash-verified

22633 return self.full_filename
22634
22635 def save(self, filename=None, path=None):
22636 """
22637 Saves the current settings dictionary. If a filename or path is specified in the call, then it will override any
22638 previously specitfied filename to create a new settings file. The settings dictionary is then saved to the newly defined file.
22639
22640 :param filename: The fFilename to save to. Can specify a path or just the filename. If no filename specified, then the caller's filename will be used.
22641 :type filename: (str or None)
22642 :param path: The (optional) path to use to save the file.
22643 :type path: (str or None)
22644 :return: The full path and filename used to save the settings
22645 :rtype: (str)
22646 """
22647 if filename is not None or path is not None:
22648 self.set_location(filename=filename, path=path)
22649 try:
22650 if not os.path.exists(self.path):
22651 os.makedirs(self.path)
22652 with open(self.full_filename, 'w') as f:
22653 if not self.use_config_file:
22654 json.dump(self.dict, f)
22655 else:
22656 self.config.write(f)
22657 except Exception as e:
22658 if not self.silent_on_error:
22659 _error_popup_with_traceback('UserSettings.save error', '*** UserSettings.save() Error saving settings to file:***\n', self.full_filename, e)
22660
22661 return self.full_filename
22662
22663 def load(self, filename=None, path=None):
22664 """

Callers 15

write_new_dictionaryMethod · 0.95
delete_entryMethod · 0.95
delete_sectionMethod · 0.95
setMethod · 0.95
get_dictMethod · 0.95
convert_to_bytesFunction · 0.80
get_img_dataFunction · 0.80
convert_to_bytesFunction · 0.80
save_winFunction · 0.80
Demo_Google_TTS.pyFile · 0.80
save_element_as_fileFunction · 0.80

Calls 4

set_locationMethod · 0.95
existsMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected