Skip to main content

Sparse JSON based config files with GUI editor.

Project description

jsonConfig is a Python package that provides sparse JSON based config files with GUI editor. The config files are referred to as being sparse because only those settings which are different than the default values are stored in the config files. Default config options are defined programmatically which allows defaults to be updated with out overwriting a users options.

Usage

Creating defaults

from jsonConfig import *

cfg = Config()
cfg.add_setting( 'Category 1', 'option1', 'Value1', alias = 'Option #1', options = ['Value1', 'Value2'], type = CT_COMBO, about = 'An example option.' )
cfg.add_setting( 'Category 1', 'option2', True, alias = 'Option #2', type = CT_CHECKBOX )
cfg.add_setting( 'Category 2', 'option1', 'value', type = CT_LINEEDIT)

Accessing values

>>> cfg
{'Category 2': {'option1': 'value'}, 'Category 1': {'option2': True, 'option1': 'Value1'}}

>>> cfg['Category 1']['option1']
'Value1'

Loading config file

config.json

{
  "Category 1": {
    "option1": {
      "value": "Value2"
    }
  }
}
cfg.set_user_file("config.json")
>>> cfg
{'Category 2': {'option1': 'value'}, 'Category 1': {'option2': True, 'option1': 'Value2'}}

GUI Editor

from PySide.QtGui import *
from jsonConfig import ConfigEditor

app = QApplication([])
editor = ConfigEditor(app, cfg, 'Demo Config Editor')
editor.setup()
app.exec_()
http://ompldr.org/vZnRscg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsonConfig-0.1.2.tar.gz (15.8 kB view details)

Uploaded Source

File details

Details for the file jsonConfig-0.1.2.tar.gz.

File metadata

  • Download URL: jsonConfig-0.1.2.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsonConfig-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fb9eb0d4df4f954c5efbc99c8a0c2b5ed0c511f740886a8d7a736463754ce715
MD5 88f7c092b7dca99344ac289189ef3f07
BLAKE2b-256 dad5f915a696f68edfead69e0fc9f7ca0f6ebe41189cf60be80ca39732c0fd33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page