Class Widgets 2 Plugin SDK Development tools and type stubs
Project description
[!CAUTION]
本项目还处在开发阶段,API 接口可能随时发生变化,敬请谅解。
This project is still in development. The API may change at any time, so please bear with us.
Overview
class-widgets-sdk provides the essential base classes, development tools (like scaffolding and packaging), and complete type hints for creating plugins for Class Widgets 2.
This package provides the core SDK for development and must be installed in your plugin's environment. Plugins are executed within the Class Widgets 2 main application.
Installation
pip install class-widgets-sdk
Getting Started
1. Create a new plugin
Use the included CLI tool to generate a new plugin project structure:
cw-plugin-init com.example.myplugin
2. Install dependencies
Navigate to your new plugin directory and install the SDK in editable mode:
cd com.example.myplugin
pip install -e .
3. Usage (Base Class & Types)
The SDK provides the base class CW2Plugin and models for configuration, giving you full IDE autocompletion and static analysis support.
from ClassWidgets.SDK import CW2Plugin, ConfigBaseModel, PluginAPI
class MyConfig(ConfigBaseModel):
enabled: bool = True
text: str = "hEIlo, WoRId"
class MyPlugin(CW2Plugin):
def __init__(self, api: PluginAPI):
super().__init__(api)
self.config = MyConfig()
def on_load(self):
self.api.config.register_plugin_model(self.pid, self.config)
# Your IDE will provide full autocompletion here
self.api.widgets.register(
widget_id="com.example.mywidget",
name="My Widget",
qml_path="path/to/mywidget.qml"
)
4. Package
Use the included CLI tool to build and package your plugin into a distributable .cwplugin or .zip file:
cw-plugin-pack
Tools
The SDK includes powerful command-line tools for plugin development and distribution:
| Command | Description |
|---|---|
cw-plugin-init |
Generate a new plugin project scaffold. |
cw-plugin-pack |
Build and package the plugin into a distributable .cwplugin or .zip file. |
Learn more >
cw-plugin-init
Initialize a new Class Widgets plugin project with an interactive setup wizard.
Usage:
# Create plugin in current directory (interactive)
cw-plugin-init
# Create plugin in specific directory
cw-plugin-init my-plugin
# Force overwrite existing files
cw-plugin-init my-plugin --force
Flow:
- Select location (current dir or new folder)
- Enter plugin metadata (name, author, ID, etc.)
- Confirm and generate files
cw-plugin-pack
Build and package the plugin into a distributable .cwplugin or .zip file.
# Package current directory (default: .cwplugin)
cw-plugin-pack
# Specify format (.cwplugin or .zip)
cw-plugin-pack --format zip
# Specify output path
cw-plugin-pack -o ./dist/my-plugin.cwplugin
# Package specific directory
cw-plugin-pack ./my-plugin
Format
.cwplugin- Recommended plugin format.zip- Standard archive format
How It Works
- Development: You install this SDK package to get base classes, type hints, autocompletion, and static type checking (with mypy/pyright) in your IDE.
- Runtime: When your plugin is loaded by the Class Widgets 2 main application, your
CW2Pluginsubclass is instantiated and executed.
[!IMPORTANT]
- This package is the Development Kit for your plugin. Plugins must be tested within the Class Widgets 2 main application.
- The import path for the SDK is
ClassWidgets.SDK.
Links
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
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
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 class_widgets_sdk-0.4.1.tar.gz.
File metadata
- Download URL: class_widgets_sdk-0.4.1.tar.gz
- Upload date:
- Size: 214.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
357b7830532f5449b433414c919699a63c484c0f7465cb176e566681f04ee7d9
|
|
| MD5 |
3be76c9da35f27c172e49b9f138a998c
|
|
| BLAKE2b-256 |
56735427f5c0449f6eeecc96d6a4fb15e5ab5160d4bf1c7603328db83e8ebcf1
|
Provenance
The following attestation bundles were made for class_widgets_sdk-0.4.1.tar.gz:
Publisher:
python-publish.yml on Class-Widgets/class-widgets-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
class_widgets_sdk-0.4.1.tar.gz -
Subject digest:
357b7830532f5449b433414c919699a63c484c0f7465cb176e566681f04ee7d9 - Sigstore transparency entry: 976158445
- Sigstore integration time:
-
Permalink:
Class-Widgets/class-widgets-sdk@262394171246f9b057f2f1ee19870efa46cc0969 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/Class-Widgets
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@262394171246f9b057f2f1ee19870efa46cc0969 -
Trigger Event:
push
-
Statement type:
File details
Details for the file class_widgets_sdk-0.4.1-py3-none-any.whl.
File metadata
- Download URL: class_widgets_sdk-0.4.1-py3-none-any.whl
- Upload date:
- Size: 52.0 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 |
772423fd965767ee5891d37d6d4442c78b512d08ce890bf8e947ad98c2bed6d0
|
|
| MD5 |
d189b10b691162223cb6f63744111755
|
|
| BLAKE2b-256 |
dcec005004392c88f1ed9d5f5bca0e3f3ae791008eebb4ba7c6142a3869d8d56
|
Provenance
The following attestation bundles were made for class_widgets_sdk-0.4.1-py3-none-any.whl:
Publisher:
python-publish.yml on Class-Widgets/class-widgets-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
class_widgets_sdk-0.4.1-py3-none-any.whl -
Subject digest:
772423fd965767ee5891d37d6d4442c78b512d08ce890bf8e947ad98c2bed6d0 - Sigstore transparency entry: 976158446
- Sigstore integration time:
-
Permalink:
Class-Widgets/class-widgets-sdk@262394171246f9b057f2f1ee19870efa46cc0969 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/Class-Widgets
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@262394171246f9b057f2f1ee19870efa46cc0969 -
Trigger Event:
push
-
Statement type: