Skip to content

Instantly share code, notes, and snippets.

@bmorris3
Created September 26, 2025 18:17
Show Gist options
  • Select an option

  • Save bmorris3/b3e6d875d9b2439893bd4ef162626046 to your computer and use it in GitHub Desktop.

Select an option

Save bmorris3/b3e6d875d9b2439893bd4ef162626046 to your computer and use it in GitHub Desktop.
Demo relative arrangement of multiple Sidecar widget outputs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "a042789b-289e-4b76-96db-9ecf6afcbeb6",
"metadata": {},
"outputs": [],
"source": [
"from sidecar import Sidecar\n",
"from ipywidgets import widgets\n",
"\n",
"sidecar_1 = Sidecar(\n",
" title='A', \n",
" anchor='split-bottom'\n",
")\n",
"\n",
"with sidecar_1:\n",
" display(widgets.Button(description='A'))\n",
"\n",
"sidecar_2 = Sidecar(\n",
" title='B', \n",
" ref=sidecar_1, # set anchor w.r.t. the first widget \n",
" anchor='split-right',\n",
")\n",
"\n",
"with sidecar_2:\n",
" display(widgets.Button(description='B'))\n",
"\n",
"sidecar_3 = Sidecar(\n",
" title='C', \n",
" ref=sidecar_2, # set anchor w.r.t. the second widget\n",
" anchor='split-bottom',\n",
")\n",
"with sidecar_3:\n",
" display(widgets.Button(description='C'))\n",
"\n",
"sidecar_4 = Sidecar(\n",
" title='D', \n",
" ref=sidecar_3, # set anchor w.r.t. the third widget\n",
" anchor='split-right',\n",
")\n",
"with sidecar_4:\n",
" display(widgets.Button(description='D'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b4177af7-8f56-411b-9148-f8cfc6117df5",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment