Skip to content

Commit 2e62e56

Browse files
committed
improve table doc and fix some bugs
1 parent 83a7c33 commit 2e62e56

File tree

2 files changed

+58
-16
lines changed

2 files changed

+58
-16
lines changed

doc/groovy/TableAPI.ipynb

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,15 @@
293293
"td4"
294294
]
295295
},
296+
{
297+
"cell_type": "markdown",
298+
"metadata": {},
299+
"source": [
300+
"## Programmable Actions\n",
301+
"\n",
302+
"Bind a closure or running a cell to the context menu or double click action on the table."
303+
]
304+
},
296305
{
297306
"cell_type": "code",
298307
"execution_count": null,
@@ -357,15 +366,6 @@
357366
"println abc"
358367
]
359368
},
360-
{
361-
"cell_type": "markdown",
362-
"metadata": {},
363-
"source": [
364-
"# Action API\n",
365-
"\n",
366-
"Bind running a cell to the context menu or double click action on the table."
367-
]
368-
},
369369
{
370370
"cell_type": "code",
371371
"execution_count": null,
@@ -508,6 +508,19 @@
508508
"nbconverter_exporter": "",
509509
"version": "2.4.3"
510510
},
511+
"toc": {
512+
"base_numbering": 1,
513+
"nav_menu": {},
514+
"number_sections": false,
515+
"sideBar": false,
516+
"skip_h1_title": false,
517+
"title_cell": "Table of Contents",
518+
"title_sidebar": "Contents",
519+
"toc_cell": false,
520+
"toc_position": {},
521+
"toc_section_display": false,
522+
"toc_window_display": false
523+
},
511524
"widgets": {
512525
"state": {
513526
"f7d30807-6d2d-414d-b604-fcb0ed748612": {

doc/python/TableAPI.ipynb

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@
148148
"TableDisplay({\"x\" : 1, \"y\" : 2})"
149149
]
150150
},
151+
{
152+
"cell_type": "markdown",
153+
"metadata": {},
154+
"source": [
155+
"## Programmable Table Actions"
156+
]
157+
},
151158
{
152159
"cell_type": "code",
153160
"execution_count": null,
@@ -161,11 +168,19 @@
161168
"]\n",
162169
"display = TableDisplay(mapList4)\n",
163170
"\n",
164-
"#set what happens on a double click\n",
165-
"display.setDoubleClickAction(lambda row, column, tabledisplay: tabledisplay.values[row].__setitem__(column, sum(tabledisplay.values[row])))\n",
171+
"def dclick(row, column, tabledisplay):\n",
172+
" tabledisplay.values[row][column] = sum(map(int,tabledisplay.values[row]))\n",
173+
"\n",
174+
"display.setDoubleClickAction(dclick)\n",
175+
"\n",
176+
"def negate(row, column, tabledisplay):\n",
177+
" tabledisplay.values[row][column] = -1 * int(tabledisplay.values[row][column])\n",
166178
"\n",
167-
"#add a context menu item\n",
168-
"display.addContextMenuItem(\"negate\", lambda row, column, tabledisplay: tabledisplay.values[row].__setitem__(column, -1 * tabledisplay.values[row][column]))\n",
179+
"def incr(row, column, tabledisplay):\n",
180+
" tabledisplay.values[row][column] = int(tabledisplay.values[row][column]) + 1\n",
181+
"\n",
182+
"display.addContextMenuItem(\"negate\", negate)\n",
183+
"display.addContextMenuItem(\"increment\", incr)\n",
169184
"\n",
170185
"display"
171186
]
@@ -199,7 +214,8 @@
199214
},
200215
"outputs": [],
201216
"source": [
202-
"print(\"runDoubleClick fired\")"
217+
"print(\"runDoubleClick fired\")\n",
218+
"print(display.details)"
203219
]
204220
},
205221
{
@@ -312,7 +328,7 @@
312328
"metadata": {},
313329
"outputs": [],
314330
"source": [
315-
"TableDisplay({'Two Sigma': 'http://twosigma.com', 'BeakerX': 'http://BeakerX'})"
331+
"TableDisplay({'Two Sigma': 'http://twosigma.com', 'BeakerX': 'http://BeakerX.com'})"
316332
]
317333
}
318334
],
@@ -333,7 +349,20 @@
333349
"name": "python",
334350
"nbconvert_exporter": "python",
335351
"pygments_lexer": "ipython3",
336-
"version": "3.6.4"
352+
"version": "3.6.5"
353+
},
354+
"toc": {
355+
"base_numbering": 1,
356+
"nav_menu": {},
357+
"number_sections": false,
358+
"sideBar": false,
359+
"skip_h1_title": false,
360+
"title_cell": "Table of Contents",
361+
"title_sidebar": "Contents",
362+
"toc_cell": false,
363+
"toc_position": {},
364+
"toc_section_display": false,
365+
"toc_window_display": false
337366
}
338367
},
339368
"nbformat": 4,

0 commit comments

Comments
 (0)