MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / UserSettings

Class UserSettings

PySimpleGUI/PySimpleGUI.py:22337–22930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22335# created from the source file filename.
22336
22337class UserSettings:
22338 # A reserved settings object for use by the setting functions. It's a way for users
22339 # to access the user settings without diarectly using the UserSettings class
22340 _default_for_function_interface = None # type: UserSettings
22341
22342 def __init__(self, filename=None, path=None, silent_on_error=False, autosave=True, use_config_file=None, convert_bools_and_none=True):
22343 """
22344 User Settings
22345
22346 :param filename: The name of the file to use. Can be a full path and filename or just filename
22347 :type filename: (str or None)
22348 :param path: The folder that the settings file will be stored in. Do not include the filename.
22349 :type path: (str or None)
22350 :param silent_on_error: If True errors will not be reported
22351 :type silent_on_error: (bool)
22352 :param autosave: If True the settings file is saved after every update
22353 :type autosave: (bool)
22354 :param use_config_file: If True then the file format will be a config.ini rather than json
22355 :type use_config_file: (bool)
22356 :param convert_bools_and_none: If True then "True", "False", "None" will be converted to the Python values True, False, None when using INI files. Default is TRUE
22357 :type convert_bools_and_none: (bool)
22358 """
22359
22360 self.path = path
22361 self.filename = filename
22362 self.full_filename = None
22363 self.dict = {}
22364 self.default_value = None
22365 self.silent_on_error = silent_on_error
22366 self.autosave = autosave
22367 if filename is not None and filename.endswith('.ini') and use_config_file is None:
22368 warnings.warn('[UserSettings] You have specified a filename with .ini extension but did not set use_config_file. Setting use_config_file for you.', UserWarning)
22369 use_config_file = True
22370 self.use_config_file = use_config_file
22371 # self.retain_config_comments = retain_config_comments
22372 self.convert_bools = convert_bools_and_none
22373 if use_config_file:
22374 self.config = configparser.ConfigParser()
22375 self.config.optionxform = str
22376 # self.config_dict = {}
22377 self.section_class_dict = {} # type: dict[_SectionDict]
22378 if filename is not None or path is not None:
22379 self.load(filename=filename, path=path)
22380
22381 ########################################################################################################
22382 ## FIRST is the _SectionDict helper class
22383 ## It is typically not directly accessed, although it is possible to call delete_section, get, set
22384 ########################################################################################################
22385
22386 class _SectionDict:
22387 item_count = 0
22388
22389 def __init__(self, section_name, section_dict, config, user_settings_parent): # (str, Dict, configparser.ConfigParser)
22390 """
22391 The Section Dictionary. It holds the values for a section.
22392
22393 :param section_name: Name of the section
22394 :type section_name: str

Callers 6

set_optionsFunction · 0.85
popup_get_folderFunction · 0.85
popup_get_fileFunction · 0.85
popup_get_textFunction · 0.85
PySimpleGUI.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected