Skip to content

Commit d630045

Browse files
committed
reflow document through quarto visual editor
1 parent 8345d4f commit d630045

File tree

1 file changed

+57
-88
lines changed

1 file changed

+57
-88
lines changed

tutorials/intro-express/1-welcome.qmd

+57-88
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,28 @@
22
title: Getting Started
33
---
44

5-
Shiny for Python is a web application framework that helps tell your
6-
data story.
7-
If you've landed on this page,
8-
you probably have a bit of Python experience,
9-
worked with data,
10-
and now need a way to publish an interactive
11-
web application to help tell your data story.
5+
Shiny for Python is a web application framework that helps tell your data story.
6+
If you've landed on this page, you probably have a bit of Python experience, worked with data, and now need a way to publish an interactive web application to help tell your data story.
127

138
## Installation and Setup
149

15-
This is a 1 to 2 Hour tutorial to get you started and familiar with all the basic
16-
parts of creating and deploying a Shiny for Python application.
17-
Before starting this tutorial,
18-
check to make sure you have your packages and environment
19-
setup.
20-
You can see the
21-
[Installation section of the Get Started Guides](/get-started/install-create-run.qmd).
10+
This is a 1 to 2 Hour tutorial to get you started and familiar with all the basic parts of creating and deploying a Shiny for Python application.
11+
Before starting this tutorial, check to make sure you have your packages and environment setup.
12+
You can see the [Installation section of the Get Started Guides](/get-started/install-create-run.qmd).
2213

2314
## Parts of a Shiny Application
2415

2516
Shiny express allows us to write shiny apps with a minimal amount of code.
26-
This lets us rapidly link interactive components with our data
27-
in our web application.
17+
This lets us rapidly link interactive components with our data in our web application.
2818

2919
There are 3 main parts of a shiny express application
3020

