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 regression in wx version of FileEditor #1993

Merged
merged 1 commit into from
Mar 20, 2023

Conversation

David-Baddeley
Copy link
Contributor

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)

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! This looks good to merge.

@corranwebster corranwebster merged commit 838d8c4 into enthought:main Mar 20, 2023
@greschd
Copy link
Contributor

greschd commented Mar 20, 2023

@corranwebster looking at the change in file_editor, I've noticed it also has a _get_value method:

def _get_value(self):
"""Returns the current file name from the edit control."""
if self.history is not None:
return self.history.value
return self._file_name.GetValue()

I'm wondering if that should be used instead? Or alternatively, if the _get_value method might be unused?

@corranwebster
Copy link
Contributor

Possibly - _get_value matches the pattern for a Traits property getter, but that may be a coincidence. I'd need to dig in a bit, which I don't have time for right now - in the middle of getting Python 3.11 support working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants