Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix browsing for files or directories #201

Merged
merged 7 commits into from
Sep 19, 2022
Merged

Fix browsing for files or directories #201

merged 7 commits into from
Sep 19, 2022

Conversation

yoda-vid
Copy link
Collaborator

@yoda-vid yoda-vid commented Sep 19, 2022

Fixes #200.

Swaps out the TraitsUI FileEditor for the Pyface FileDialog and DirectoryDialog 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.

Use the Pyface file dialog in place of the TraitsUI browser to select files, which fixes several issues including the inability to select files in Linux on testing in a newly generated Conda environment.
The file browser for selecting files and/or directories is not working on some platforms and environments. As a workaround, replace the TraitsUI-based file browser with the one from Pyface, which works for selecting files or directories and setting a default path. This browser requires separate controls for selecting files or directories, so a separate directory browser button has been added. Add a preference for storing the last opened import path.
- Add separate labels and tooltips with more detailed instructions to guide users on selecting a file vs a directory to import
- Remove the text field for the selected path for simplicity and clarity since the table shows the parsed paths
Multiplane image setup has automatically searching for matching paths to include images from different channels. Extend the filename parameter to take a sequence of paths, which will be used directly in place of matching additional paths.
Enable selecting multiple files, which may be more intuitive than selecting one image and auto-detecting of matching files. If multiple files are selected, auto-detection is turned off.
The handler for the clear import button overrode the default argument to reset the import path, fixed here by making a separate handler function.
@yoda-vid yoda-vid added bug Something isn't working enhancement New feature or request labels Sep 19, 2022
@yoda-vid yoda-vid added this to the v1.6.0 milestone Sep 19, 2022
@yoda-vid yoda-vid merged commit 6a89d8b into master Sep 19, 2022
@yoda-vid yoda-vid deleted the fix_file_browsing branch September 19, 2022 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Files and/or directories cannot be selected in some environments
1 participant