Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expressify shiny widgets #99

Merged
merged 7 commits into from
Jan 29, 2024
Merged

Expressify shiny widgets #99

merged 7 commits into from
Jan 29, 2024

Conversation

gshotwell
Copy link
Contributor

I mostly included the apps from the new ipywidget docs. One bit that might need a callout is the render.express example. I wanted something which returned a context manager, and iterator, and a rendering function, and to do that I needed to be explicit aobut the output. This is basically a module workaround, but I think it's a pretty good example of what render.expresscan do.

from shiny import render
from shiny.express import ui, input, output
import numpy as np
import matplotlib.pyplot as plt


ui.input_slider("n", "Number of cards", value=3, min=1, max=5)


@render.express
def cards():
    with ui.layout_columns():
        for i in range(input.n()):
            with ui.card():
                f"Card {i}"

                @output(id=f"hist_{i}")
                @render.plot(alt="A histogram")
                def histogram():
                    np.random.seed(19680801)
                    x = 100 + 15 * np.random.randn(437)
                    plt.hist(x, 20, density=True)

@gshotwell gshotwell changed the base branch from main to rc-express January 23, 2024 15:06
examples/python/output_ui/app.py Outdated Show resolved Hide resolved
@wch wch merged commit 590fe6d into rc-express Jan 29, 2024
@wch wch deleted the expressify-shiny-widgets branch January 29, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants