fastTemplates

Hi,

I’ve tried the new fast templates with the release of 0.11. Like the other templates I was able to pre-set to one theme or the other, but flipping with the button in the top menu doesn’t work for myself it just stays on the same theme so makes me think I may need to add something to make this work that I’m not seeing in the example?

The only other thing that I noticed when I applied side bar footer it didn’t apply to the foot, it applied directly under the settings widgets at the top. Is there a way to force this to the foot of the page or will it append after last item naturally?

1 Like

You can try to delete the cache of the browser.

https://support.google.com/accounts/answer/32050?co=GENIE.Platform%3DDesktop&hl=en

If you update panel an old css stylesheet is saved in your browser.

Hi Carl

Regarding the switch it should work. Try to clear the cache.

Regarding the side bar footer. Could you be more specific and provide some minimal, reproducible example of what you are trying to do?

Thanks.

Hi @nghenzi, @Marc

Thanks for the advice, so I’ve given the cache a clear and tried couple of browsers, however all with same effect described - the button doesn’t do it’s thing for me. I created a clean environment with conda so maybe something went wrong - the error in the browser suggests I’ve loaded dev-tools likely not my intention… I’ll reload everything as a second this morning. That said here is a snippet of the error and video of what I’m experiencing.

I run this in JupyterLab with a connected ipykernel from a conda virtual session there’s no reason for this other than the path I lead myself down when I started exploring python.

As for the footer I just expected it to appear at the foot of the side bar if I append normal text but seeing I’ve got issues I’ll come back to it once iron out where I’ve gone wrong.

import numpy as np
import panel as pn
from panel.template import DarkTheme
import holoviews as hv

template = pn.template.FastGridTemplate(title='FastGridTemplate',sidebar_footer="hello I'm the footer",theme=DarkTheme)

pn.config.sizing_mode = 'stretch_width'

xs = np.linspace(0, np.pi)
freq = pn.widgets.FloatSlider(name="Frequency", start=0, end=10, value=2)
phase = pn.widgets.FloatSlider(name="Phase", start=0, end=np.pi)

files = pn.widgets.FileSelector('~')

@pn.depends(freq=freq, phase=phase)
def sine(freq, phase):
    return hv.Curve((xs, np.sin(xs*freq+phase))).opts(
        responsive=True, min_height=400, title="Sine")

@pn.depends(freq=freq, phase=phase)
def cosine(freq, phase):
    return hv.Curve((xs, np.cos(xs*freq+phase))).opts(
        responsive=True, min_height=400, title="Cosine")

#dashboard side
template.sidebar.append(pn.pane.Markdown("## Settings"))
template.sidebar.append(freq)
template.sidebar.append(phase)

#dashboard focal
template.main[:3, :6] = hv.DynamicMap(sine)
template.main[:3, 6:] = hv.DynamicMap(cosine)

template.show();

catpure2

I’ve reloaded everything with same result as before, though I noted on recreation of the environment conda is keeping the same packages I originally downloaded and using them to install rather than grabbing new from online. Once I figure out how to completely flush and install a fresh I’ll report back if everything starts working for me.

Some time ago I had a similar issue with the conda environments and the ipykernel (in jupyter notebook). I changed of environment but the panel packages were loaded from the same location. I had to install ipykernel each time I switched of environment with

python -m ipykernel install --user

I had to reinstall anaconda, and it works normally now.

So… I ran a clean install and I hit same issue and maybe it’s because I didn’t read the notes properly so this line I took as works with .show()

The app can be displayed within the notebook by using .servable() , or rendered in another tab by replacing it with .show()

I didn’t read to the bottom properly which says and I assume that means for .show() launching from the notebook? I think I might of assumed if you tried to inline display it in the notebook it wouldn’t work right rather than render to new tab.

this template currently does not render correctly in a notebook ,

My findings and I guess my bad, it works when I run .servable() and then invoke the command line to launch server, if I use .show() as I did above which I used for convenience from the notebook it all kind of works just not the button theme switching part.

In short

  • theme switching issue with .show() from notebook
  • theme switching works if run .servable() then open command prompt & run panel serve file.ipynb
1 Like

For the technically interested Theme switching works by using the url arguments. So they are either not set, set to theme=default, theme=dark.

When you launch using .show from notebook the web app gets the url arguments from the notebook (and they don’t change). When you click the switch button it changes the url arguments in the web app. But the theme shown is determined from the url arguments of the notebook unfortunately.

Maybe a different implementation than the default could change this.

1 Like