Skip to content

Commit e3e30ef

Browse files
committed
Refresh section on first tab open (not just revisit)
1 parent c02f9ee commit e3e30ef

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

control.ipynb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@
4848
" name = section_names[index]\n",
4949
" placeholder = placeholders[index]\n",
5050
" widget = section_instances.get(name)\n",
51-
" if widget is not None:\n",
52-
" # Cached: just refresh if the section supports it.\n",
53-
" refresher = getattr(widget, \"refresh\", None)\n",
54-
" if callable(refresher):\n",
55-
" refresher()\n",
56-
" return\n",
57-
" try:\n",
58-
" widget = sections[name]()\n",
59-
" except Exception as exc:\n",
60-
" # Show the error but do NOT cache it: revisiting the tab retries.\n",
61-
" placeholder.children = [\n",
62-
" ipw.HTML(\n",
63-
" f'<div class=\"alert alert-danger\" role=\"alert\">'\n",
64-
" f'Failed to open the \"{name}\" section: {exc}</div>'\n",
65-
" )\n",
66-
" ]\n",
67-
" return\n",
68-
" section_instances[name] = widget\n",
69-
" placeholder.children = [widget]\n",
51+
" if widget is None:\n",
52+
" try:\n",
53+
" widget = sections[name]()\n",
54+
" except Exception as exc:\n",
55+
" # Show the error but do NOT cache it: revisiting the tab retries.\n",
56+
" placeholder.children = [\n",
57+
" ipw.HTML(\n",
58+
" f'<div class=\"alert alert-danger\" role=\"alert\">'\n",
59+
" f'Failed to open the \"{name}\" section: {exc}</div>'\n",
60+
" )\n",
61+
" ]\n",
62+
" return\n",
63+
" section_instances[name] = widget\n",
64+
" placeholder.children = [widget]\n",
65+
"\n",
66+
" # First open and every revisit both probe for fresh data.\n",
67+
" refresher = getattr(widget, \"refresh\", None)\n",
68+
" if callable(refresher):\n",
69+
" refresher()\n",
7070
"\n",
7171
"\n",
7272
"def on_tab_change(change):\n",

0 commit comments

Comments
 (0)