How to make your own widget
Guide explains how to create and add your own widget to Supervisely SDK
Last updated
Was this helpful?
Guide explains how to create and add your own widget to Supervisely SDK
Last updated
Was this helpful?
In this tutorial you will learn how to create your own widget, add it to Supervisely SDK and make small demo.
Clone SKD repo:
Clone repo with widgets samples:
Create SDK folder symlink in ui-widgets-demos
Create folder in supervisely/app/widgets/<your_widget_folder>
like that
Declare a new class with inheritance from Widget in your_widget.py
Construct template.html
for your widget using other widgets from SDK or any HTML elements
(Optional) Prepare file script.js
for your widget if you need to implement your own Vue JS component. 📗 See for more details.
Import new widget as part of widgets
module. Just add import in supervisely/app/widgets/__init__.py
Create folder with example of your widget in ui-widgets-demos/NEW widgets/<your_widget_example_folder>
like that
Example of main.py
To see the demo of your widget, you need to run the server. You got 2 options for that:
a) Just run the server from command line
python -m uvicorn "NEW widgets.grid_plot.src.main:app" --host 0.0.0.0 --port 8000 --ws websockets --reload
b) If you are VSCode user, then just edit ui-widgets-demos/.vscode/launch.json
as showed below and run the server from "run & debug" menu
After all steps, test your widget in browser http://0.0.0.0:8000 and if it ok make a commit & push & create the pull request in both repo(SDK and ui-widget-demos).
Send the link to pull-request to Maxim Kolomeychenko(@Max) in Slack. He will run a new SDK build.
Success!
supervisely/app/widgets/textarea/textarea.py
supervisely/app/widgets/textarea/template.html
supervisely/app/widgets/__init__.py
NEW widgets/textarea/src/main.py