Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Disable controls while loading #51

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions callbacks/image_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,75 @@ def locally_store_annotations(relayout_data, img_idx, annotation_store):
return annotation_store


clientside_callback(
"""
function DisableControlsDuringLoading(project_source_trigger, slider_trigger) {
console.log(window.dash_clientside.callback_context.triggered)
return Array(17).fill(true)
}
""",
Output("figure-brightness", "disabled"),
Output("figure-contrast", "disabled"),
Output("filters-reset", "disabled"),
Output("view-annotations", "disabled"),
Output("open-freeform", "disabled"),
Output("closed-freeform", "disabled"),
Output("circle", "disabled"),
Output("rectangle", "disabled"),
Output("drawing-off", "disabled"),
Output("paintbrush-width", "disabled"),
Output("annotation-class-selection", "disabled"),
Output("annotation-class-selection", "disabled", "disabled"),
Output({"type": "annotation-color", "index": "red"}, "disabled"),
Output({"type": "annotation-color", "index": "grape"}, "disabled"),
Output({"type": "annotation-color", "index": "violet"}, "disabled"),
Output({"type": "annotation-color", "index": "blue"}, "disabled"),
Output({"type": "annotation-color", "index": "yellow"}, "disabled"),
Input("project-name-src", "value"),
Input("image-selection-slider", "value"),
prevent_initial_call="initial_duplicate",
)
clientside_callback(
"""
function EnableControlsAfterLoading(project_source_trigger) {
return Array(17).fill(false)
}
""",
Output("figure-brightness", "disabled", allow_duplicate=True),
Output("figure-contrast", "disabled", allow_duplicate=True),
Output("filters-reset", "disabled", allow_duplicate=True),
Output("view-annotations", "disabled", allow_duplicate=True),
Output("open-freeform", "disabled", allow_duplicate=True),
Output("closed-freeform", "disabled", allow_duplicate=True),
Output("circle", "disabled", allow_duplicate=True),
Output("rectangle", "disabled", allow_duplicate=True),
Output("drawing-off", "disabled", allow_duplicate=True),
Output("paintbrush-width", "disabled", allow_duplicate=True),
Output("annotation-class-selection", "disabled", allow_duplicate=True),
Output(
{"type": "annotation-color", "index": "red"}, "disabled", allow_duplicate=True
),
Output(
{"type": "annotation-color", "index": "grape"}, "disabled", allow_duplicate=True
),
Output(
{"type": "annotation-color", "index": "violet"},
"disabled",
allow_duplicate=True,
),
Output(
{"type": "annotation-color", "index": "blue"}, "disabled", allow_duplicate=True
),
Output(
{"type": "annotation-color", "index": "yellow"},
"disabled",
allow_duplicate=True,
),
Input("image-viewer", "figure"),
prevent_initial_call=True,
)


@callback(
Output("image-selection-slider", "min"),
Output("image-selection-slider", "max"),
Expand Down
11 changes: 11 additions & 0 deletions components/control_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def layout():
step=1,
color="gray",
size="sm",
disabled=True,
),
dmc.Space(h=5),
dmc.Text("Contrast", size="sm"),
Expand All @@ -82,6 +83,7 @@ def layout():
step=1,
color="gray",
size="sm",
disabled=True,
),
dmc.Space(h=10),
dmc.ActionIcon(
Expand All @@ -101,6 +103,7 @@ def layout():
mb=10,
ml="auto",
style={"margin": "auto"},
disabled=True,
),
]
),
Expand All @@ -119,6 +122,7 @@ def layout():
label="View annotation layer",
checked=True,
styles={"trackLabel": {"cursor": "pointer"}},
disabled=True,
)
),
dmc.Space(h=20),
Expand All @@ -134,6 +138,7 @@ def layout():
color="gray",
children=DashIconify(icon="mdi:draw"),
style={"border": "3px solid black"},
disabled=True,
),
label="Open Freeform",
),
Expand All @@ -145,6 +150,7 @@ def layout():
children=DashIconify(
icon="fluent:draw-shape-20-regular"
),
disabled=True,
),
label="Closed Freeform",
),
Expand All @@ -156,6 +162,7 @@ def layout():
children=DashIconify(
icon="gg:shape-circle"
),
disabled=True,
),
label="Circle",
),
Expand All @@ -167,6 +174,7 @@ def layout():
children=DashIconify(
icon="gg:shape-square"
),
disabled=True,
),
label="Rectangle",
),
Expand All @@ -176,6 +184,7 @@ def layout():
variant="outline",
color="gray",
children=DashIconify(icon="el:off"),
disabled=True,
),
label="Stop Drawing",
),
Expand All @@ -191,6 +200,7 @@ def layout():
step=1,
color="gray",
size="sm",
disabled=True,
),
dmc.Space(h=20),
dmc.Text("Annotation class", size="sm"),
Expand All @@ -207,6 +217,7 @@ def layout():
className=f"{color}-icon",
id={"type": "annotation-color", "index": color},
w=30,
disabled=True,
)
for i, color in enumerate(
[
Expand Down