-
Notifications
You must be signed in to change notification settings - Fork 21
Overhaul "Learn Shiny" content to be Express focused #68
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
169d0a5
wip overhaul learn shiny
cpsievert bdec2e4
Add Shiny Core motivation draft
ea77420
Incorporate latest shinywidgets stuff
cpsievert 8fbff93
import render from express more consistently
cpsievert f06053b
Fix links; address some feedback
cpsievert 58c4458
More feedback
cpsievert 1e18467
Refine/add to express motivation
cpsievert 8b627ec
Address feedback
cpsievert 33d50d2
Merge branch 'rc-express' into learn-shiny-overhaul
cpsievert df3d645
Address feedback on Express vs Core
cpsievert 69b7deb
Fix some links that have changed; update Jupyter Widgets to include v…
cpsievert d23a9d0
Adopt/tweak banner
cpsievert 173db6a
Make .panel-underline a sitewide feature
cpsievert 4d16b0b
Use more official shinylive link mechanism
cpsievert 1f33e71
Do a half-baked update to api/index.qmd (this should get more attenti…
cpsievert d62e8cd
Merge branch 'rc-express' into learn-shiny-overhaul
cpsievert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,51 @@ | ||
| # API Reference Intro | ||
|
|
||
| This website documents the public API of Shiny for Python. See the [Getting Started tutorial](/docs/get-started.qmd) for a more approachable introduction to the API. | ||
| The left-hand sidebar gives quick access to the full public API, and the table of contents below shows the same entries plus a brief summary for each. | ||
| Most of the reference pages include a live example app at the bottom, or at least mention another page with a relevant example. | ||
| This page details the Shiny's full API. | ||
| New users are encouraged to start from the [Quick Start tutorial](../docs/quick-start.qmd), and then come back here when you're ready to learn more. | ||
| We recommend newcomers start with [Shiny Express](../docs/express-introduction.qmd) instead of the more structured Shiny Core API. | ||
|
|
||
| We've intentionally designed Shiny's API so that you can `from shiny import *` to get access to most of what you need for most apps without introducing an excessive amount of namespace pollution. | ||
| Namely, it gives you: | ||
| ::: {.panel-tabset .panel-underline .border-0 .p-0 .justify-content-center} | ||
|
|
||
| * User interface (UI/HTML) helpers, available via the `ui` subpackage. | ||
| ### Express | ||
|
|
||
| * To avoid clashing with this `ui` namespace when you do `from shiny import *`, you'll want to name you UI object something else, like `app_ui`. | ||
| ```{shinylive-python} | ||
| #| standalone: true | ||
| #| components: [editor, viewer] | ||
| #| layout: vertical | ||
| #| viewerHeight: 150 | ||
|
|
||
| * Reactive programming utilities, available via the `reactive` subpackage. | ||
| * Decorators for rendering `output`, available via the `render` subpackage. | ||
| from shiny.express import input, render, ui | ||
|
|
||
| * 3rd party packages that want to implement their own rendering functions are encouraged to use a `@render_foo()` naming convention so users may import with `from mypkg import render_foo`. | ||
| ui.input_slider("val", "Slider label", min=0, max=100, value=50) | ||
|
|
||
| * A handful of other things you'll want for most apps (e.g., `App`, `Module`, etc). | ||
| * If you're using type checking, you'll also want to use the `Inputs`, `Outputs`, and `Session` Classes | ||
| to type the instances supplied to your server function, for example: | ||
| @render.text | ||
| def slider_val(): | ||
| return f"Slider value: {input.val()}" | ||
| ``` | ||
|
|
||
| ### Core | ||
|
|
||
| ```{shinylive-python} | ||
| #| standalone: true | ||
| #| components: [editor, viewer] | ||
| #| layout: vertical | ||
| #| viewerHeight: 400 | ||
| ## file: app.py | ||
| from shiny import * | ||
| #| viewerHeight: 150 | ||
|
|
||
| from shiny import App, render, ui | ||
|
|
||
| app_ui = ui.page_fluid( | ||
| ui.input_slider("n", "Value of n", min=1, max=10, value=5), | ||
| ui.output_text("n2") | ||
| app_ui = ui.page_fixed( | ||
| ui.input_slider("val", "Slider label", min=0, max=100, value=50), | ||
| ui.output_text_verbatim("slider_val") | ||
| ) | ||
|
|
||
| def server(input: Inputs, output: Outputs, session: Session) -> None: | ||
| @output | ||
| def server(input, output, session): | ||
| @render.text | ||
| def n2(): | ||
| return f"The value of n*2 is {input.n() * 2}" | ||
| def slider_val(): | ||
| return f"Slider value: {input.val()}" | ||
|
|
||
| app = App(app_ui, server) | ||
| ``` | ||
|
|
||
| ::: | ||
|
|
||
| {{< include _api_index.qmd >}} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.