MCPcopy
hub / github.com/plotly/dash / find_component

Function find_component

dash/_layout_utils.py:124–144  ·  view source on GitHub ↗

Find a component by ID. If neither ``layout`` nor ``page`` is provided, searches the full app layout (preferring ``validation_layout`` for completeness).

(
    component_id: str | dict,
    layout: Component | None = None,
    page: str | None = None,
)

Source from the content-addressed store, hash-verified

122
123
124def find_component(
125 component_id: str | dict,
126 layout: Component | None = None,
127 page: str | None = None,
128) -> Component | None:
129 """Find a component by ID.
130
131 If neither ``layout`` nor ``page`` is provided, searches the full
132 app layout (preferring ``validation_layout`` for completeness).
133 """
134 if page is not None:
135 layout = _resolve_page_layout(page)
136
137 if layout is None:
138 app = get_app()
139 layout = getattr(app, "validation_layout", None) or app.get_layout()
140
141 for comp, _ in traverse(layout):
142 if getattr(comp, "id", None) == component_id:
143 return comp
144 return None
145
146
147def parse_wildcard_id(pid: Any) -> dict | None:

Callers 9

get_initial_valueMethod · 0.90
is_validMethod · 0.90
_initial_outputMethod · 0.90
outputsMethod · 0.90
inputsMethod · 0.90
call_toolMethod · 0.90
test_finds_by_dict_idMethod · 0.90

Calls 4

get_appFunction · 0.90
_resolve_page_layoutFunction · 0.85
traverseFunction · 0.85
get_layoutMethod · 0.45

Tested by 3

test_finds_by_dict_idMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…