enthought / enthought/traitsui

Unable to select directory in FileEditor on Windows

Open
#1,685 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

The `allow_dir` parameter for the `FileEditor` widget works for selecting a directory on macOS, but I could not get it to allow directory selection on Windows. Here's a minimal example based on the [`FileEditor` demo](https://github.com/enthought/traitsui/blob/master/traitsui/examples/demo/Standard_Editors/FileEditor_demo.py), with the addition of the directory parameter:

```Python
from traits.api import HasTraits, File
from traitsui.api import Item, Group, View, FileEditor

class FileEditorDemo(HasTraits):
file_name = File()
file_group = Group(
Item('file_name', style='simple', label='Simple', id='simple_file',
editor=FileEditor(allow_dir=True)),
)
traits_view = View(file_group)

demo = FileEditorDemo()
if __name__ == '__main__':
demo.configure_traits()
```

On macOS, I can select a folder and press Open, which closes the dialog and populates the text field with the path to the folder. On Windows, selecting a folder and pressing Open simply enters the folder. To select an item and close the dialog, I must select a file rather than a folder. A workaround is to select a file in the folder and then manually delete the file name from the path.

Tested on TraitsUI 7.2.1, Traits 6.2.0, PyFace 7.3.0, and PyQt5 5.15.4. I also went back to TraitsUI 6.0.0, Traits 5.0.0, PyFace 6.0.0, and PyQt5 5.12 but saw the same behavior.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.