Development
Wave apps and scripts are plain Python programs. You can develop, debug and test them from the command-line, from the Python REPL, or from your favorite text editor.
Both PyCharm Community Edition and Visual Studio Code are excellent for Python programming.
tip
At the time of writing, PyCharm's type-checking and error-detection is superior to Visual Studio Code's Python plugin.
Getting started
The simplest way to get started in either PyCharm or Visual Studio Code is the same:
- Create a working directory.
- Set up a Python virtual environment.
- Install the
h2o-wave
package. - Open the directory in your IDE.
mkdir $HOME/wave-apps
cd $HOME/wave-apps
python3 -m venv venv
./venv/bin/pip install h2o-wave
Using PyCharm
- Launch PyCharm
- Click "File" -> "Open...", then choose
$HOME/wave-apps
. - Right-click on
wave-apps
in the "Project" tree, then click "New" -> "Python File". - Enter a file name, say,
hello_world.py
. - Write some code (see sample below).
- Right-click anywhere inside the file and choose "Run hello_world" or "Debug hello_world".
Using Visual Studio Code
- Launch Visual Studio Code
- Click "File" -> "Open...", then choose
$HOME/wave-apps
. - Click "File" -> "New File"; save the file as, say,
hello_world.py
. - You should now get a prompt asking if you want to install extensions for Python. Click "Install".
- Write some code (see sample below).
- Hit
Ctrl+F5
to run, orF5
to debug.
A hello world sample
$HOME/wave-apps/hello_world.py
from h2o_wave import site, ui
# Grab a reference to the page at route '/hello'
page = site['/hello']
# Add a markdown card to the page.
page['quote'] = ui.markdown_card(
box='1 1 2 2',
title='Hello World',
content='"The Internet? Is that thing still around?" - *Homer Simpson*',
)
# Finally, save the page.
page.save()