- "source": "correspondance = {\n \"Daemon\": DaemonControlWidget,\n \"Group\": GroupControlWidget,\n \"Process\": ProcessControlWidget,\n \"Profile\": ProfileControlWidget,\n}\n\ntoc = ipw.ToggleButtons(\n options=correspondance.keys(),\n value=None,\n orientation=\"vertical\",\n layout=ipw.Layout(width=\"200px\"),\n)\n\n\noutput = ipw.Output()\n\n\ndef update_output(value=None):\n if value is None:\n value = {\"new\": \"Group\"}\n if value[\"new\"] in correspondance:\n with output:\n clear_output()\n try:\n widget = correspondance[value[\"new\"]]()\n except Exception as exc:\n widget = ipw.HTML(\n f'<div class=\"alert alert-danger\" role=\"alert\">'\n f'Failed to open the \"{value[\"new\"]}\" section: {exc}</div>'\n )\n display(widget)\n\n\ntoc.observe(update_output, names=\"value\")\n\ntoc.value = \"Daemon\"\ndisplay(ipw.HBox([toc, output]))"
0 commit comments