Skip to content

Commit

Permalink
Fix up example, add deprecation to on_row_double_press
Browse files Browse the repository at this point in the history
  • Loading branch information
mofojed committed Mar 8, 2024
1 parent b36cd9b commit 630108d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
24 changes: 10 additions & 14 deletions plugins/ui/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -777,20 +777,16 @@ The `ui.table` component has a few events that you can listen to. You can listen
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}")
)
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}"),
)
```

Expand Down
11 changes: 7 additions & 4 deletions plugins/ui/src/deephaven/ui/elements/UITable.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from __future__ import annotations

import collections
import logging
import sys
from warnings import warn
from typing import Callable, Literal, Sequence, Any, cast
from warnings import warn

if sys.version_info < (3, 11):
from typing_extensions import TypedDict, NotRequired
Expand Down Expand Up @@ -458,10 +457,10 @@ def hide_columns(self, columns: str | list[str]) -> "UITable":
"""
raise NotImplementedError()

@DeprecationWarning
def on_row_double_press(self, callback: RowPressCallback) -> "UITable":
"""
Add a callback for when a row is double clicked.
*Deprecated: Use the on_row_double_press keyword arg instead.
Args:
callback: The callback function to run when a row is double clicked.
Expand All @@ -471,7 +470,11 @@ def on_row_double_press(self, callback: RowPressCallback) -> "UITable":
Returns:
A new UITable
"""
warn("Use on_row_double_press arg on ui.table instead", DeprecationWarning)
warn(
"on_row_double_press function is deprecated. Use the on_row_double_press keyword arg instead.",
DeprecationWarning,
stacklevel=2,
)
return self._with_prop("on_row_double_press", callback)

def quick_filter(
Expand Down

0 comments on commit 630108d

Please sign in to comment.