Skip to content

Commit

Permalink
improve table doc and fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdraves committed Jun 13, 2018
1 parent 83a7c33 commit 2e62e56
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 16 deletions.
31 changes: 22 additions & 9 deletions doc/groovy/TableAPI.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@
"td4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Programmable Actions\n",
"\n",
"Bind a closure or running a cell to the context menu or double click action on the table."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -357,15 +366,6 @@
"println abc"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Action API\n",
"\n",
"Bind running a cell to the context menu or double click action on the table."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -508,6 +508,19 @@
"nbconverter_exporter": "",
"version": "2.4.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": false,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": false,
"toc_window_display": false
},
"widgets": {
"state": {
"f7d30807-6d2d-414d-b604-fcb0ed748612": {
Expand Down
43 changes: 36 additions & 7 deletions doc/python/TableAPI.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@
"TableDisplay({\"x\" : 1, \"y\" : 2})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Programmable Table Actions"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -161,11 +168,19 @@
"]\n",
"display = TableDisplay(mapList4)\n",
"\n",
"#set what happens on a double click\n",
"display.setDoubleClickAction(lambda row, column, tabledisplay: tabledisplay.values[row].__setitem__(column, sum(tabledisplay.values[row])))\n",
"def dclick(row, column, tabledisplay):\n",
" tabledisplay.values[row][column] = sum(map(int,tabledisplay.values[row]))\n",
"\n",
"display.setDoubleClickAction(dclick)\n",
"\n",
"def negate(row, column, tabledisplay):\n",
" tabledisplay.values[row][column] = -1 * int(tabledisplay.values[row][column])\n",
"\n",
"#add a context menu item\n",
"display.addContextMenuItem(\"negate\", lambda row, column, tabledisplay: tabledisplay.values[row].__setitem__(column, -1 * tabledisplay.values[row][column]))\n",
"def incr(row, column, tabledisplay):\n",
" tabledisplay.values[row][column] = int(tabledisplay.values[row][column]) + 1\n",
"\n",
"display.addContextMenuItem(\"negate\", negate)\n",
"display.addContextMenuItem(\"increment\", incr)\n",
"\n",
"display"
]
Expand Down Expand Up @@ -199,7 +214,8 @@
},
"outputs": [],
"source": [
"print(\"runDoubleClick fired\")"
"print(\"runDoubleClick fired\")\n",
"print(display.details)"
]
},
{
Expand Down Expand Up @@ -312,7 +328,7 @@
"metadata": {},
"outputs": [],
"source": [
"TableDisplay({'Two Sigma': 'http://twosigma.com', 'BeakerX': 'http://BeakerX'})"
"TableDisplay({'Two Sigma': 'http://twosigma.com', 'BeakerX': 'http://BeakerX.com'})"
]
}
],
Expand All @@ -333,7 +349,20 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.6.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": false,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": false,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down

0 comments on commit 2e62e56

Please sign in to comment.