31-
1. [input components](/components/#inputs):
32-
provide user interactions that can be used as inputs in other parts of the web application.
33-
2. [output components](/components/#outputs):
34-
results that are displayed on the web application.
35-
3. [layout and ui components](/layouts):
36-
how and where the inputs and output of the web application are displayed.
21+
1. [input components](/components/#inputs): provide user interactions that can be used as inputs in other parts of the web application.
22+
2. [output components](/components/#outputs): results that are displayed on the web application.
23+
3. [layout and ui components](/layouts): how and where the inputs and output of the web application are displayed.
3724

3825
The example below demonstrates the basic mechanics behind Shiny apps.
39-
As you move the slider (an input component),
40-
the text (output component) will react and update to the corresponding input value.
26+
As you move the slider (an input component), the text (output component) will react and update to the corresponding input value.
4127

4228
```{shinylive-python}
4329
#| standalone: true
@@ -55,33 +41,32 @@ def slider_val():
5541

5642
Let's briefly break down the components of the application above:
5743

58-
- Inputs
59-
- Create a slider with a `ui.input_*` function.
60-
- Here we are using the `ui.input_slider()` function to create the slider.
61-
- This slider has an id of `"val"` which is used to get the slider value later
62-
- Outputs
63-
- Created by decorating a function with the corresponding `@render.*` decorator.
64-
- Here we are displaying text, so we are using the `@render.text` decorator.
65-
- Inside a `render` function, `input` values can be read [reactively](#reactivity).
66-
- We read the value from the slider by calling `input.val()`.
67-
- When those `input` values change, Shiny knows how to minimally re-render output.
68-
- Layouts
69-
- Inferred automatically based on what items you place in your application.
70-
- We will learn more about layouts and user interfaces in the next lesson of this tutorial.
71-
72-
::: {.callout-note}
44+
- Inputs
45+
- Create a slider with a `ui.input_*` function.
46+
- Here we are using the `ui.input_slider()` function to create the slider.
47+
- This slider has an id of `"val"` which is used to get the slider value later
48+
- Outputs
49+
- Created by decorating a function with the corresponding `@render.*` decorator.
50+
- Here we are displaying text, so we are using the `@render.text` decorator.
51+
- Inside a `render` function, `input` values can be read [reactively](#reactivity).
52+
- We read the value from the slider by calling `input.val()`.
53+
- When those `input` values change, Shiny knows how to minimally re-render output.
54+
- Layouts
55+
- Inferred automatically based on what items you place in your application.
56+
- We will learn more about layouts and user interfaces in the next lesson of this tutorial.
57+
58+
:::: callout-note
7359
## Exercise
7460

7561
Let's make and run our first shiny for python application.
7662

77-
1. Take the above code and save it to a file. Here we named it `app.py`
78-
2. Click on the play button (red circle in the image below)j
63+
1. Take the above code and save it to a file. Here we named it `app.py`
64+
2. Click on the play button (red circle in the image below)j
7965

8066
You will see the terminal run the `shiny run` command for you automatically.
8167
The output will look something like this
8268

83-
84-
```bash
69+
``` bash
8570
$ python -m shiny run --port 55901 --reload --autoreload-port 55902 app-010-simple.py
8671
INFO: Will watch for changes in these directories: ['~/Desktop/py-shiny-example']
8772
INFO: Uvicorn running on http://127.0.0.1:55901 (Press CTRL+C to quit)
@@ -92,82 +77,66 @@ INFO: Application startup complete.
9277
INFO: 127.0.0.1:56426 - "GET /?vscodeBrowserReqId=1737097751843 HTTP/1.1" 200 OK
9378
```
9479
95-
This will run the application on port `55901` and automatically reload and update
96-
as you make changes to the `app.py` file.
80+
This will run the application on port `55901` and automatically reload and update as you make changes to the `app.py` file.
9781
98-
1. You will see the app build in the bottom terminal and open in the viewer on the side
99-
2. Move the slider and see how the output reacts
100-
3. Congratulations, you made your first shiny for python application!
82+
1. You will see the app build in the bottom terminal and open in the viewer on the side
83+
2. Move the slider and see how the output reacts
84+
3. Congratulations, you made your first shiny for python application!
10185
102-
::: {.column-margin}
86+
::: column-margin
10387
![](img/010-run_app.png)
10488
:::
89+
::::
10590
106-
:::
107-
108-
::: {.callout-tip}
91+
::: callout-tip
10992
## Naming your files
11093
111-
If you start your file with the word `app`,
112-
the shiny for python extension will recognize
113-
it as an application and you will be able to see the "play" button to run your application.
114-
You can also name your file `app-get_started.py`
115-
and you will still get the shiny extension play button.
94+
If you start your file with the word `app`, the shiny for python extension will recognize it as an application and you will be able to see the "play" button to run your application.
95+
You can also name your file `app-get_started.py` and you will still get the shiny extension play button.
11696
117-
To have Shiny for Python work well with the VS Code extensions and for you to go through
118-
the next series of lessons.
97+
To have Shiny for Python work well with the VS Code extensions and for you to go through the next series of lessons.
11998
We recommend either one of the following file naming conventions:
12099
121-
1. Create separate folders for each app example you will create and save separate `app.py` files in each folder
122-
2. Create separate `app*.py` files in the same directory (e.g., `app-01.py`, `app-02.py`)
100+
1. Create separate folders for each app example you will create and save separate `app.py` files in each folder
101+
2. Create separate `app*.py` files in the same directory (e.g., `app-01.py`, `app-02.py`)
123102
124103
If you named your application `app.py` you can omit it form the command and only use `shiny run --reload`.
125104
The `app.py` is the default file Shiny looks for to run in the current directory.
126105
Otherwise, you can pass in the name of the file that you wish to run.
127-
The `app` prefix used in the example above is used to signal to the Shiny VS Code extension
128-
to display the run app button.
106+
The `app` prefix used in the example above is used to signal to the Shiny VS Code extension to display the run app button.
129107
:::
130108
131109
## Run your shiny application
132110
133-
In addition to the play button in Positron, you can manually run your application from
134-
the command line.
135-
This is useful if you wish to specify your own port or want to rename your application
136-
without the `app` prefix.
111+
In addition to the play button in Positron, you can manually run your application from the command line.
112+
This is useful if you wish to specify your own port or want to rename your application without the `app` prefix.
137113
138-
```bash
139-
shiny run my_app.py --reload --port 8000
114+
``` bash
115+
shiny run my_app.py --reload
140116
```
141117
142-
:::{.callout-tip}
118+
::: callout-tip
143119
## Helpful run options
144120
145121
Some useful options you can pass the `shiny run` command are:
146122
147-
- `--reload`: Enables auto-reload, the application will reload to reflect your changes as you save your work.
148-
- `--port`: pass in a custom port, e.g., `--port 8000`.
149-
This will run the app on the specified port,
150-
instead of a random port.
151-
This makes it easier to have the same browser window open as you stop and start your application.
123+
- `--reload`: Enables auto-reload, the application will reload to reflect your changes as you save your work.
124+
- `--port`: pass in a custom port, e.g., `--port 8000`. This will run the app on the specified port, instead of a random port. This makes it easier to have the same browser window open as you stop and start your application.
152125
153-
You can learn more about these run options on the
154-
[`run_app` documentation page](https://shiny.posit.co/py/api/core/run_app.html).
126+
You can learn more about these run options on the [`run_app` documentation page](https://shiny.posit.co/py/api/core/run_app.html).
155127
:::
156128
157129
## Shiny Express: Your first application
158130
159-
The rest of this tutorial will work on creating this
160-
[Restaurant Tipping Dashboard](https://gallery.shinyapps.io/template-dashboard-tips1/).
131+
The rest of this tutorial will work on creating this [Restaurant Tipping Dashboard](https://gallery.shinyapps.io/template-dashboard-tips1/).
161132
162-
::::: {.column-screen .hero-image .pt-4 .pb-5 style="margin-top:0px;max-width:1600px;"}
133+
:::: {.column-screen .hero-image .pt-4 .pb-5 style="margin-top:0px;max-width:1600px;"}
163134
::: {.hello-output .g-col-12 .g-col-xl-12}
164-
<iframe
165-
src="https://gallery.shinyapps.io/template-dashboard-tips1/"
166-
frameborder="0"
167-
width="100%"
168-
class="mb-0 card hello-output-iframe"
169-
></iframe>
135+
<iframe src="https://gallery.shinyapps.io/template-dashboard-tips1/" frameborder="0" width="100%" class="mb-0 card hello-output-iframe">
170136
137+
</iframe>
138+
139+
```{=html}
171140
<style>
172141
.hello-output-iframe {
173142
height: 900px;
@@ -178,6 +147,6 @@ The rest of this tutorial will work on creating this
178147
}
179148
}
180149
</style>
150+
```
181151
:::
182-
183-
:::::
152+
::::

0 commit comments

Comments
 (0)