Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add selected option to tableview get rows method #299

Merged
merged 2 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

setuptools.setup(
name="ttkbootstrap",
version="1.7.7.1",
version="1.7.7.2",
author="Israel Dryer",
author_email="[email protected]",
description="A supercharged theme extension for tkinter that enables on-demand modern flat style themes inspired by Bootstrap.",
Expand Down
11 changes: 10 additions & 1 deletion src/ttkbootstrap/tableview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,9 +1153,13 @@ def get_column(
except ValueError:
return None

def get_rows(self, visible=False, filtered=False) -> List[TableRow]:
def get_rows(self, visible=False, filtered=False, selected=False) -> List[TableRow]:
"""Return a list of TableRow objects.

Return a subset of rows based on optional flags. Only ONE flag can be used
at a time. If more than one flag is set to `True`, then the first flag will
be used to return the data.

Parameters:

visible (bool):
Expand All @@ -1164,6 +1168,9 @@ def get_rows(self, visible=False, filtered=False) -> List[TableRow]:
filtered (bool):
If True, only rows in the filtered dataset will be returned.

selected (bool):
If True, only rows that are currently selected will be returned.

Returns:

List[TableRow]:
Expand All @@ -1173,6 +1180,8 @@ def get_rows(self, visible=False, filtered=False) -> List[TableRow]:
return self._viewdata
elif filtered:
return self._tablerows_filtered
elif selected:
return [row for row in self._viewdata if row.iid in self.view.selection()]
else:
return self._tablerows

Expand Down