Hello World!
Create simple supervisely app with GUI
Introduction
In this tutorial you will learn how to create Supervisely apps with GUI on pure python using Supervisely app engine and widgets. We will create a simple "Hello, World!" app that will generate names using Text
and Button
widgets.
main.py
is just 26 lines of code.
Requirements
Install latest supervisely
version to have access to all available widgets and names
library for names generation
How to debug this tutorial
Step 1. Prepare ~/supervisely.env
file with credentials. Learn more here.
Step 2. Clone repository with source code.
Step 3 Open repository directory in Visual Studio Code.
Step 4 Create Virtual Environment
Step 5. Open the .vscode/launch.json
file in the project and specify the path to your script in launching configuration arguments.
Step 6. Start debugging hello_world/src/main.py
:
Go to
Run and Debug
section(Ctrl+Shift+D)
.Select configuration name
Uvicorn
that you specified inlaunch.json
from configuration dropdown.Press green play button or
F5
to start debugging.
Hello, World! app
Import libraries
Init API client
Init API for communicating with Supervisely instance. First, we load environment variables with credentials:
Initialize Text
and Button
widgets.
Text
and Button
widgets.Create app layout
Prepare a layout for app using Card
widget with the content
parameter and place 2 widgets that we've just created in the Container
widget. Place order in the Container
is also important, we want the "hello text" to be above the name generation button.
Create app using layout
Create an app object with layout parameter.
Handle button clicks
Use the decorator as shown below to handle button click. When we change hello_msg.text
value, data will be pushed to web browser via web sockets.
Last updated