You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/08-MultiPageDashApp.md
+28-25
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
2
2
> ## Status: Multi-Page Dash App Plugin
3
-
> #### Under active development: A plugin to simplify creating multi-page Dash apps. This is a preview of functionality that will be added to Dash 2.x.
3
+
> #### The `pages` functionality is now part of dash 2.5! These docs remain here for legacy purposes. `pages` is a plugin to simplify creating multi-page Dash apps.
4
4
> **[See the community announcement for details and discussion](https://community.plotly.com/t/introducing-dash-pages-dash-2-1-feature-preview/57775)**
5
5
6
6
@@ -80,18 +80,19 @@ if __name__ == "__main__":
80
80
81
81
4. Create a folder called `pages/` and place your app layouts in files within that folder. Each file needs to:
82
82
- Define `layout`. This can be a variable or function that returns a component
83
-
- Call `dash.register_page(__name__)` to tell `dl.plugins.pages` that this page should be part of the multi-page framework
83
+
- Call `dl.plugins.register_page(__name__)` to tell `dl.plugins.pages` that this page should be part of the multi-page framework
from dash import Dash, dcc, html, Input, Output, callback
93
93
import plotly.express as px
94
94
95
+
register_page(__name__, path="/")
95
96
df = px.data.medals_wide(indexed=True)
96
97
97
98
layout = html.Div(
@@ -115,8 +116,8 @@ def filter_heatmap(cols):
115
116
```
116
117
117
118
The `dash.page_registry` is an `OrderedDict` with keys being the page's module name (e.g. `pages.bar-charts`) and values being a dictionary containing keys `path`, `name`, `order`, `title`, `description`, `image`, and `layout`.
118
-
As you saw in the above example, This `page_registry` is populated from calling `dash.register_page` within `pages/`.
119
-
`dash.register_page` will accept various arguments to customize aspects about the page. See the Advanced Features section below.
119
+
As you saw in the above example, This `page_registry` is populated from calling `register_page` within `pages/`.
120
+
`register_page` will accept various arguments to customize aspects about the page. See the Advanced Features section below.
@@ -133,16 +134,16 @@ These features are all optional. If you don't supply values here, the framework
133
134
134
135
The page's title defines what you see in your browser tab and what would appear as the website's title in search results. By default, it is derived from the filename but it can also be set with `title=`
Similarly, the meta description can be set with `description=` and the meta image can be set with `image=`. Both of these tags are used as the preview when sharing a URL in a social media platforms. They're also used in search engine results.
140
141
141
142
By default, Dash will look through your `assets/` folder for an image that matches the page's filename or else an image called `app.<image_extension>` (e.g. `app.png` or `app.jpeg`) or `logo.<image_extension>` (all image extensions are supported).
142
143
143
-
This image URL can also be set directly with `app.register_page(image=...)` e.g.
144
+
This image URL can also be set directly with `dl.plugins.register_page(image=...)` e.g.
@@ -196,7 +197,7 @@ OrderedDict values can be accessed just like regular dictionaries:
196
197
197
198
The order of the items in `page_registry` is based off of the optional `order=` parameter:
198
199
```python
199
-
dash.register_page(__name__, order=10)
200
+
dl.plugins.register_page(__name__, order=10)
200
201
```
201
202
202
203
If it's not supplied, then the order is alphanumeric based off of the filename. This order is important when rendering the page menu's dynamically in a loop. The page with the path `/` has `order=0` by default.
@@ -208,7 +209,7 @@ Redirects can be set with the `redirect_from=[...]` parameter in `register_page`
Another way to pass variables to the layout is to use the `path_template` parameter in `dash.register_page`. You can
271
+
Another way to pass variables to the layout is to use the `path_template` parameter in `register_page`. You can
270
272
define which segments of the path are variables by marking them like this: `<variable_name>`. The layout function then receives the `<variable_name>` as a keyword argument.
271
273
272
274
@@ -275,16 +277,17 @@ will receive `**{"asset_id": "a100"}`. Here is an example with two variables in
Copy file name to clipboardExpand all lines: docs/09-MultiPageDashApp-NestedFolders.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
2
2
> ## Status: Multi-Page Dash App Plugin
3
-
> #### Under active development: A plugin to simplify creating multi-page Dash apps. This is a preview of functionality that will be added to Dash 2.x.
3
+
> #### The `pages` functionality is now part of dash 2.5! These docs remain here for legacy purposes. `pages` is a plugin to simplify creating multi-page Dash apps.
4
4
> **[See the community announcement for details and discussion](https://community.plotly.com/t/introducing-dash-pages-dash-2-1-feature-preview/57775)**
5
5
6
6
@@ -12,7 +12,7 @@
12
12
If you would like to add an example, feel free to create a pull request!
13
13
14
14
### Example: Nested Folders
15
-
This example shows how `dash.register_page` handles
15
+
This example shows how `dl.plugins.register_page` handles
16
16
- Using Nested folders in `pages/`
17
17
- Storing icons as arbitrary keyword arguments
18
18
@@ -126,14 +126,14 @@ if __name__ == "__main__":
126
126
127
127
```
128
128
129
-
Recall from the previous chapter that `dash.register_page` also accepts arbitrary keyword arguments. We use this
129
+
Recall from the previous chapter that `dl.plugins.register_page` also accepts arbitrary keyword arguments. We use this
130
130
feature to store the icon used in the nav for each page.
131
131
132
132
Here is how we store the FontAwesome icon for `pages/chapter/pie-chart.py`
Copy file name to clipboardExpand all lines: docs/10-MultiPageDashApp-MetaTags.md
+9-7
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
2
+
2
3
> ## Status: Multi-Page Dash App Plugin
3
-
> #### Under active development: A plugin to simplify creating multi-page Dash apps. This is a preview of functionality that will be added to Dash 2.x.
4
+
> #### The `pages` functionality is now part of dash 2.5! These docs remain here for legacy purposes. `pages` is a plugin to simplify creating multi-page Dash apps.
4
5
> **[See the community announcement for details and discussion](https://community.plotly.com/t/introducing-dash-pages-dash-2-1-feature-preview/57775)**
5
6
6
7
@@ -52,9 +53,9 @@ In the `pages` folder we have 3 simple pages to demonstrate this feature.
52
53
53
54
#### `a_page.py`
54
55
```python
55
-
importdash
56
+
from dash_labs.plugins importregister_page
56
57
57
-
dash.register_page(__name__)
58
+
register_page(__name__)
58
59
59
60
60
61
deflayout():
@@ -69,9 +70,9 @@ def layout():
69
70
70
71
#### `birds.py`
71
72
```python
72
-
importdash
73
+
from dash_labs.plugins importregister_page
73
74
74
-
dash.register_page(
75
+
register_page(
75
76
__name__,
76
77
title="(birds) The title, headline or name of the page",
77
78
description="(birds) A short description or summary 2-3 sentences",
Copy file name to clipboardExpand all lines: docs/11-MultiPageDashApp-LayoutFunctions.md
+8-7
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
2
2
> ## Status: Multi-Page Dash App Plugin
3
-
> #### Under active development: A plugin to simplify creating multi-page Dash apps. This is a preview of functionality that will be added to Dash 2.x.
3
+
> #### The `pages` functionality is now part of dash 2.5! These docs remain here for legacy purposes. `pages` is a plugin to simplify creating multi-page Dash apps.
4
4
> **[See the community announcement for details and discussion](https://community.plotly.com/t/introducing-dash-pages-dash-2-1-feature-preview/57775)**
5
5
6
6
@@ -79,9 +79,9 @@ This is the `home.py` file. (The `about.py` and `topic_1.py` files are similar).
79
79
80
80
```python
81
81
from dash import html
82
-
importdash
82
+
from dash_labs.plugins importregister_page
83
83
84
-
dash.register_page(__name__, top_nav=True)
84
+
register_page(__name__, top_nav=True)
85
85
86
86
87
87
layout = html.Div("About page content")
@@ -125,18 +125,19 @@ def sidebar():
125
125
```
126
126
Here is `topic_2.py` (`topic_1.py` and `topic_3.py` are similar). Note that the layout is also a function.
127
127
128
-
As you see below, `topic_2.py` and `topic_3.py` will NOT have `top_nav=True` included in `dash.register_page`,
128
+
As you see below, `topic_2.py` and `topic_3.py` will NOT have `top_nav=True` included in `register_page`,
129
129
but `topic_1.py` will include `top_nav=True` because we want that page in the navbar.
130
130
131
131
```python
132
132
from dash import html
133
133
134
-
import dash
134
+
135
135
import dash_bootstrap_components as dbc
136
136
137
137
from .side_bar import sidebar
138
+
from dash_labs.plugins import register_page
138
139
139
-
dash.register_page(__name__)
140
+
register_page(__name__)
140
141
141
142
142
143
deflayout():
@@ -147,7 +148,7 @@ def layout():
147
148
```
148
149
The main purpose of this example is to show how to use `dash.page_registry` from within the `pages` folder.
149
150
The reason `sidebar` and the layouts for the three topic pages need to be functions is that pages are added to
150
-
`dash.register_page`as each module is imported from the `pages` folder and `dash.register_page` is called.
151
+
`register_page`as each module is imported from the `pages` folder and `register_page` is called.
151
152
If you don't use a function then all the pages may not yet be in `dash.page_registry` when it's used to create thing
152
153
like the sidebar. When you use a function, it will create the layout when it's used rather than when it's imported.
0 commit comments