Skip to content

Commit

Permalink
pose file is loaded upon "Load" button click
Browse files Browse the repository at this point in the history
  • Loading branch information
niksirbi committed Mar 16, 2024
1 parent 1d795b0 commit 7e98430
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions movement/napari/loader_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, napari_viewer: Viewer, parent=None):
self.create_source_software_widget()
self.create_fps_widget()
self.create_file_path_widget()
self.create_load_button()

def create_source_software_widget(self):
"""Create a combo box for selecting the source software."""
Expand All @@ -66,12 +67,17 @@ def create_file_path_widget(self):
self.file_path_edit = QLineEdit()
self.browse_button = QPushButton("browse")
self.browse_button.clicked.connect(self.open_file_dialog)
self.file_path_edit.returnPressed.connect(self.load_file_from_edit)
# Layout for line edit and button
self.file_path_layout = QHBoxLayout()
self.file_path_layout.addWidget(self.file_path_edit)
self.file_path_layout.addWidget(self.browse_button)
self.layout().addRow("Pose file:", self.file_path_layout)
self.layout().addRow("pose file:", self.file_path_layout)

def create_load_button(self):
"""Create a button to load the file and add layers to the viewer."""
self.load_button = QPushButton("Load")
self.load_button.clicked.connect(lambda: self.load_file())
self.layout().addRow(self.load_button)

def open_file_dialog(self):
dlg = QFileDialog()
Expand All @@ -84,17 +90,14 @@ def open_file_dialog(self):
file_paths = dlg.selectedFiles()
# Set the file path in the line edit
self.file_path_edit.setText(file_paths[0])
# Load the file immediately after selection
self.load_file(file_paths[0])

def load_file_from_edit(self):
# Load the file based on the path in the QLineEdit
file_path = self.file_path_edit.text()
self.load_file(file_path)

def load_file(self, file_path):
def load_file(self):
fps = self.fps_spinbox.value()
source_software = self.source_software_combo.currentText()
file_path = self.file_path_edit.text()
if file_path == "":
logger.warning("No file path specified.")
return
ds = load_poses.from_file(file_path, source_software, fps)

self.data, self.props = ds_to_napari_tracks(ds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


@pytest.fixture
def movement_meta_widget(make_napari_viewer) -> MovementMetaWidget:
def meta_widget(make_napari_viewer) -> MovementMetaWidget:
"""Fixture to expose the MovementMetaWidget for testing.
Simultaneously acts as a smoke test that the widget
Expand Down

0 comments on commit 7e98430

Please sign in to comment.