|
48 | 48 | " name = section_names[index]\n", |
49 | 49 | " placeholder = placeholders[index]\n", |
50 | 50 | " 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", |
70 | 70 | "\n", |
71 | 71 | "\n", |
72 | 72 | "def on_tab_change(change):\n", |
|
0 commit comments