Skip to content

Commit

Permalink
Separate the video name and its filepath columns in VideoTablesModel (
Browse files Browse the repository at this point in the history
#2052)

* add option to show video names with filepath

* add doc

* new feature added successfully

* delete unnecessary code

* remove attributes from video object

* Update dataviews.py

* remove all properties

* delete toggle option

* remove video show

* fix the order of the columns

* remove options

* Update sleap/gui/dataviews.py

Co-authored-by: Liezl Maree <[email protected]>

* Update sleap/gui/dataviews.py

Co-authored-by: Liezl Maree <[email protected]>

* use pathlib instead of substrings

* Update dataviews.py

Co-authored-by: Liezl Maree <[email protected]>

* Use Path instead of pathlib.Path
and sort imports and remove unused imports

* Use item.filename instead of getattr

---------

Co-authored-by: Liezl Maree <[email protected]>
  • Loading branch information
7174Andy and roomrys authored Dec 18, 2024
1 parent a6f65fb commit 1eff33d
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions sleap/gui/dataviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@
"""

from qtpy import QtCore, QtWidgets, QtGui

import numpy as np
import os

from operator import itemgetter
from pathlib import Path
from typing import Any, Callable, List, Optional

from typing import Any, Callable, Dict, List, Optional, Type
import numpy as np
from qtpy import QtCore, QtGui, QtWidgets

from sleap.gui.state import GuiState
from sleap.gui.commands import CommandContext
from sleap.gui.color import ColorManager
from sleap.io.dataset import Labels
from sleap.instance import LabeledFrame, Instance
from sleap.gui.state import GuiState
from sleap.instance import LabeledFrame
from sleap.skeleton import Skeleton


Expand Down Expand Up @@ -386,10 +383,25 @@ def getSelectedRowItem(self) -> Any:


class VideosTableModel(GenericTableModel):
properties = ("filename", "frames", "height", "width", "channels")

def item_to_data(self, obj, item):
return {key: getattr(item, key) for key in self.properties}
properties = (
"name",
"filepath",
"frames",
"height",
"width",
"channels",
)

def item_to_data(self, obj, item: "Video"):
data = {}
for property in self.properties:
if property == "name":
data[property] = Path(item.filename).name
elif property == "filepath":
data[property] = str(Path(item.filename).parent)
else:
data[property] = getattr(item, property)
return data


class SkeletonNodesTableModel(GenericTableModel):
Expand Down

0 comments on commit 1eff33d

Please sign in to comment.