refine json-import ui
Browse files99 unmodified lines10010110210310410510610710810911011111211311448 unmodified lines16316416516616716816917017199 unmodified lineswith gr.Column(min_width=80):importBtn = gr.Button(value="Import")with gr.Accordion(label="Json", open=False):gr.Markdown("""| inout | how to || -----------------| ----------------------------------------------------------------------------------------- || Import | Paste json to "Json source" and click "Import Json", edit the width/height, then click "Start edit". || Export | click "Save" and "Copy to clipboard" of "Json" section. |""")json = gr.JSON(label="Json")jsonInput = gr.Textbox(label="Json source", lines=10)jsonInputBtn = gr.Button(value="Import Json")with gr.Accordion(label="Notes", open=False):gr.Markdown("""Points to note for pseudo-3D rotation: When performing pseudo-3D rotation on the X and Y axes, the projection is converted to 2D and Z-axis information is lost when the mouse button is released. This means that if you finish dragging while the shape is collapsed, you may not be able to restore it to its original state. In such a case, please use the "undo" function.48 unmodified linesfn = None,inputs = [], outputs = [json],_js="() => { return [savePose()]; }")jsonInputBtn.click(fn = lambda x: x,inputs = [jsonInput], outputs = [json])demo.load(fn=None, inputs=[], outputs=[], _js="() => { initializeEditor(); importPose(); return []; }")gr.mount_gradio_app(app, demo, path="/")99 unmodified lines10010110210310410510610710810911011111211311411511611711811948 unmodified lines16816917017117217317417517617717817918018118218318418518699 unmodified lineswith gr.Column(min_width=80):importBtn = gr.Button(value="Import")with gr.Accordion(label="Json", open=False):with gr.Row():with gr.Column(min_width=80):replaceWithJsonBtn = gr.Button(value="Replace")with gr.Column(min_width=80):importJsonBtn = gr.Button(value="Import")gr.Markdown("""| inout | how to || -----------------| ----------------------------------------------------------------------------------------- || Import | Paste json to "Json source" and click "Read", edit the width/height, then click "Replace" or "Import". || Export | click "Save" and "Copy to clipboard" of "Json" section. |""")json = gr.JSON(label="Json")jsonSource = gr.Textbox(label="Json source", lines=10)jsonReadBtn = gr.Button(value="Read")with gr.Accordion(label="Notes", open=False):gr.Markdown("""Points to note for pseudo-3D rotation: When performing pseudo-3D rotation on the X and Y axes, the projection is converted to 2D and Z-axis information is lost when the mouse button is released. This means that if you finish dragging while the shape is collapsed, you may not be able to restore it to its original state. In such a case, please use the "undo" function.48 unmodified linesfn = None,inputs = [], outputs = [json],_js="() => { return [savePose()]; }")jsonReadBtn.click(fn = lambda x: x,inputs = [jsonSource], outputs = [json])replaceWithJsonBtn.click(fn = None,inputs = [json],outputs = [],_js="(json) => { initializeEditor(); importPose(json); return []; }")importJsonBtn.click(fn = None,inputs = [json],outputs = [],_js="(json) => { importPose(json); return []; }")demo.load(fn=None, inputs=[], outputs=[], _js="() => { initializeEditor(); importPose(); return []; }")gr.mount_gradio_app(app, demo, path="/")
app.py+20-5