Skip to content

DirectoryFileSelector: add a single-select option - #275

Merged
Felix-Mallinder merged 3 commits into
developfrom
Python_Toolkit-#274-DirectoryFileSelectorSingleSelect
Nov 24, 2026
Merged

Felix-Mallinder merged 3 commits into
developfrom
Python_Toolkit-#274-DirectoryFileSelectorSingleSelect

Conversation

@Felix-Mallinder

Copy link
Copy Markdown
Contributor

Issues addressed by this PR

Closes #274

Adds multi_select: bool = True to DirectoryFileSelector. With multi_select=False the 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_select

Changelog

  • Added a multi_select argument to DirectoryFileSelector so tools that need one file can allow a single selection only.

🤖 Generated with Claude Code

@SimosManiatis SimosManiatis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@Felix-Mallinder Felix-Mallinder self-assigned this Nov 23, 2026
@Felix-Mallinder Felix-Mallinder added the type:feature New capability or enhancement label Nov 23, 2026

@SimosManiatis SimosManiatis left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :(

  1. PY-F06 directory_file_selector.py:1 and test_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 at from __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

  1. PY-D02 directory_file_selector.py:32 , selection_label defaults to "file(s)", and the new Args entry does not say so.
    maybe add Defaults to "file(s)".

  2. 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 on develop.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@SimosManiatis SimosManiatis left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Felix-Mallinder

Copy link
Copy Markdown
Contributor Author

@BHoMBot check required

@bhombot-ci

bhombot-ci Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Felix-Mallinder to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check core
  • check null-handling
  • check serialisation
  • check versioning
  • check installer

There are 19 requests in the queue ahead of you.

@Felix-Mallinder

Copy link
Copy Markdown
Contributor Author

@BHoMBot check ready-to-merge

@bhombot-ci

bhombot-ci Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Felix-Mallinder to confirm, the following actions are now queued:

  • check ready-to-merge

There are 2 requests in the queue ahead of you.

@Felix-Mallinder

Copy link
Copy Markdown
Contributor Author

@BHoMBot check ready-to-merge

@bhombot-ci

bhombot-ci Bot commented Nov 24, 2026

Copy link
Copy Markdown

@Felix-Mallinder to confirm, the following actions are now queued:

  • check ready-to-merge

There are 6 requests in the queue ahead of you.

@Felix-Mallinder
Felix-Mallinder merged commit 5d44a0c into develop Nov 24, 2026
19 checks passed
@Felix-Mallinder
Felix-Mallinder deleted the Python_Toolkit-#274-DirectoryFileSelectorSingleSelect branch November 24, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New capability or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DirectoryFileSelector: add a single-select option

2 participants