Configurations
API reference
carefree-drawboard
🎨 is designed to hold configurations in one single file - the cfconfig.py
file.
constants.py
DEFAULT_ENTRY = "app"
FRONTEND_PORT = "5123"
BACKEND_PORT = "8123"
UPLOAD_ROOT_KEY = "CFDRAW_UPLOAD_ROOT"
UPLOAD_ROOT = Path("~").expanduser() / ".cache" / "carefree-draw"
def get_upload_root() -> str:
return os.environ.get(UPLOAD_ROOT_KEY, str(UPLOAD_ROOT))
config.py
@dataclass
class Config:
entry: str = constants.DEFAULT_ENTRY
frontend_port: str = constants.FRONTEND_PORT
backend_port: str = constants.BACKEND_PORT
backend_hosting_url: Optional[str] = None
upload_root: str = field(default_factory=constants.get_upload_root)
board_settings: BoardSettings = field(default_factory=BoardSettings)
extra_plugins: ExtraPlugins = field(default_factory=ExtraPlugins)
use_react_strict_mode: bool = False
cfconfig.py
from cfdraw import *
config = Config()
The most commonly used configuration is probably the upload_root
property, which is used to specify the root directory for storing uploaded stuffs (projects, creations, etc.):
cfconfig.py
from cfdraw import *
config = Config(
# This tells us to use `cwd` to store the uploaded stuffs
upload_root="./",
)
If you want to customize some overall settings for the drawboard 🎨, you can use the board_settings
property. For example, if you want to switch the default language to Chinese, you can:
cfconfig.py
from cfdraw import *
config = Config(
board_settings=BoardSettings(
globalSettings=GlobalSettings(
defaultLang=Lang.ZH,
)
)
)
carefree-drawboard
🎨 also provides the extra_plugins
property in case you need. For example, if you want to place your logo on the lt
(left-top) corner of the drawboard 🎨, you can:
cfconfig.py
from cfdraw import *
config = Config(
extra_plugins=ExtraPlugins(
logo=ILogoSettings(
iconW=300,
iconH=99,
pivot=PivotType.LT,
src="https://url/to/your/logo.png",
)
),
)