-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ui.table press event listener support (#346)
- Depends on my web PR: deephaven/web-client-ui#1857 - Passes through the on_*_press events to IrisGrid - Tested with the snippet from the examples, ensured all events were being printed with the correct information: ```python import deephaven.ui as ui import deephaven.plot.express as dx te = ( ui.table(dx.data.stocks()) .on_row_press(lambda row, data: print(f"Row Press: {row}, {data}")) .on_row_double_press(lambda row, data: print(f"Row Double Press: {row}, {data}")) .on_cell_press( lambda cell_index, data: print(f"Cell Press: {cell_index}, {data}") ) .on_cell_double_press( lambda cell_index, data: print(f"Cell Double Press: {cell_index}, {data}") ) .on_column_press(lambda column: print(f"Column Press: {column}")) .on_column_double_press( lambda column: print(f"Column Double Press: {column}") ) ) ```
- Loading branch information
Showing
13 changed files
with
967 additions
and
494 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
from __future__ import annotations | ||
|
||
from deephaven.table import Table | ||
from ..elements import UITable | ||
from ..types import ( | ||
CellPressCallback, | ||
ColumnPressCallback, | ||
RowPressCallback, | ||
) | ||
|
||
|
||
def table(table: Table) -> UITable: | ||
def table( | ||
table: Table, | ||
*, | ||
on_row_press: RowPressCallback | None = None, | ||
on_row_double_press: RowPressCallback | None = None, | ||
on_cell_press: CellPressCallback | None = None, | ||
on_cell_double_press: CellPressCallback | None = None, | ||
on_column_press: ColumnPressCallback | None = None, | ||
on_column_double_press: ColumnPressCallback | None = None, | ||
) -> UITable: | ||
""" | ||
Add some extra methods to the Table class for giving hints to displaying a table | ||
Customization to how a table is displayed, how it behaves, and listen to UI events. | ||
Args: | ||
table: The table to wrap | ||
on_row_press: The callback function to run when a row is clicked. | ||
The first parameter is the row index, and the second is the row data provided in a dictionary where the | ||
column names are the keys. | ||
on_row_double_press: The callback function to run when a row is double clicked. | ||
The first parameter is the row index, and the second is the row data provided in a dictionary where the | ||
column names are the keys. | ||
on_cell_press: The callback function to run when a cell is clicked. | ||
The first parameter is the cell index, and the second is the row data provided in a dictionary where the | ||
column names are the keys. | ||
on_cell_double_press: The callback function to run when a cell is double clicked. | ||
The first parameter is the cell index, and the second is the row data provided in a dictionary where the | ||
column names are the keys. | ||
on_column_press: The callback function to run when a column is clicked. | ||
The first parameter is the column name. | ||
on_column_double_press: The callback function to run when a column is double clicked. | ||
The first parameter is the column name. | ||
""" | ||
return UITable(table) | ||
props = locals() | ||
del props["table"] | ||
return UITable(table, **props) |
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
Oops, something went wrong.