Spaces:
Runtime error
Runtime error
Update app.py
Browse files162 unmodified lines16316416516616716816917017117217317417517217617717417817918018118218318418518618718818919019119219319419519619719819913 unmodified lines21321421519419519619719819920020120220320420520620720820921621721821955 unmodified lines275276277278162 unmodified lines return generate_plot(df, "Edited Layout", selected), df.to_dict("records")
@app.callback( Output("edited-data", "data", allow_duplicate=True), Output("selected-led", "data"), Output("move-mode", "data"), Input("edited-plot", "clickData"), State("selected-led", "data"), State("move-mode", "data"), State("edited-data", "data"), State("snap-toggle", "value"), prevent_initial_call=True)def select_or_toggle_led(click, moving):def handle_led_click(click, selected, moving, data, snap_val): if not click: return None, False return dash.no_update, selected, moving pt = click["points"][0] clicked_text = pt.get("text", None) x, y = pt["x"], pt["y"]
if clicked_text and clicked_text.isdigit(): # Select LED return dash.no_update, int(clicked_text), True
if selected and moving: # Move previously selected LED if "snap" in snap_val: x, y = snap(x), snap(y) df = pd.DataFrame(data) df.loc[df["LED Number"] == selected, "X Position"] = x df.loc[df["LED Number"] == selected, "Y Position"] = y return df.to_dict("records"), None, False
return dash.no_update, selected, moving pt = click["points"][0] led_number = pt.get("text", None) if led_number and led_number.isdigit():13 unmodified lines State("snap-toggle", "value"), prevent_initial_call=True)def move_selected_led(click, selected, moving, data, snap_val): if not (click and selected and moving): return dash.no_update, selected, moving pt = click["points"][0] # Allow move only if text is not a marker (i.e. blank canvas) if pt.get("text", None): print("Click ignored: clicked on LED marker.") return dash.no_update, selected, True x, y = pt["x"], pt["y"] if "snap" in snap_val: x, y = snap(x), snap(y) df = pd.DataFrame(data) df.loc[df["LED Number"] == selected, "X Position"] = x df.loc[df["LED Number"] == selected, "Y Position"] = y print(f"Moved LED {selected} to ({x}, {y})") return df.to_dict("records"), new_led_number, True, None, False
@app.callback( Output("edited-data", "data"),55 unmodified lines
app.py+26-18