mohammed-aljafry commited on
Commit
5836a74
·
verified ·
1 Parent(s): 47d05b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -9
app.py CHANGED
@@ -179,19 +179,30 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"), cs
179
  # evt.index هو رقم الصف الذي تم الضغط عليه
180
  selected_example = FULL_EXAMPLES_DATA[evt.index]
181
  return gr.update(value=selected_example["img_path"]), gr.update(value=selected_example["json_path"])
182
-
183
- # --- استخدام gr.Dataset ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  example_dataset = gr.Dataset(
185
- components=[
186
- gr.Image(label="الصورة", type="filepath"),
187
- gr.Textbox(label="السرعة"),
188
- gr.Textbox(label="الاتجاه"),
189
- gr.Textbox(label="الموقع"),
190
- gr.Textbox(label="الهدف")
191
- ],
192
  samples=SAMPLES_FOR_DISPLAY,
193
  label="اختر سيناريو اختبار"
194
  )
 
195
  # --- ربط حدث التحديد بالدالة ---
196
  example_dataset.select(
197
  fn=on_example_select,
@@ -200,6 +211,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"), cs
200
  )
201
  else:
202
  gr.Markdown("لم يتم العثور على أمثلة صالحة.")
 
203
 
204
  with gr.Column(scale=3):
205
  with gr.Group():
 
179
  # evt.index هو رقم الصف الذي تم الضغط عليه
180
  selected_example = FULL_EXAMPLES_DATA[evt.index]
181
  return gr.update(value=selected_example["img_path"]), gr.update(value=selected_example["json_path"])
182
+
183
+ # --- استخدام gr.Dataset مع إخفاء المكونات ---
184
+ with gr.Accordion("📝 تفاصيل السيناريو المحدد", open=False): # المكونات التي تظهر فوق الجدول سيتم طيّها داخل هذا الـ Accordion
185
+ example_image = gr.Image(label="الصورة", type="filepath")
186
+ example_speed = gr.Textbox(label="السرعة")
187
+ example_theta = gr.Textbox(label="الاتجاه")
188
+ example_position = gr.Textbox(label="الموقع")
189
+ example_target = gr.Textbox(label="الهدف")
190
+
191
+ example_components = [example_image, example_speed, example_theta, example_position, example_target]
192
+
193
+ if SAMPLES_FOR_DISPLAY:
194
+ # --- دالة التحديد ---
195
+ def on_example_select(evt: gr.SelectData):
196
+ selected_example = FULL_EXAMPLES_DATA[evt.index]
197
+ return gr.update(value=selected_example["img_path"]), gr.update(value=selected_example["json_path"])
198
+
199
+ # --- الجدول بدون عرض المكونات العلوية بشكل مزعج ---
200
  example_dataset = gr.Dataset(
201
+ components=example_components,
 
 
 
 
 
 
202
  samples=SAMPLES_FOR_DISPLAY,
203
  label="اختر سيناريو اختبار"
204
  )
205
+
206
  # --- ربط حدث التحديد بالدالة ---
207
  example_dataset.select(
208
  fn=on_example_select,
 
211
  )
212
  else:
213
  gr.Markdown("لم يتم العثور على أمثلة صالحة.")
214
+
215
 
216
  with gr.Column(scale=3):
217
  with gr.Group():