Last active
March 6, 2020 20:53
-
-
Save nmearl/39212cc7be8a6b75aabc828116af8f7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import ipyvuetify as v\n", | |
"from traitlets import Unicode, List\n", | |
"\n", | |
"\n", | |
"class TestWidget(v.VuetifyTemplate):\n", | |
" template = Unicode(\"\"\"\n", | |
" <template>\n", | |
" <v-treeview\n", | |
" selectable\n", | |
" item-disabled=\"locked\"\n", | |
" v-model=\"view.selected_items\"\n", | |
" :items=\"view.items\"\n", | |
" v-for=\"view in views\"\n", | |
" ></v-treeview>\n", | |
" </template>\n", | |
" \"\"\").tag(sync=True)\n", | |
" \n", | |
" views = List([\n", | |
" {\n", | |
" 'id': 1,\n", | |
" 'selected_items': [],\n", | |
" 'items': [\n", | |
" {\n", | |
" 'id': 1,\n", | |
" 'name': \"Applications :\",\n", | |
" 'locked': False,\n", | |
" 'children': [\n", | |
" { 'id': 2, 'name': \"Calendar : app\", 'locked': False\n", | |
" },\n", | |
" { 'id': 3, 'name': \"Chrome : app\", 'locked': False\n", | |
" },\n", | |
" { 'id': 4, 'name': \"Webstorm : app\", 'locked': False\n", | |
" },\n", | |
" ]\n", | |
" }\n", | |
" ]\n", | |
" }\n", | |
" ]).tag(sync=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "cba96d4fc7914b22af6c539afa721dcc", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"text/plain": [ | |
"TestWidget(views=[{'id': 1, 'selected_items': [], 'items': [{'id': 1, 'name': 'Applications :', 'locked': Fals…" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"tw = TestWidget()\n", | |
"tw" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"My expectation is that when I begin toggling checkboxes above, the stored dictionary in `views` would update as well. However, if I go ahead and do that and print of the `views` traitlet, the `selected_items` array is empty." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[{'id': 1,\n", | |
" 'selected_items': [],\n", | |
" 'items': [{'id': 1,\n", | |
" 'name': 'Applications :',\n", | |
" 'locked': False,\n", | |
" 'children': [{'id': 2, 'name': 'Calendar : app', 'locked': False},\n", | |
" {'id': 3, 'name': 'Chrome : app', 'locked': False},\n", | |
" {'id': 4, 'name': 'Webstorm : app', 'locked': False}]}]}]" | |
] | |
}, | |
"execution_count": 14, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"tw.views" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"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.7.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment