Skip to content

How to run dash-slicer in the @app.callback? #55

@mareksocha

Description

@mareksocha

Hi,
I am strugling to make dash-slicer work in the app.callback. Here is my code:

import dash
import dash_html_components as html
import imageio
from dash_slicer import VolumeSlicer

app = dash.Dash(__name__, update_title=None)

app.layout = html.Div(
    children=[
        html.Button('Randomize', id='random_button', n_clicks=0),
        html.Div(id='series_viewer')
    ]
)


@app.callback(
    dash.dependencies.Output('series_viewer', 'children'),
    dash.dependencies.Input('random_button', 'n_clicks')
)
def show(n_clicks):
    vol = imageio.volread("imageio:stent.npz")
    slicer = VolumeSlicer(app, vol)
    slicer.graph.config["scrollZoom"] = False
    return slicer.graph, slicer.slider, *slicer.stores


if __name__ == "__main__":
    app.run_server(debug=True, dev_tools_props_check=False)

What I am getting is:
obraz

Where there should be an image over the slider. Is there any way to make it work?

This code is based on the example from: Introduction to Dash Slicer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions