本文整理汇总了Python中dash.Dash方法的典型用法代码示例。如果您正苦于以下问题:Python dash.Dash方法的具体用法?Python dash.Dash怎么用?Python dash.Dash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dash
的用法示例。
在下文中一共展示了dash.Dash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dbm3002_rotate
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbm3002_rotate(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div([
dash_bio.Molecule3dViewer(
id=_COMPONENT_ID,
modelData=_model_data,
styles=_styles_data
)
])
dash_duo.start_server(app)
dash_duo.wait_for_element('#' + _COMPONENT_ID)
mol3d = dash_duo.find_element('#' + _COMPONENT_ID + ' canvas')
ac = ActionChains(dash_duo.driver)
ac.drag_and_drop_by_offset(mol3d, 100, 50).perform()
dash_duo.percy_snapshot('test-mol3d_rotate')
示例2: add
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def add(self, filename: pathlib.Path) -> str:
"""Calling this function makes the filename given as input
available as a hosted asset when the application is running.
The returned string is a URI which the plugin optionally
can use internally (e.g. as "src" in image elements).
Calling this function with the same input path
multiple times will return the same URI.
Filenames added to WebvizAssets that ends with .css or .js
are loaded automatically in the browser by Dash,
both in non-portable and portable mode.
"""
path = pathlib.Path(filename)
if filename not in self._assets.values():
assigned_id = self._generate_id(path.name)
self._assets[assigned_id] = filename
else:
assigned_id = {v: k for k, v in self._assets.items()}[filename]
return os.path.normcase(os.path.join(self._base_folder(), assigned_id))
示例3: test_example_plugin
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_example_plugin(dash_duo):
app = dash.Dash(__name__)
app.config.suppress_callback_exceptions = True
CACHE.init_app(app.server)
title = "Example"
page = _example_plugin.ExamplePlugin(app, title)
app.layout = page.layout
dash_duo.start_server(app)
btn = dash_duo.find_element("#" + page.uuid("submit-button"))
assert btn.text == "Submit"
text = dash_duo.find_element("#" + page.uuid("output-state"))
assert text.text == "Button has been pressed 0 times."
btn.click()
dash_duo.wait_for_contains_text(
"#" + page.uuid("output-state"), "Button has been pressed 1 times", timeout=2
)
assert text.text == "Button has been pressed 1 times."
示例4: test_data_table_with_settings
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_data_table_with_settings(dash_duo):
app = dash.Dash(__name__)
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.config.suppress_callback_exceptions = True
CACHE.init_app(app.server)
code_file = "./tests/data/example_data.csv"
with mock.patch(GET_DATA) as mock_path:
mock_path.return_value = pd.read_csv(code_file)
page = _data_table.DataTable(
csv_file=code_file, sorting=False, filtering=False, pagination=False
)
app.layout = page.layout
dash_duo.start_server(app)
assert dash_duo.get_logs() == [], "browser console should contain no error"
示例5: setUp
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def setUp(self):
"""Set up for tests. Need to provid Flask.test_client() to all tests. Further
configuration (e.g. FlaskLoginAuth) must be provided within the tests."""
server = Flask(__name__)
server.config.update(
SECRET_KEY = os.urandom(12),
)
self.app = Dash(name='app1', url_base_pathname='/app1', server=server)
self.app.layout = html.Div('Hello World!')
self.add_auth_app = Dash(name='add_auth_app', url_base_pathname='/add-auth-app', server=server)
self.add_auth_app.layout = html.Div('Hello World!')
self.multi_app_no_auth = Dash(name='multi_app_no_auth', url_base_pathname='/app-no-auth', server=server)
self.multi_app_no_auth.layout = html.Div('Hello World!')
# Will raise an error because it doesn't have the same server
self.crash_app = Dash(name='crash', url_base_pathname='/crash-app')
self.crash_app.layout = html.Div('Goodby Cruel World!')
self.server = server.test_client()
self.assertEqual(server.debug, False)
示例6: test_parameter_corr
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_parameter_corr(dash_duo):
app = dash.Dash(__name__)
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.config.suppress_callback_exceptions = True
CACHE.init_app(app.server)
app.webviz_settings = {
"shared_settings": {"scratch_ensembles": {"iter-0": ""}},
"theme": default_theme,
}
ensembles = ["iter-0"]
with mock.patch(get_parameters) as mock_parameters:
mock_parameters.return_value = pd.read_csv("tests/data/parameters.csv")
p = ParameterCorrelation(app, ensembles)
app.layout = p.layout
dash_duo.start_server(app)
my_component = dash_duo.find_element(f"#{p.ids('ensemble-all')}")
if not my_component.text.startswith("iter-0"):
raise AssertionError()
示例7: test_surface_selector
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_surface_selector(dash_duo):
app = dash.Dash(__name__)
app.config.suppress_callback_exceptions = True
realizations = pd.read_csv("tests/data/realizations.csv")
s = SurfaceSelector(app, surface_context, realizations)
app.layout = html.Div(children=[s.layout, html.Pre(id="pre", children="ok")])
@app.callback(Output("pre", "children"), [Input(s.storage_id, "data")])
def _test(data):
return json.dumps(json.loads(data))
dash_duo.start_server(app)
dash_duo.wait_for_contains_text("#pre", json.dumps(return_value), timeout=4)
示例8: test_dbcl001_colorscale
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbcl001_colorscale(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(nested_component_layout(
dash_bio.Clustergram(
data=_data
)
))
nested_component_app_callback(
app,
dash_duo,
component=dash_bio.Clustergram,
component_data=_data,
test_prop_name='color_map',
test_prop_value=json.dumps(
[[0, 'blue'], [0.5, 'yellow'], [1, 'pink']]
),
prop_value_type='list',
path_to_test_prop='["data"][2]["colorscale"]',
take_snapshot=True
)
示例9: test_dbcl006_df_input_row_cluster
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbcl006_df_input_row_cluster(dash_duo):
app = dash.Dash(__name__)
# run the same test as dbcl002 (row clustering) where table of
# observations (data argument) is left as a DataFrame
assert isinstance(_mtcars_data, pd.DataFrame)
app.layout = html.Div(nested_component_layout(
dash_bio.Clustergram(
data=_mtcars_data
)
))
nested_component_app_callback(
app,
dash_duo,
component=dash_bio.Clustergram,
component_data=_data,
test_prop_name='cluster',
test_prop_value='row',
prop_value_type='string'
)
assert len(dash_duo.find_elements('g.subplot.x2y2')) == 0
assert len(dash_duo.find_elements('g.subplot.x4y4')) == 1
示例10: test_dbsp001_rotate
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbsp001_rotate(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(
dash_bio.Speck(
id=_COMPONENT_ID,
data=_data
)
)
dash_duo.start_server(app)
dash_duo.wait_for_element('#' + _COMPONENT_ID)
speck = dash_duo.find_element('#' + _COMPONENT_ID + ' canvas')
ac = ActionChains(dash_duo.driver)
ac.move_to_element(speck).drag_and_drop_by_offset(
speck, 150, 200).perform()
dash_duo.percy_snapshot('test-speck_rotate')
示例11: test_dbsp002_click_and_drag
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbsp002_click_and_drag(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(
dash_bio.Speck(
id=_COMPONENT_ID,
data=_data
)
)
dash_duo.start_server(app)
dash_duo.wait_for_element('#' + _COMPONENT_ID)
speck = dash_duo.find_element('#' + _COMPONENT_ID + ' canvas')
ac = ActionChains(dash_duo.driver)
ac.move_to_element(speck).key_down(Keys.SHIFT).drag_and_drop_by_offset(
speck, -50, 100).key_up(Keys.SHIFT).perform()
dash_duo.percy_snapshot('test-speck_click_and_drag')
示例12: test_dbsp004_preset_view_toon
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbsp004_preset_view_toon(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(simple_app_layout(
dash_bio.Speck(
id=_COMPONENT_ID,
data=_data
)
))
simple_app_callback(
app,
dash_duo,
component_id=_COMPONENT_ID,
test_prop_name='presetView',
test_prop_value='toon',
prop_value_type='string',
take_snapshot=True
)
示例13: test_dbsp005_preset_view_stickball
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbsp005_preset_view_stickball(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(simple_app_layout(
dash_bio.Speck(
id=_COMPONENT_ID,
data=_data
)
))
simple_app_callback(
app,
dash_duo,
component_id=_COMPONENT_ID,
test_prop_name='presetView',
test_prop_value='stickball',
prop_value_type='string',
take_snapshot=True
)
示例14: test_dbm2002_preselected_atoms
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbm2002_preselected_atoms(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(simple_app_layout(
dash_bio.Molecule2dViewer(
id=_COMPONENT_ID,
modelData=_data,
selectedAtomIds=[1, 3]
)
))
dash_duo.start_server(app)
dash_duo.wait_for_element('#test-mol2d')
assert len(dash_duo.find_elements(
'g.nodes-container > g.node.selected[index="1"]')) == 1
assert len(dash_duo.find_elements(
'g.nodes-container > g.node.selected[index="3"]')) == 1
示例15: test_dbvp001_highlight_color
# 需要导入模块: import dash [as 别名]
# 或者: from dash import Dash [as 别名]
def test_dbvp001_highlight_color(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(nested_component_layout(
dash_bio.VolcanoPlot(
dataframe=_data
)
))
nested_component_app_callback(
app,
dash_duo,
component=dash_bio.VolcanoPlot,
component_data=_data,
test_prop_name='highlight_color',
test_prop_value='rgb(90, 12, 254)',
prop_value_type='string',
data_prop_name='dataframe',
take_snapshot=True
)