Hi, so basically i want the start-button for a callback to turn disabled during the callback procedure. I have searched a little bit and found the keyword argument “running” (https://dash.plotly.com/reference) for a long_callback which is exactly what i need.
Problem now is that even though i imported the libraries for cache and long_callback_manager like in the examples the programm cant handle it for some reason and my CPU jumps up to a cozy 100%.
Here are some of the relevant code snippets that make my pc unhappy :’)
Import and cache:
from dash.long_callback import DiskcacheLongCallbackManager
import diskcache
print('Programmstart')
cache = diskcache.Cache("./cache")
long_callback_manager = DiskcacheLongCallbackManager(cache)
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SOLAR], long_callback_manager=long_callback_manager)
The actual callback:
@app.long_callback(
[
Output('start_output', 'children'),
Output('results', 'style'),
Output('settings_page', 'style'),
Output('start_button', 'children')
],
[
Input('start_button', 'n_clicks')
],
[
State('example_switch', 'value'),
State('year_dropdown', 'value'),
State('wind_hours_slider', 'value'),
State('biomass_switch', 'value'),
State('biomass_input', 'value'),
State('solar_switch', 'value'),
State('solar_input', 'value'),
State('wind_expansion_switch', 'value'),
State('planned_wind_switch', 'value'),
State('methods_wind_check', 'value'),
State('storage_switch', 'value'),
State('storage_expansion_switch', 'value'),
State('storage_expansion_slider', 'value'),
State('start_capacity_slider', 'value'),
State('safety_padding_slider', 'value'),
State('storage_options_check', 'value'),
State('results', 'style'),
State('settings_page', 'style')
],
running=[(Output('start_button', 'disabled'), False, True)]
)
If anyone had the same problems or maybe even knows a better solution with a normal callback, please let me know