From 1785851b576952528849509a3b1426c2b12418f8 Mon Sep 17 00:00:00 2001 From: Dominik Gresch Date: Thu, 30 Mar 2023 03:41:48 -0400 Subject: [PATCH] Fix resetting of the error state for wx.FileEditor Reset the 'error' change of the file editor when its value changes. Previously, the state would remain as error, which means the value cannot be set. --- traitsui/wx/file_editor.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/traitsui/wx/file_editor.py b/traitsui/wx/file_editor.py index 396a08b34..360f2ed70 100644 --- a/traitsui/wx/file_editor.py +++ b/traitsui/wx/file_editor.py @@ -138,6 +138,7 @@ def update_editor(self): self._no_update = False else: self._file_name.SetValue(self.str_value) + self._reset_error() def show_file_dialog(self, event=None): """Displays the pop-up file dialog.""" @@ -158,6 +159,13 @@ def get_error_control(self): """Returns the editor's control for indicating error status.""" return self._file_name + def _reset_error(self): + """Resets the error state of the editor.""" + if self._error is not None: + self._error = None + self.ui.errors -= 1 + self.set_error_state(False) + # -- Traits Event Handlers ------------------------------------------------ @observe("popup:value") @@ -228,6 +236,7 @@ def _update(self, file_name): file_name = splitext(file_name)[0] self.value = file_name + self._reset_error() except TraitError as excp: pass