jonigata commited on
Commit
38122ef
1 Parent(s): 3eb5670

refine json-import ui

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -100,15 +100,20 @@ with gr.Blocks(css="""button { min-width: 80px; }""") as demo:
100
  with gr.Column(min_width=80):
101
  importBtn = gr.Button(value="Import")
102
  with gr.Accordion(label="Json", open=False):
 
 
 
 
 
103
  gr.Markdown("""
104
  | inout | how to |
105
  | -----------------| ----------------------------------------------------------------------------------------- |
106
- | Import | Paste json to "Json source" and click "Import Json", edit the width/height, then click "Start edit". |
107
  | Export | click "Save" and "Copy to clipboard" of "Json" section. |
108
  """)
109
  json = gr.JSON(label="Json")
110
- jsonInput = gr.Textbox(label="Json source", lines=10)
111
- jsonInputBtn = gr.Button(value="Import Json")
112
  with gr.Accordion(label="Notes", open=False):
113
  gr.Markdown("""
114
  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.
@@ -163,9 +168,19 @@ When using Q, X, C, R, pressing and dont release until the operation is complete
163
  fn = None,
164
  inputs = [], outputs = [json],
165
  _js="() => { return [savePose()]; }")
166
- jsonInputBtn.click(
167
  fn = lambda x: x,
168
- inputs = [jsonInput], outputs = [json])
 
 
 
 
 
 
 
 
 
 
169
  demo.load(fn=None, inputs=[], outputs=[], _js="() => { initializeEditor(); importPose(); return []; }")
170
 
171
  gr.mount_gradio_app(app, demo, path="/")
 
100
  with gr.Column(min_width=80):
101
  importBtn = gr.Button(value="Import")
102
  with gr.Accordion(label="Json", open=False):
103
+ with gr.Row():
104
+ with gr.Column(min_width=80):
105
+ replaceWithJsonBtn = gr.Button(value="Replace")
106
+ with gr.Column(min_width=80):
107
+ importJsonBtn = gr.Button(value="Import")
108
  gr.Markdown("""
109
  | inout | how to |
110
  | -----------------| ----------------------------------------------------------------------------------------- |
111
+ | Import | Paste json to "Json source" and click "Read", edit the width/height, then click "Replace" or "Import". |
112
  | Export | click "Save" and "Copy to clipboard" of "Json" section. |
113
  """)
114
  json = gr.JSON(label="Json")
115
+ jsonSource = gr.Textbox(label="Json source", lines=10)
116
+ jsonReadBtn = gr.Button(value="Read")
117
  with gr.Accordion(label="Notes", open=False):
118
  gr.Markdown("""
119
  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.
 
168
  fn = None,
169
  inputs = [], outputs = [json],
170
  _js="() => { return [savePose()]; }")
171
+ jsonReadBtn.click(
172
  fn = lambda x: x,
173
+ inputs = [jsonSource], outputs = [json])
174
+ replaceWithJsonBtn.click(
175
+ fn = None,
176
+ inputs = [json],
177
+ outputs = [],
178
+ _js="(json) => { initializeEditor(); importPose(json); return []; }")
179
+ importJsonBtn.click(
180
+ fn = None,
181
+ inputs = [json],
182
+ outputs = [],
183
+ _js="(json) => { importPose(json); return []; }")
184
  demo.load(fn=None, inputs=[], outputs=[], _js="() => { initializeEditor(); importPose(); return []; }")
185
 
186
  gr.mount_gradio_app(app, demo, path="/")