How do I create a custom computation/ filter that supports same execution options as {python} filter #8049
Replies: 3 comments 5 replies
-
I am not sure to follow why you want to define a new Jupyter engine kernel (see online resources about that since it's independent of Quarto). If you want to add a class to easily target, use ```{python}
#| echo: true
#| classes: panel-convert-python
import panel as pn
pn.extension(design="material")
slider = pn.widgets.IntSlider(name="Select a value", value=10, start=0, end=100)
pn.Column(
pn.rx("You selected: {}").format(slider),
).servable()
``` Also, I don't understand your goal here. ---
title: "Quarto Playground"
format: html
embed-resources: true
---
This is a playground for Quarto.
```{python}
#| echo: true
import panel as pn
pn.extension(design="material")
slider = pn.widgets.IntSlider(name="Select a value", value=10, start=0, end=100)
pn.Column(pn.rx("You selected: {}").format(slider),).servable()
```
```{python}
# Import necessary libraries
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')
# Create some data
data = {
'x': [1, 2, 3, 4, 5],
'y': [5, 6, 7, 8, 9]
}
# Create a scatter plot
scatter = hv.Scatter(data, 'x', 'y')
# Set some options
scatter.opts(opts.Scatter(width=700, size=10, color='red'))
# Display the plot
scatter
``` |
Beta Was this translation helpful? Give feedback.
-
Thanks for the questions. I don't think I need to define a new kernel. Because with Pyscript, Pyodide and Panel the rendering can take place when the user opens the document. And the output will be live and interactive. What I want is to take a code block as input and output the code nicely styled on top and some custom html output below. I would like to be able to control this using the exact same execution options as the The goal is to get live, interactive output powered by PyScript, Pyodide and/ or Panel. Not static output created by Jupyter. The examples below have the output rendered by PyScript/ Panel instead of Jupyter. PyScriptLink: https://awesome-panel.github.io/holoviz-quarto/example-pyscript.html In this example I am able to render using pyscript instead of Jupyter. <div id="out-1" class="lds-dual-ring pn-container"></div>
<script type="py">
import panel as pn
slider = pn.widgets.IntSlider(name="Select a value", value=10, start=0, end=100)
pn.Column(
pn.rx("You selected: {}").format(slider),
).servable(target="out-1")
</script> I just want to be able to write this as a nice code block with a custom ```{pyscript-python}
import panel as pn
slider = pn.widgets.IntSlider(name="Select a value", value=10, start=0, end=100)
pn.Column(
pn.rx("You selected: {}").format(slider),
)
``` I want this filter to have the same execution options as the I try to explain this in the video below. explanation.mp4Panel ConvertLink: https://awesome-panel.github.io/holoviz-quarto/example-panel-convert-python.html Here I have created a custom filter |
Beta Was this translation helpful? Give feedback.
-
@MarcSkovMadsen cool use case! I've been playing around recently with a direct Pyodide implementation that doesn't have sliders/widgets; but, exists off a single pyodide thread/download without the iframe encapsulation. With the proposed That said, the approach taken by the two quarto extensions mentioned by @mcanouil handle option processing in slightly different ways:
So, you can likely get the
I know the above is not ideal; but hopefully, that can help you out while we await for 1.5 release (sometime in 2024) |
Beta Was this translation helpful? Give feedback.
-
Description
Hi. I'm trying to make it super simple to use the HoloViz ecosystem with Quarto. See https://github.com/awesome-panel/holoviz-quarto.
Instead of using the
{python}
filter I would like to provide some custom filters. I want them to work in the same way as the{python} filter
, i.e. taking the same execution options. I would like to be able to useecho
,code-fold
etc. options.For example something like
Currently I can only get the rendered output
I will use Python to create the raw html output
I've tried to figure out how I can most easily do this, inheriting as much existing functionality as possible. But I've not been able to find this in the official docs or looking on github. I need help.
How do I create something like this?
Beta Was this translation helpful? Give feedback.
All reactions