Skip to content

Commit

Permalink
Layout docks in a tab configuration (instead of stacked) (#1289)
Browse files Browse the repository at this point in the history
* Add tab with to docks (and use `self.model` in table)

* Use `self.model_type` in `create_models`
  • Loading branch information
roomrys authored Apr 27, 2023
1 parent b5aab0e commit d7c9505
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
6 changes: 3 additions & 3 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,9 @@ def _create_dock_windows(self):
"""Create dock windows and connect them to GUI."""

self.videos_dock = VideosDock(self)
self.skeleton_dock = SkeletonDock(self)
self.suggestions_dock = SuggestionsDock(self)
self.instances_dock = InstancesDock(self)
self.skeleton_dock = SkeletonDock(self, tab_with=self.videos_dock)
self.suggestions_dock = SuggestionsDock(self, tab_with=self.videos_dock)
self.instances_dock = InstancesDock(self, tab_with=self.videos_dock)

# Bring videos tab forward.
self.videos_dock.wgt_layout.parent().parent().raise_()
Expand Down
33 changes: 13 additions & 20 deletions sleap/gui/widgets/docks.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __init__(
)

def create_models(self) -> VideosTableModel:
self.model = VideosTableModel(
self.model = self.model_type(
items=self.main_window.labels.videos, context=self.main_window.commands
)
return self.model
Expand All @@ -177,9 +177,7 @@ def create_tables(self) -> GenericTableView:
state=main_window.state,
row_name="video",
is_activatable=True,
model=VideosTableModel(
items=main_window.labels.videos, context=main_window.commands
),
model=self.model,
ellipsis_left=True,
)

Expand Down Expand Up @@ -407,15 +405,16 @@ def lay_everything_out(self):
class SuggestionsDock(DockWidget):
"""Dock widget for displaying suggestions."""

def __init__(self, main_window: QMainWindow):
def __init__(self, main_window: QMainWindow, tab_with: Optional[QLayout] = None):
super().__init__(
name="Labeling Suggestions",
main_window=main_window,
model_type=SuggestionsTableModel,
tab_with=tab_with,
)

def create_models(self) -> SuggestionsTableModel:
self.model = SuggestionsTableModel(
self.model = self.model_type(
items=self.main_window.labels.suggestions, context=self.main_window.commands
)
return self.model
Expand All @@ -424,10 +423,7 @@ def create_tables(self) -> GenericTableView:
self.table = GenericTableView(
state=self.main_window.state,
is_sortable=True,
model=SuggestionsTableModel(
items=self.main_window.labels.suggestions,
context=self.main_window.commands,
),
model=self.model,
)

# Connect some actions to the table
Expand Down Expand Up @@ -525,16 +521,16 @@ def create_table_edit_buttons(self) -> QWidget:
class InstancesDock(DockWidget):
"""Dock widget for displaying instances."""

def __init__(
self,
main_window: QMainWindow,
):
def __init__(self, main_window: QMainWindow, tab_with: Optional[QLayout] = None):
super().__init__(
name="Instances", main_window=main_window, model_type=LabeledFrameTableModel
name="Instances",
main_window=main_window,
model_type=LabeledFrameTableModel,
tab_with=tab_with,
)

def create_models(self) -> LabeledFrameTableModel:
self.model = LabeledFrameTableModel(
self.model = self.model_type(
items=self.main_window.state["labeled_frame"],
context=self.main_window.commands,
)
Expand All @@ -545,10 +541,7 @@ def create_tables(self) -> GenericTableView:
state=self.main_window.state,
row_name="instance",
name_prefix="",
model=LabeledFrameTableModel(
items=self.main_window.state["labeled_frame"],
context=self.main_window.commands,
),
model=self.model,
)
return self.table

Expand Down

0 comments on commit d7c9505

Please sign in to comment.