Skip to content

Commit

Permalink
fix regression with file editor (#1993)
Browse files Browse the repository at this point in the history
File (and directory editors) are broken in current head (and the last couple of releases). See traceback below.

```
Traceback (most recent call last):
  File "/Users/david/dev/traitsui/traitsui/wx/file_editor.py", line 147, in show_file_dialog
    dlg = self._create_file_dialog()
  File "/Users/david/dev/traitsui/traitsui/wx/file_editor.py", line 209, in _create_file_dialog
    default_path=self._file_name.text(),
AttributeError: 'TextCtrl' object has no attribute 'text'
```

This looks like it can be traced to #1829, which seems to have copy-pasted the `FileDialog` creation code verbatim from the QT version into the wx version. Replacing the `.text()` call with the wx equivalent `.GetValue()` seems to fix things. Thought I'd submit a PR directly seeing as I had a simple fix, but happy to create an issue instead/as well if desired.

**Checklist**
- [ ] Add a news fragment if this PR is news-worthy for end users. (see docs/releases/README.rst)
  • Loading branch information
David-Baddeley authored Mar 20, 2023
1 parent ce8b285 commit 838d8c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion traitsui/wx/directory_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _create_file_dialog(self):
"""Creates the correct type of file dialog."""
dlg = DirectoryDialog(
parent=self.get_control_widget(),
default_path=self._file_name.text(),
default_path=self._file_name.GetValue(),
)
return dlg

Expand Down
2 changes: 1 addition & 1 deletion traitsui/wx/file_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _create_file_dialog(self):

dlg = FileDialog(
parent=self.get_control_widget(),
default_path=self._file_name.text(),
default_path=self._file_name.GetValue(),
action="save" if self.factory.dialog_style == "save as" else "open",
wildcard=wildcard,
)
Expand Down

0 comments on commit 838d8c4

Please sign in to comment.