当前位置: 首页>>代码示例>>Python>>正文


Python dependencies.State方法代码示例

本文整理汇总了Python中dash.dependencies.State方法的典型用法代码示例。如果您正苦于以下问题:Python dependencies.State方法的具体用法?Python dependencies.State怎么用?Python dependencies.State使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dash.dependencies的用法示例。


在下文中一共展示了dependencies.State方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_state

# 需要导入模块: from dash import dependencies [as 别名]
# 或者: from dash.dependencies import State [as 别名]
def get_state(self, attribute_name):
        return State(self.full_name, attribute_name) 
开发者ID:negrinho,项目名称:deep_architect,代码行数:4,代码来源:main.py

示例2: set_callbacks

# 需要导入模块: from dash import dependencies [as 别名]
# 或者: from dash.dependencies import State [as 别名]
def set_callbacks(self, app):
        @app.callback(
            Output(self.ids("parameter"), "value"),
            [
                Input(self.ids("prev-btn"), "n_clicks"),
                Input(self.ids("next-btn"), "n_clicks"),
            ],
            [State(self.ids("parameter"), "value")],
        )
        def _set_parameter_from_btn(_prev_click, _next_click, column):

            ctx = dash.callback_context.triggered
            if ctx is None:
                raise PreventUpdate
            callback = ctx[0]["prop_id"]
            if callback == f"{self.ids('prev-btn')}.n_clicks":
                column = prev_value(column, self.parameter_columns)
            elif callback == f"{self.ids('next-btn')}.n_clicks":
                column = next_value(column, self.parameter_columns)
            else:
                column = self.parameter_columns[0]
            return column

        @app.callback(
            Output(self.ids("graph"), "data"), [Input(self.ids("parameter"), "value")]
        )
        def _set_parameter(column):
            param = self.parameters[[column, "REAL", "ENSEMBLE"]]

            ensembles = param["ENSEMBLE"].unique().tolist()

            iterations = []
            values = []
            labels = []

            for ensemble in ensembles:
                df = param[param["ENSEMBLE"] == ensemble]
                iterations.append(ensemble)
                values.append(df[column].tolist())
                labels.append([f"Realization {real}" for real in df["REAL"].tolist()])

            return {"iterations": iterations, "values": values, "labels": labels} 
开发者ID:equinor,项目名称:webviz-subsurface,代码行数:44,代码来源:_parameter_distribution.py

示例3: init_callbacks

# 需要导入模块: from dash import dependencies [as 别名]
# 或者: from dash.dependencies import State [as 别名]
def init_callbacks(dash_app):
    @dash_app.callback(
        [
            Output("output-geojson-upload", "children"),
            Output("geojson-dropdown", "options"),
        ],
        [Input("upload-geojson", "contents")],
        [State("upload-geojson", "filename")],
    )
    def update_geojson(contents, filename):
        if filename is None:
            raise PreventUpdate
        geojson_options = [build_option(ct["key"]) for ct in get_custom_geojson()]
        try:
            geojson_key = load_geojson(contents, filename)
            geojson_options.append(build_option(geojson_key))
            return "{} uploaded!".format(geojson_key), geojson_options
        except BaseException as ex:
            return str(ex), geojson_options

    @dash_app.callback(
        [
            Output("featureidkey-dropdown", "options"),
            Output("featureidkey-dropdown", "disabled"),
            Output("featureidkey-dropdown", "placeholder"),
        ],
        [Input("geojson-dropdown", "value")],
    )
    def update_featureidkey_options(geojson):
        geojson_data = get_custom_geojson(geojson)
        placeholder = "Select uploaded data"
        if geojson_data is None or isinstance(geojson_data, list):
            return [], False, placeholder
        disabled = geojson_data["type"] != "FeatureCollection"
        placeholder = "id" if disabled else placeholder
        if geojson_data and not disabled:
            return (
                [build_option(p) for p in geojson_data.get("properties", [])],
                disabled,
                placeholder,
            )
        return [], disabled, placeholder

    @dash_app.callback(
        Output("geojson-modal", "is_open"),
        [
            Input("open-geojson-modal", "n_clicks"),
            Input("close-geojson-modal", "n_clicks"),
        ],
        [State("geojson-modal", "is_open")],
    )
    def toggle_modal(n1, n2, is_open):
        if n1 or n2:
            return not is_open
        return is_open 
开发者ID:man-group,项目名称:dtale,代码行数:57,代码来源:custom_geojson.py

示例4: simple_app_callback

# 需要导入模块: from dash import dependencies [as 别名]
# 或者: from dash.dependencies import State [as 别名]
def simple_app_callback(
        app,
        dash_duo,
        component_id,
        test_prop_name,
        test_prop_value,
        prop_value_type,
        validation_fn=None,
        take_snapshot=False
):
    if validation_fn is None:
        def validation_fn(x): return x == test_prop_value

    @app.callback(
        Output(component_id, test_prop_name),
        [Input('submit-prop-button', 'n_clicks')],
        [State('prop-value', 'value')]
    )
    def setup_click_callback(nclicks, value):
        if nclicks is not None and nclicks > 0:
            return process_value(value, prop_value_type)
        raise dash.exceptions.PreventUpdate()

    @app.callback(
        Output('pass-fail-div', 'children'),
        [Input(component_id, test_prop_name)],
        [State('submit-prop-button', 'n_clicks')]
    )
    def simple_callback(prop_value, nclicks):
        if nclicks is None or nclicks == 0:
            return None
        passfail = PASS if validation_fn(prop_value) else FAIL
        return html.Div(passfail, id='passfail')

    _start_app_server(
        app,
        dash_duo,
        component_id,
        test_prop_name,
        test_prop_value,
        take_snapshot
    ) 
开发者ID:plotly,项目名称:dash-bio,代码行数:44,代码来源:common_features.py


注:本文中的dash.dependencies.State方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。