Skip to content

Instantly share code, notes, and snippets.

@tylere
Created January 26, 2022 18:46
Show Gist options
  • Save tylere/4fe5346907af9ac5ffd69f08cc669def to your computer and use it in GitHub Desktop.
Save tylere/4fe5346907af9ac5ffd69f08cc669def to your computer and use it in GitHub Desktop.
Accordian widget test.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Accordian widget test.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyME0CW+kAIFPbIkyHGQFbYW",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"8cec4245388840568904cbbdc12b694b": {
"model_module": "@jupyter-widgets/controls",
"model_name": "AccordionModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "AccordionView",
"_dom_classes": [],
"_titles": {
"0": "IntSlider Widget",
"1": "Text Widget"
},
"_model_name": "AccordionModel",
"_view_module": "@jupyter-widgets/controls",
"selected_index": 0,
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.5.0",
"box_style": "",
"layout": "IPY_MODEL_bc8f939def7b43fa83ecbb9e97ce3f9d",
"_model_module": "@jupyter-widgets/controls",
"children": [
"IPY_MODEL_e097aa086ef647e78b483451e8c54986",
"IPY_MODEL_c5953f4ebc0a4004b4f80e13d346b46a"
]
}
},
"bc8f939def7b43fa83ecbb9e97ce3f9d": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"e097aa086ef647e78b483451e8c54986": {
"model_module": "@jupyter-widgets/controls",
"model_name": "IntSliderModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "IntSliderView",
"style": "IPY_MODEL_b4adf4f5ceb74fc8bff7ea562b62430e",
"_dom_classes": [],
"description": "",
"step": 1,
"_model_name": "IntSliderModel",
"orientation": "horizontal",
"max": 100,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 0,
"_view_count": null,
"disabled": false,
"_view_module_version": "1.5.0",
"min": 0,
"continuous_update": true,
"readout_format": "d",
"description_tooltip": null,
"readout": true,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_c8958488c39342358619dfae571f2fb6"
}
},
"c5953f4ebc0a4004b4f80e13d346b46a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "TextModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "TextView",
"style": "IPY_MODEL_f42886eb1ddc4d54a32f09a3ac3a2171",
"_dom_classes": [],
"description": "",
"_model_name": "TextModel",
"placeholder": "​",
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": "",
"_view_count": null,
"disabled": false,
"_view_module_version": "1.5.0",
"continuous_update": true,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_3269e37f315d4f588d6a911d668a87b0"
}
},
"b4adf4f5ceb74fc8bff7ea562b62430e": {
"model_module": "@jupyter-widgets/controls",
"model_name": "SliderStyleModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "StyleView",
"handle_color": null,
"_model_name": "SliderStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"c8958488c39342358619dfae571f2fb6": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"f42886eb1ddc4d54a32f09a3ac3a2171": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "StyleView",
"_model_name": "DescriptionStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"_model_module": "@jupyter-widgets/controls"
}
},
"3269e37f315d4f588d6a911d668a87b0": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
}
}
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/tylere/4fe5346907af9ac5ffd69f08cc669def/accordian-widget-test.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"source": [
"import ipywidgets\n",
"from IPython.display import HTML\n",
"\n",
"print(ipywidgets.__version__)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "DPowXs3rslkI",
"outputId": "a4e573ea-8e54-4abb-d553-3b7d581d2b03"
},
"execution_count": 47,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"7.6.5\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"The ipywidgets.Accordian widget does not render the caret icons.\n",
"\n",
"For and example of how it should render with section titles, see: https://ipywidgets.readthedocs.io/en/7.6.5/examples/Widget%20List.html#Accordion"
],
"metadata": {
"id": "Z9w6T7bFhSAo"
}
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"id": "5CzAJMO-hKfd",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 166,
"referenced_widgets": [
"8cec4245388840568904cbbdc12b694b",
"bc8f939def7b43fa83ecbb9e97ce3f9d",
"e097aa086ef647e78b483451e8c54986",
"c5953f4ebc0a4004b4f80e13d346b46a",
"b4adf4f5ceb74fc8bff7ea562b62430e",
"c8958488c39342358619dfae571f2fb6",
"f42886eb1ddc4d54a32f09a3ac3a2171",
"3269e37f315d4f588d6a911d668a87b0"
]
},
"outputId": "4ce12fda-2395-43bc-fe82-d2aef5e48925"
},
"outputs": [
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8cec4245388840568904cbbdc12b694b",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"Accordion(children=(IntSlider(value=0), Text(value='')), _titles={'0': 'IntSlider Widget', '1': 'Text Widget'}…"
]
},
"metadata": {}
}
],
"source": [
"accordion = ipywidgets.Accordion(\n",
" children=[ipywidgets.IntSlider(), ipywidgets.Text()],\n",
" )\n",
"accordion"
]
},
{
"cell_type": "markdown",
"source": [
"Once additional fonts are loaded, it displays correctly."
],
"metadata": {
"id": "GJShiufptAoT"
}
},
{
"cell_type": "code",
"source": [
"display(HTML('''<link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css\"> '''))\n",
"accordion"
],
"metadata": {
"id": "u3LStMhEjpX4",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 166,
"referenced_widgets": [
"8cec4245388840568904cbbdc12b694b",
"bc8f939def7b43fa83ecbb9e97ce3f9d",
"e097aa086ef647e78b483451e8c54986",
"c5953f4ebc0a4004b4f80e13d346b46a",
"b4adf4f5ceb74fc8bff7ea562b62430e",
"c8958488c39342358619dfae571f2fb6",
"f42886eb1ddc4d54a32f09a3ac3a2171",
"3269e37f315d4f588d6a911d668a87b0"
]
},
"outputId": "51fc112c-7808-4337-f662-6e163f992422"
},
"execution_count": 46,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css\"> "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8cec4245388840568904cbbdc12b694b",
"version_minor": 0,
"version_major": 2
},
"text/plain": [
"Accordion(children=(IntSlider(value=0), Text(value='')), _titles={'0': 'IntSlider Widget', '1': 'Text Widget'}…"
]
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"source": [
""
],
"metadata": {
"id": "2rowl1l-sMU0"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment