Skip to content

Instantly share code, notes, and snippets.

@MarcSkovMadsen
Last active August 24, 2022 15:42
Show Gist options
  • Save MarcSkovMadsen/0c6cf1ee264eadfe4057c406fe742c42 to your computer and use it in GitHub Desktop.
Save MarcSkovMadsen/0c6cf1ee264eadfe4057c406fe742c42 to your computer and use it in GitHub Desktop.
FastGridTemplate Walk Through
import holoviews as hv
import numpy as np
import panel as pn
pn.extension(sizing_mode="stretch_width")
ACCENT_COLOR = "#37718e" # "#DF3874"
XS = np.linspace(0, np.pi)
def sine(freq, phase):
return hv.Curve((XS, np.sin(XS * freq + phase))).opts(
responsive=True, min_height=400, title="Sine", color=ACCENT_COLOR
)
def cosine(freq, phase):
return hv.Curve((XS, np.cos(XS * freq + phase))).opts(
responsive=True, min_height=400, title="Cosine", color=ACCENT_COLOR
)
freq = pn.widgets.FloatSlider(name="Frequency", start=0, end=10, value=2)
phase = pn.widgets.FloatSlider(name="Phase", start=0, end=np.pi)
sine = pn.bind(sine, freq=freq, phase=phase)
cosine = pn.bind(cosine, freq=freq, phase=phase)
template = pn.template.FastGridTemplate(
site="Awesome Panel",
site_url="https://awesome-panel.org",
title="FastGridTemplate",
# logo="https://panel.holoviz.org/_static/logo_horizontal.png",
# favicon="https://www.python.org/static/favicon.ico"
# sidebar_footer="<br/><span>Made with Panel</span>",
# busy_indicator=pn.indicators.BooleanStatus(color="dark"),
# cols={'lg': 12, 'md': 12, 'sm': 12, 'xs': 12, 'xxs': 12},
# row_height=200,
# dimensions={'minW': 0, 'maxW': 'Infinity', 'minH': 0, 'maxH': 4},
prevent_collision=True,
save_layout=True,
# theme="dark",
# theme_toggle=False,
# background_color="#e5eeda",
# neutral_color=ACCENT_COLOR,
accent_base_color=ACCENT_COLOR,
header_background="#37718e",
header_color="lightgray",
header_neutral_color="#5f9eb8",
header_accent_base_color="white",
corner_radius=15,
font="COMIC SANS MS",
shadow=False,
# main_layout="",
# sidebar_width=1000,
# main_max_width="75%",
meta_description="All about awesome analytics apps in Python",
# meta_refresh="2"
)
template.sidebar[:]=["## Settings", freq, phase, pn.widgets.Button(name="Click Me!", button_type="primary")]
template.main[:1, :] = "## 🍺 Probably the most powerful datascience app template in the world!\n🐍 Use it with all the Python tools you already know and love"
template.main[1:4, :6] = pn.pane.HoloViews(hv.DynamicMap(sine), sizing_mode="stretch_both")
template.main[1:4, 6:] = pn.pane.HoloViews(hv.DynamicMap(cosine), sizing_mode="stretch_both")
template.servable()
@MarcSkovMadsen
Copy link
Author

This gist supports the FastGridTemplate walk trough.

It's based on Panel 0.12.0 with some bug fixes that will released ASAP with Panel 0.12.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment