mdAmin313 commited on
Commit
e0fcab8
·
verified ·
1 Parent(s): 209262a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -187,7 +187,12 @@ with gr.Blocks() as demo:
187
  with gr.Row():
188
  with gr.Column(scale=1):
189
  country = gr.Dropdown(choices=COUNTRY_NAMES, value="United States", label="Country")
190
- state = gr.Dropdown(choices=[], label="State / Subdivision")
 
 
 
 
 
191
  update_btn = gr.Button("Refresh states")
192
  categories = gr.CheckboxGroup(place_options, label="Categories to search", value=["cafe","restaurant"])
193
  search_btn = gr.Button("Search places")
@@ -197,11 +202,9 @@ with gr.Blocks() as demo:
197
  map_html_out = gr.HTML(label="Map")
198
  table_out = gr.Dataframe(headers=["name","amenity","lat","lon","address","osm_id"], label="Results Table")
199
 
200
- # initial population of states for default country
201
- state.update(choices=list_subdivisions("US")[0], value=(list_subdivisions("US")[0][0] if list_subdivisions("US")[0] else None))
202
-
203
- update_btn.click(fn=update_states, inputs=country, outputs=[state, state], _js=None)
204
  search_btn.click(fn=run_search, inputs=[country, state, categories], outputs=[info, table_out, map_html_out, download])
205
 
 
206
  if __name__ == "__main__":
207
  demo.launch()
 
187
  with gr.Row():
188
  with gr.Column(scale=1):
189
  country = gr.Dropdown(choices=COUNTRY_NAMES, value="United States", label="Country")
190
+
191
+ # Initialize state dropdown with US subdivisions
192
+ us_names, us_codes = list_subdivisions("US")
193
+ default_state_value = us_names[0] if us_names else None
194
+ state = gr.Dropdown(choices=us_names, value=default_state_value, label="State / Subdivision")
195
+
196
  update_btn = gr.Button("Refresh states")
197
  categories = gr.CheckboxGroup(place_options, label="Categories to search", value=["cafe","restaurant"])
198
  search_btn = gr.Button("Search places")
 
202
  map_html_out = gr.HTML(label="Map")
203
  table_out = gr.Dataframe(headers=["name","amenity","lat","lon","address","osm_id"], label="Results Table")
204
 
205
+ update_btn.click(fn=update_states, inputs=country, outputs=[state, state])
 
 
 
206
  search_btn.click(fn=run_search, inputs=[country, state, categories], outputs=[info, table_out, map_html_out, download])
207
 
208
+
209
  if __name__ == "__main__":
210
  demo.launch()