Skip to content

Commit

Permalink
Added support for tooltip overwrite and tooltip test
Browse files Browse the repository at this point in the history
  • Loading branch information
minhtuevo committed Jan 7, 2025
1 parent e7f361b commit 1f3031a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 10 additions & 4 deletions fiftyone/operators/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,11 +1906,17 @@ def add_row_action(
self.row_actions.append(row_action)
return row_action

def add_tooltip(self, row, column, value, **kwargs):
def add_tooltip(self, row, column, value, overwrite=True, **kwargs):
if (row, column) in self._tooltip_map:
raise ValueError(
f"Tooltip for row '{row}' and column '{column}' already exists"
)
if overwrite:
tooltip = self._tooltip_map[(row, column)]
tooltip.value = value
tooltip.__dict__.update(kwargs)
return tooltip
else:
raise ValueError(
f"Tooltip for row '{row}' and column '{column}' already exists"
)

tooltip = Tooltip(row=row, column=column, value=value, **kwargs)
self.tooltips.append(tooltip)
Expand Down
5 changes: 4 additions & 1 deletion tests/unittests/operators/tableview_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ def test_table_view_basic(self):
table.add_tooltip(1, 2, "Tooltip 2")

with self.assertRaises(ValueError):
table.add_tooltip(1, 1, "Tooltip 3")
table.add_tooltip(1, 1, "Tooltip 3", overwrite=False)

table.add_tooltip(1, 1, "Tooltip 3")

0 comments on commit 1f3031a

Please sign in to comment.