|
148 | 148 | "TableDisplay({\"x\" : 1, \"y\" : 2})" |
149 | 149 | ] |
150 | 150 | }, |
| 151 | + { |
| 152 | + "cell_type": "markdown", |
| 153 | + "metadata": {}, |
| 154 | + "source": [ |
| 155 | + "## Programmable Table Actions" |
| 156 | + ] |
| 157 | + }, |
151 | 158 | { |
152 | 159 | "cell_type": "code", |
153 | 160 | "execution_count": null, |
|
161 | 168 | "]\n", |
162 | 169 | "display = TableDisplay(mapList4)\n", |
163 | 170 | "\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", |
166 | 178 | "\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", |
169 | 184 | "\n", |
170 | 185 | "display" |
171 | 186 | ] |
|
199 | 214 | }, |
200 | 215 | "outputs": [], |
201 | 216 | "source": [ |
202 | | - "print(\"runDoubleClick fired\")" |
| 217 | + "print(\"runDoubleClick fired\")\n", |
| 218 | + "print(display.details)" |
203 | 219 | ] |
204 | 220 | }, |
205 | 221 | { |
|
312 | 328 | "metadata": {}, |
313 | 329 | "outputs": [], |
314 | 330 | "source": [ |
315 | | - "TableDisplay({'Two Sigma': 'http://twosigma.com', 'BeakerX': 'http://BeakerX'})" |
| 331 | + "TableDisplay({'Two Sigma': 'http://twosigma.com', 'BeakerX': 'http://BeakerX.com'})" |
316 | 332 | ] |
317 | 333 | } |
318 | 334 | ], |
|
333 | 349 | "name": "python", |
334 | 350 | "nbconvert_exporter": "python", |
335 | 351 | "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 |
337 | 366 | } |
338 | 367 | }, |
339 | 368 | "nbformat": 4, |
|
0 commit comments