Spaces:
Runtime error
Runtime error
Update app.py
Browse files162 unmodified lines16316416516616716816917017117217317417517617713 unmodified lines19119219319419519619719819920020120220320420520620720820921021121255 unmodified lines268269270162 unmodified linesreturn generate_plot(df, "Edited Layout", selected), df.to_dict("records")@app.callback(Output("selected-led", "data"),Output("move-mode", "data"),Input("edited-plot", "clickData"),State("move-mode", "data"),prevent_initial_call=True)def select_or_toggle_led(click, moving):if not click:return None, Falsept = click["points"][0]led_number = pt.get("text", None)if led_number and led_number.isdigit():13 unmodified linesState("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, movingpt = 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, Truex, 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"] = xdf.loc[df["LED Number"] == selected, "Y Position"] = yprint(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 lines162 unmodified lines16316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819913 unmodified lines21321421521621721821955 unmodified lines275276277278162 unmodified linesreturn 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 handle_led_click(click, selected, moving, data, snap_val):if not click:return dash.no_update, selected, movingpt = click["points"][0]clicked_text = pt.get("text", None)x, y = pt["x"], pt["y"]if clicked_text and clicked_text.isdigit():# Select LEDreturn dash.no_update, int(clicked_text), Trueif selected and moving:# Move previously selected LEDif "snap" in snap_val:x, y = snap(x), snap(y)df = pd.DataFrame(data)df.loc[df["LED Number"] == selected, "X Position"] = xdf.loc[df["LED Number"] == selected, "Y Position"] = yreturn df.to_dict("records"), None, Falsereturn dash.no_update, selected, movingpt = click["points"][0]led_number = pt.get("text", None)if led_number and led_number.isdigit():13 unmodified linesState("snap-toggle", "value"),prevent_initial_call=True)@app.callback(Output("edited-data", "data"),55 unmodified lines
app.py+26-18