Skip to main content

wxconfig

A library for managing application settings stored in a yaml file. Provides a dynamically generated wxpython dialog box for enabling the user to modify settings. Supports settings metadata including setting label and help text which can be displayed in the dynamically generated dialog.

Usage

  1. Define your application settings in a yaml file:
[config.yaml]
app_function_1:
  setting_theme_1:
    setting_1: A text value
    setting_2: True
    setting_3: 22.2
  setting_theme_2:
    setting_1: A text value
    setting_2: True
    setting_3: 22.2
  1. If you require your settings dialog to contain nicely formatted labels and tooltips, define these in a separate yaml file:
[configmeta.yaml]
app_function_1:
  setting_theme_1:
    setting_1:
      __label: Setting 1
      __helptext: This is the tooltip for setting 1
    setting_2:
      __label: Setting 2
      __helptext: This is the tooltip for setting 2
  1. In your application, load your config. Also load your metadata if required:
import wxconfig as cfg

cfg.Config().load("config.yaml", meta="configmeta.yaml")
  1. You can access your applications config from anywhere in your application. Config is a singleton, and retains its state throughout the applications instance. Config values can be set and retrieved using dot notation to represent their path as defined in the config file:
import wxconfig as cfg

# Get a config value
conf_val = cfg.Config().get('app_function_1.setting_theme_1.setting_1')

# Set a congig value
cfg.Config().set('app_function_1.setting_theme_1.setting_1', 'A new text value')
  1. Any altered settings can be saved back to the config file:
import wxconfig as cfg

cfg.Config().save()
  1. Your application can open a setting dialog box that allows the user to change the applications settings. Any settings that you do not want the user to change can be excluded:
import wxconfig as cfg

# Display the dialog. Exclude all settings under setting_theme_2
settings_dialog = cfg.SettingsDialog(parent=None, exclude=['setting_theme_2'])
res = settings_dialog.ShowModal()
  1. If the user cancels the dialog, any changed settings are discarded, and the return value is wx.ID_CANCEL. If the user selects update, the settings are saved, and the return value is wx.ID_OK. All changed settings can be accessed through the setting dialogs changed_settings property, which contains a dict of settings paths and new values:
import wx
import wxconfig as cfg

# Display the dialog. Exclude all settings under setting_theme_2
settings_dialog = cfg.SettingsDialog(parent=None, exclude=['setting_theme_2'])
res = settings_dialog.ShowModal()

if res == wx.ID_OK:
    for changed_setting in settings_dialog.changed_settings:
        # Application logic to handle changed config values goes here
        # ...
        print(f"Setting {changed_setting} has changed to {settings_dialog.changed_settings[changed_setting]}")
  1. If you would like the settings dialogs position, size and style to be restored the next time the user opens it, then this can be stored in the config file. Create a config section named settings_window with the initial values. These will be changed if the user repositions or resizes the settings dialog. Keep the style value as is or change to a different wxpython window style:
[config.yaml]
settings_window:
  x: 354
  y: 299
  width: 727
  height: 419
  style: 524352

Metadata

Release files for wxconfig 1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wxconfig 1.5
File Size Uploaded Provenance Actions
wxconfig-1.5.tar.gz 10.4 kB Without provenance Details for wxconfig-1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wxconfig 1.5
File Interpreter ABI Platform Actions
wxconfig-1.5-py3-none-any.whl Python 3 none any Details for wxconfig-1.5-py3-none-any.whl

Total release size: 21.0 kB

Release files / wxconfig-1.5.tar.gz

Download URL wxconfig-1.5.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
db92711b6b37dac17bf80faa4bb385b2c372c3a33dbff09d23bae81706b20882
BLAKE2b-256 checksum
How to use checksums
f59d18e6cd93cde141082c87b4415cab59241847d0f04af30fe8e5f504052989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.6

Release files / wxconfig-1.5-py3-none-any.whl

Download URL wxconfig-1.5-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
346d75741decd1db789c8f2e736a27dd344227852b2e9f7550c8a2da7db4da0e
BLAKE2b-256 checksum
How to use checksums
68cfd1a05926cd3d7b72cee48963e33d6ffa768841e62a0c5c3d717cbd5db409
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.6

Security for wxconfig 1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page