Configuration utilities for the Panda3D game engine
Project description
Panda3D Config
Experimental library. Not suitable for production use.
Configuration utilities for the Panda3D game engine. Provides a convenient wrapper around Panda3D's configuration system with support for declaring typed variables, validation, change notifications, and loading/saving user settings from files.
Features
- Typed variable declarations — Declare config variables with explicit types (
bool,int,double,string) and default values. - Validation — Automatic type validation on set, with support for custom per-variable validators.
- Change notifications — Messenger events are sent when variables change, making it easy to react to config updates at runtime.
- Load/Save — Read and write configuration files in Panda3D's native format, with optional human-readable descriptions.
- Restart tracking — Mark variables that require a restart, so your UI can inform users when a restart is needed.
- Built-in ShowBase config —
ShowBaseConfigprovides pre-declared variables for common graphics, window, and audio settings.
Installation
pip install panda3d-config
Dependencies
Quick Start
Custom configuration
from panda3d import core as p3d
from panda3d_config import PandaConfig
config = PandaConfig("MyGame")
# Declare variables with type and default value
config.declare_variable("music-volume", "0.8", p3d.ConfigFlags.VT_double)
config.declare_variable("show-hud", "true", p3d.ConfigFlags.VT_bool)
config.declare_variable("difficulty", "1", p3d.ConfigFlags.VT_int, restart_required=True)
# Get and set values
config.set("music-volume", "0.5")
value = config.get("music-volume") # "0.5"
# Save to file
config.save("settings.config")
# Load from file
config.load("settings.config")
Using ShowBaseConfig
ShowBaseConfig comes with pre-declared variables for common Panda3D settings like display mode, window size, fullscreen, anti-aliasing, texture filtering, and audio.
from panda3d_config import ShowBaseConfig
settings = ShowBaseConfig()
# Configure before creating ShowBase
settings.set("win-size", "1920 1080")
settings.set("fullscreen", "true")
settings.set("multisamples", "4")
settings.set("framebuffer-multisample", "true")
# Save user preferences
settings.save("user-settings.config")
Changes to win-size and fullscreen are applied to the window automatically at runtime if ShowBase is already running.
Custom validation
Define a method named <variable>_validate (with hyphens replaced by underscores) on a PandaConfig subclass to add custom validation logic:
class GameConfig(PandaConfig):
def __init__(self):
super().__init__("GameConfig")
self.declare_variable("difficulty", "1", p3d.ConfigFlags.VT_int)
def difficulty_validate(self, value: str) -> bool:
return int(value) in range(0, 4)
Listening for changes
from direct.showbase.DirectObject import DirectObject
class SettingsUI(DirectObject):
def __init__(self):
super().__init__()
self.accept("music-volume-config-value-changed", self.on_volume_changed)
def on_volume_changed(self, value: str):
print(f"Volume changed to {value}")
License
This project is licensed under the MIT License — see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file panda3d_config-0.0.0-py3-none-any.whl.
File metadata
- Download URL: panda3d_config-0.0.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0cd0ec13d00c52a7eb8aaa9f3ef47e73997e025e668fc3af220007f213d34c6
|
|
| MD5 |
208048c39a425e8793e8c28f14de3b34
|
|
| BLAKE2b-256 |
5c080c183456d413a540809b4436187e54ca394b686b7a6453146c378bd351a1
|
Provenance
The following attestation bundles were made for panda3d_config-0.0.0-py3-none-any.whl:
Publisher:
ci.yml on DigitalDescent/panda3d-config
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
panda3d_config-0.0.0-py3-none-any.whl -
Subject digest:
b0cd0ec13d00c52a7eb8aaa9f3ef47e73997e025e668fc3af220007f213d34c6 - Sigstore transparency entry: 1206303604
- Sigstore integration time:
-
Permalink:
DigitalDescent/panda3d-config@f65ec6e021d95e6425d1242ed20ef759519a3c4f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DigitalDescent
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@f65ec6e021d95e6425d1242ed20ef759519a3c4f -
Trigger Event:
push
-
Statement type: