Skip to content

Commit

Permalink
add toggle for showing/unshowing code
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutterley committed May 5, 2024
1 parent 24b80de commit e63f569
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions demo/voila_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,24 @@
" atl06_rsps.leaflet.redraw()\n",
"\n",
"# show code action\n",
"global code06_is_shown\n",
"code06_is_shown = False\n",
"def on_show_code06_clicked(b):\n",
" global url_textbox, atl06_parms\n",
" global url_textbox, atl06_parms, code06_is_shown\n",
" with show_code06_output:\n",
" display.clear_output()\n",
" print(f'icesat2.init()')\n",
" # validate boolean entries to be in title case\n",
" atl06_json = json.dumps(atl06_parms, indent=4)\n",
" atl06_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl06_json)\n",
" print('parms = ', atl06_json, sep='')\n",
" print('gdf = icesat2.atl06p(parms)')\n",
" code06_is_shown = not code06_is_shown\n",
" if code06_is_shown:\n",
" print(f'icesat2.init()')\n",
" # validate boolean entries to be in title case\n",
" atl06_json = json.dumps(atl06_parms, indent=4)\n",
" atl06_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl06_json)\n",
" print('parms = ', atl06_json, sep='')\n",
" print('gdf = icesat2.atl06p(parms)')\n",
" show_code06_button.description = \"Unshow Code\"\n",
" else:\n",
" show_code06_button.description = \"Show Code\"\n",
"\n",
"\n",
"# Download ATL06-SR data as geojson\n",
"display.display(download_output)\n",
Expand Down Expand Up @@ -449,7 +457,7 @@
"# display buttons\n",
"display.display(run_button)\n",
"display.display(SRwidgets.HBox([download_atl06_button, SRwidgets.file_format]))\n",
"display.display(SRwidgets.HBox([show_code06_button, show_code06_output]))"
"display.display(show_code06_button, show_code06_output)"
]
},
{
Expand Down Expand Up @@ -639,17 +647,23 @@
"m.add_selected_callback(click_handler)\n",
"\n",
"# show code action\n",
"global code03_is_shown\n",
"code03_is_shown = False\n",
"def on_show_code03_clicked(b):\n",
" global url_textbox, atl03_parms\n",
" global url_textbox, atl03_parms, code03_is_shown\n",
" with show_code03_output:\n",
" display.clear_output()\n",
" print(f'icesat2.init()')\n",
" # validate boolean entries to be in title case\n",
" atl03_json = json.dumps(atl03_parms, indent=4)\n",
" atl03_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl03_json)\n",
" print('parms = ', atl03_json, sep='')\n",
" print('gdf = icesat2.atl03sp(parms)')\n",
"\n",
" code03_is_shown = not code03_is_shown\n",
" if code03_is_shown:\n",
" print(f'icesat2.init()')\n",
" # validate boolean entries to be in title case\n",
" atl03_json = json.dumps(atl03_parms, indent=4)\n",
" atl03_json = re.sub(r'\\b(true|false)', lambda m: m.group(1).title(), atl03_json)\n",
" print('parms = ', atl03_json, sep='')\n",
" print('gdf = icesat2.atl03sp(parms)')\n",
" show_code03_button.description = \"Unshow Code\"\n",
" else:\n",
" show_code03_button.description = \"Show Code\"\n",
"\n",
"def on_atl03_download_clicked(e=None):\n",
" download_file(atl03_rsps, SRwidgets.atl03_filename,\n",
Expand Down

0 comments on commit e63f569

Please sign in to comment.