Fix browsing for files or directories #201
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #200.
Swaps out the TraitsUI
FileEditor
for the PyfaceFileDialog
andDirectoryDialog
as recommended here. The Pyface versions appear to work more reliably for file selection.A separate button is required for directory selection since there does not appear to be a single dialog that allows selecting both files and directories. This turns out to not be such an issue since separate MM import pathways are used for importing files vs directories, so I've taken advantage of these separate buttons to clarify their different behaviors with separate labels and tooltips.
For more intuitive behavior, the import file browser now accepts multiple paths instead of relying on auto-detecting related image files. The old behavior is still applied when the user selects a single behavior, but selecting multiple files will import only them, without attempting to auto-detect additional files.
The TraitsUI file browser also has an issue with setting the initial path (see enthought/traitsui#1429), whereas the Pyface dialog works. I've added a preference entry to store the last loaded imported path, which is used to initialize the file or directory browser when opening it again.
Another small fix is that clearing the import fields did not clear the underlying import path, which prevented a response when selecting the same file. The button handler now properly resets this path.