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

Fix tables performance and empty rows #8

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
6 changes: 4 additions & 2 deletions yagat/frames/impl/base_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, parent, context: AppContext, *args, **kwargs):
)
self.context = context
self.context.add_selection_changed_listener(self.on_selection_changed)
self.context.add_tab_changed_listener(lambda _: self.on_selection_changed(self.context.selection))

self.sheet.set_index_width(300)
self.sheet.pack(fill="both", expand=True)
Expand All @@ -53,8 +54,10 @@ def filter_data_frame(self, df: pd.DataFrame, voltage_levels: list[str]) -> pd.D
pass

def on_selection_changed(self, selection: tuple[Optional[str], Optional[str], Optional[Connection]]):
if self.context.selected_tab != self.tab_name:
return
self.sheet.reset()
if not self.context.network_structure:
self.sheet.data = []
return
df = self.get_data_frame()
voltage_levels = self.filtered_voltage_levels(selection)
Expand All @@ -63,7 +66,6 @@ def on_selection_changed(self, selection: tuple[Optional[str], Optional[str], Op
self.sheet.data = [l.tolist() for l in df.to_numpy()]
self.sheet.set_index_data(df.index.tolist())
self.sheet.set_header_data(df.columns)
self.sheet.set_all_cell_sizes_to_text()

def filtered_voltage_levels(self,
selection: tuple[Optional[str], Optional[str], Optional[Connection]]) -> list[str]:
Expand Down