-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add menu item for deleting instances beyond frame limit (#1797)
* Add menu item for deleting instances beyond frame limit * Add test function to test the instances returned * typos * Update docstring * Add frame range form * Extend command to use frame range --------- Co-authored-by: Talmo Pereira <[email protected]>
- Loading branch information
1 parent
4728aba
commit 5e23ddc
Showing
5 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
main: | ||
|
||
- name: min_frame_idx | ||
label: Minimum frame index | ||
type: int | ||
range: 1,1000000 | ||
default: 1 | ||
|
||
- name: max_frame_idx | ||
label: Maximum frame index | ||
type: int | ||
range: 1,1000000 | ||
default: 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Frame range dialog.""" | ||
from PySide2 import QtWidgets | ||
from sleap.gui.dialogs.formbuilder import FormBuilderModalDialog | ||
from typing import Optional | ||
|
||
|
||
class FrameRangeDialog(FormBuilderModalDialog): | ||
def __init__(self, max_frame_idx: Optional[int] = None, title: str = "Frame Range"): | ||
|
||
super().__init__(form_name="frame_range_form") | ||
min_frame_idx_field = self.form_widget.fields["min_frame_idx"] | ||
max_frame_idx_field = self.form_widget.fields["max_frame_idx"] | ||
|
||
if max_frame_idx is not None: | ||
min_frame_idx_field.setRange(1, max_frame_idx) | ||
min_frame_idx_field.setValue(1) | ||
|
||
max_frame_idx_field.setRange(1, max_frame_idx) | ||
max_frame_idx_field.setValue(max_frame_idx) | ||
|
||
min_frame_idx_field.valueChanged.connect(self._update_max_frame_range) | ||
max_frame_idx_field.valueChanged.connect(self._update_min_frame_range) | ||
|
||
self.setWindowTitle(title) | ||
|
||
def _update_max_frame_range(self, value): | ||
min_frame_idx_field = self.form_widget.fields["min_frame_idx"] | ||
max_frame_idx_field = self.form_widget.fields["max_frame_idx"] | ||
|
||
max_frame_idx_field.setRange(value, max_frame_idx_field.maximum()) | ||
|
||
def _update_min_frame_range(self, value): | ||
min_frame_idx_field = self.form_widget.fields["min_frame_idx"] | ||
max_frame_idx_field = self.form_widget.fields["max_frame_idx"] | ||
|
||
min_frame_idx_field.setRange(min_frame_idx_field.minimum(), value) | ||
|
||
|
||
if __name__ == "__main__": | ||
app = QtWidgets.QApplication([]) | ||
dialog = FrameRangeDialog(max_frame_idx=100) | ||
print(dialog.get_results()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters