# `gradio_floorplan` Static Badge A Gradio custom component for interactive SVG floor plan editing ## Installation ```bash pip install gradio_floorplan ``` ## Usage ```python import gradio as gr from gradio_floorplan import FloorPlan DEFAULT_VALUE = { "corners": [[50, 50], [550, 50], [550, 450], [50, 450]], "furnitures": [ { "object": "Sofa", "localisation": [150, 100, 250, 300], "description": "3-seat sofa", }, { "object": "Table", "localisation": [300, 200, 380, 400], "description": "Coffee table", }, ], } def on_furniture_moved(value): """Receives updated floor plan after user moves a furniture item.""" return value with gr.Blocks() as demo: gr.Markdown("## LaMaison — Floor Plan") floor_plan = FloorPlan(value=DEFAULT_VALUE, label="Floor Plan", interactive=True) output = gr.JSON(label="Updated positions") floor_plan.change(on_furniture_moved, inputs=floor_plan, outputs=output) if __name__ == "__main__": demo.launch() ``` ## `FloorPlan` ### Initialization
name type default description
value ```python dict | None ``` value = None None
label ```python str | None ``` value = None None
info ```python str | None ``` value = None None
every ```python 'Timer | float | None' ``` value = None None
show_label ```python bool | None ``` value = None None
container ```python bool ``` value = True None
scale ```python int | None ``` value = None None
min_width ```python int ``` value = 160 None
interactive ```python bool | None ``` value = None None
visible ```python bool ``` value = True None
elem_id ```python str | None ``` value = None None
elem_classes ```python list[str] | str | None ``` value = None None
render ```python bool ``` value = True None
### Events | name | description | |:-----|:------------| | `change` | | ### User function The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both). - When used as an Input, the component only impacts the input signature of the user function. - When used as an output, the component only impacts the return signature of the user function. The code snippet below is accurate in cases where the component is used as both an input and an output. ```python def predict( value: dict| None ) -> dict| None: return value ```