Skip to content

Instantly share code, notes, and snippets.

@mtanco
mtanco / testing_handlers_and_args.py
Created March 25, 2021 20:49
This is a simple app for understanding the behavior of `handle_on` and when `q.arg` dictionary is cleared.
from h2o_wave import main, app, Q, ui, on, handle_on
@app('/')
async def serve(q: Q):
if not q.client.initialized: # first time a tab comes this is app
q.page['a'] = ui.form_card(
box='4 3 4 2',
items=[
ui.textbox(name='color_textbox', placeholder='Purple'),
@mtanco
mtanco / wave_started_app.py
Created March 19, 2021 17:52
Starter code I have been using for most new apps
from h2o_wave import main, app, Q, ui, handle_on, on, data
from loguru import logger
def on_startup():
"""
Runs when the app is started, even if there are no browsers connected
:return:
"""
logger.info('http://localhost:10101/')
@mtanco
mtanco / wave_use_uploaded_data.py
Last active February 26, 2021 04:15
wave_use_uploaded_data
import os
import time
from h2o_wave import main, app, Q, ui, data
import pandas as pd
import numpy as np
@app('/')
async def serve(q: Q):
print(q.args)
@mtanco
mtanco / wave_plot_from_pandas.py
Created December 20, 2020 18:31
Example of how to format a pandas dataframe for plotting with native Wave plot functions
# Plot / Dataframe
# Examples of how to format pandas data when plotting
# Use the `tolist()` function on `df.columns` and `df.values` along with Wave's `data` class
# ---
from h2o_wave import site, data, ui, main
import pandas as pd
import numpy as np
# Page to hold our charts
page = site['/demo']