Repository navigation
DirectoryFileSelector: add a single-select option - #275
Felix-Mallinder merged 3 commits into
Conversation
SimosManiatis
left a comment
There was a problem hiding this comment.
1.PY-T01 Python_Engine/Python/tests/test_bhom_tkinter_ui.py:466 — test_directory_file_selector_single_select never tries to take a second file. It checks selectmode, checks that select_all_button exists only for the default, calls selection_set(0), and expects [tmp_path / "a.aps"]. That passes, and it would still pass if a second click left both files selected. The docstring also says Deselect All is hidden; the test never looks for deselect_all_button.
selection_set is the wrong call for this assertion. Setting index 0 and then index 1 leaves (0, 1) selected even when selectmode is browse. Drive it the way the browse binding does: selection_clear(0, tk.END), then selection_set on the second row, then _on_submit(), and assert selected_files is only that one path. Assert deselect_all_button is absent on the single selector. On the default selector, select both rows and assert submit returns both, so the default path stays covered.
2.PY-D02 directory_file_selector.py:17 — multi_select is a new public argument and it defaults to True. init has no Args section, so that default is only in the signature. The module docstring on line 1 still describes the window as multiple-file only.
Fix??: document multi_select on init ("Defaults to True. When False, the list keeps a single file and hides Select All / Deselect All.") and update the module docstring to the same behaviour.
3.PY-F06 — both changed files have no BHoM copyright header. Add the standard header, end year 2026, above the module docstring.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Python review — Python_Toolkit PR #275
Scope: develop...fcdc1f5 (directory_file_selector.py, test_bhom_tkinter_ui.py). Re-review after "Address review: strengthen single-select test, document multi_select".
Automated: black would reformat both files; pylint directory_file_selector.py 8.62/10; test_directory_file_selector_single_select passed. check_docstrings.py and check_file_names.py clean (PY-D05, PY-F03, PY-F07).
Full suite and coverage were not run cause i did not have the Python_Toolkit 3.10 environment , so this used Python 3.12. CI on the PR is green.
The copyright job only checks C#, so it does not cover these files.
The earlier test and docstring comments are addressed.
The single-select test now selects both rows on the default selector, asserts both paths come back, checks that Select All and Deselect All are absent when multi_select=False, then clears, selects the second row, and asserts submit returns only b.aps. That test passed. multi_select is documented on __init__ (default True, single file, buttons hidden), and the module docstring now describes one-or-more selection.
But :(
- PY-F06
directory_file_selector.py:1andtest_bhom_tkinter_ui.py:1— both files are in this diff and still have no BHoM copyright header. The selector starts at the module docstring; the test starts atfrom __future__ import annotations.
Fix: put the standard header at the top of each file, end year 2026, above the module docstring and above from __future__.
Also i found these
-
PY-D02
directory_file_selector.py:32,selection_labeldefaults to"file(s)", and the newArgsentry does not say so.
maybe addDefaults to "file(s)". -
PY-F01
directory_file_selector.py:3, black wants the new module docstring's closing quotes on their own line. The rest of the black diff (tab indentation in the test file, quote style, missing final newline) is already ondevelop.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
SimosManiatis
left a comment
There was a problem hiding this comment.
Python review — Python_Toolkit PR #275
The single-select behaviour, the test, the multi_select docs, the selection_label default, and the docstring quotes are in place.
Python copyright headers stay off this PR. That rule lives in the Python review skill, which is not on develop, and the CI copyright check does not cover Python. This can merge ahead of that skill.
|
@BHoMBot check required |
|
@Felix-Mallinder to confirm, the following actions are now queued:
There are 19 requests in the queue ahead of you. |
|
@BHoMBot check ready-to-merge |
|
@Felix-Mallinder to confirm, the following actions are now queued:
There are 2 requests in the queue ahead of you. |
|
@BHoMBot check ready-to-merge |
|
@Felix-Mallinder to confirm, the following actions are now queued:
There are 6 requests in the queue ahead of you. |
Issues addressed by this PR
Closes #274
Adds
multi_select: bool = TruetoDirectoryFileSelector. Withmulti_select=Falsethe list allows one file only (selectmode=tk.BROWSE) and Select All / Deselect All are hidden. The default keeps today's behaviour, so existing callers are unchanged.Test files
Python_Engine/Python/tests/test_bhom_tkinter_ui.py::test_directory_file_selector_single_selectChangelog
multi_selectargument toDirectoryFileSelectorso tools that need one file can allow a single selection only.🤖 Generated with Claude Code