Skip to content

Instantly share code, notes, and snippets.

@mtanco
Created March 26, 2021 17:27
Show Gist options
  • Save mtanco/4b39b58a75a886e9786325b3300be342 to your computer and use it in GitHub Desktop.
Save mtanco/4b39b58a75a886e9786325b3300be342 to your computer and use it in GitHub Desktop.
This example script explores how to display stat cards nicely on a layout
from h2o_wave import main, site, Q, ui
def create_stat_card(name: str, n: int):
page[name] = ui.tall_gauge_stat_card(
box=ui.box(zone='body', width='200px', height='200px'),
title='test '*n,
value=str(n),
aux_value=str(n*100),
progress=n*0.1,
plot_color='purple',
data=None,
commands=None
)
page = site['/']
page['meta'] = ui.meta_card(
box='',
title='Stat Gauges',
layouts=[
ui.layout(
breakpoint='xl',
width='1200px',
zones=[
ui.zone(
name='body', # use this for all tall_gauge_stat_cards
direction='row', # place cards as rows or columns
wrap='start', # wrap overflow to next line
),
]
)
]
)
for i in range(14):
create_stat_card(f'card_{i}', i)
page.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment