Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Callback with navbar

$
0
0

Hi all,

I have this code below. I’ve created 3 navigation links: Inputs, Calculations and About.

Now on the Inputs sheet, I would like to add several dropdowns and input fields for the user. How can I include those input fields and give them ids as I want to use them for calculations later (i.e I create a dropdown and I give it an id of “my-dropdown” to later use for the calculations I want to make in Calculations).

So far this is what I have in the callbacks but if I want to continue my function with an elif pathname == “/inputs” and then I start including my input fields, I will not be able to store their ids to call them later once I want to do the calculations. Can you please advise?

navbar = dbc.NavbarSimple(
    children=[
        dbc.NavItem(dbc.NavLink("INPUTS", href="/inputs", external_link=True, active="exact")),
        dbc.NavItem(dbc.NavLink("CALCULATIONS", href="/calculations", external_link=True, active="exact")),
        dbc.NavItem(dbc.NavLink("ABOUT", href="/about", external_link=True, active="exact")),
        dbc.DropdownMenu(
            children=[
                dbc.DropdownMenuItem("Comments", href="/comments", external_link=True),
                dbc.DropdownMenuItem("Version Updates", href="/updates", external_link=True),

            ],
            nav=True,
            in_navbar=True,
            label="More",
        ),
    ],
    brand="Main Page Title",
    color="#015151",
    dark=True
)

content = html.Div(id="page-content", children=[])

app.layout = html.Div([
    dcc.Location(id="url"),
    navbar,
    content
])


# ---------------------------------------------------------------------------
## APP CALLBACKS ##

# Add info in about section
@app.callback(
    Output("page-content", "children"),
    [Input("url", "pathname")]
)
def render_page_content(pathname):
    if pathname == "/about":
        return [
            html.Br(),
            html.Br(),
            html.P('About', style={'fontWeight': 'bold', 'font-size': 32, 'margin-left': '20px'}),

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images