class_docstr: View / controller for the preferences that get displayed in the main window
  
      
class_docstr_tok: ["View","\/","controller","for","the","preferences","that","get","displayed","in","the","main","window"]
code: def __on_edit_box_change(self, event, edit_box, text, actions):
      path = edit_box.GetValue()
      error_text = "The %s is not a directory" % text
      if os.path.isdir(path):
          for action in actions:
              action(path)
          items = edit_box.GetItems()
          if len(items) < 1 or items[0] != path:
              ins = edit_box.GetInsertionPoint()
              edit_box.Insert(edit_box.Value, 0, path)
              edit_box.Select(0)
              edit_box.SetInsertionPoint(ins)
              abspath = os.path.abspath(path)
  
              # Remove items that are simply the abspath
              filtered_items = list(
                  filter(
                      lambda item: os.path.abspath(item) != abspath,
                      items,
                  )
              )
              # Clearing the whole edit box also wipes typed text. Specifically remove items which are invalid.
              for i in range(len(items), 0, -1):
                  if items[i - 1] not in filtered_items:
                      edit_box.Delete(i)
                  else:
                      # Prevent exact duplicate entries
                      filtered_items.remove(items[i - 1])
          self.pop_error_text(error_text)
      else:
          self.set_error_text(error_text)
  
imports: import os
  import wx
  from cellprofiler_core.analysis import use_analysis
  from cellprofiler_core.preferences import DEFAULT_IMAGE_DIRECTORY
  from cellprofiler_core.preferences import DEFAULT_IMAGE_FOLDER_HELP
  from cellprofiler_core.preferences import DEFAULT_OUTPUT_DIRECTORY
  from cellprofiler_core.preferences import DEFAULT_OUTPUT_FOLDER_HELP
  from cellprofiler_core.preferences import add_image_directory_listener
  from cellprofiler_core.preferences import add_output_directory_listener
  from cellprofiler_core.preferences import add_progress_callback
  from cellprofiler_core.preferences import fire_image_directory_changed_event
  from cellprofiler_core.preferences import get_default_image_directory
  from cellprofiler_core.preferences import get_default_output_directory
  from cellprofiler_core.preferences import get_recent_files
  from cellprofiler_core.preferences import remove_image_directory_listener
  from cellprofiler_core.preferences import remove_output_directory_listener
  from cellprofiler_core.preferences import set_default_image_directory
  from cellprofiler_core.preferences import set_default_output_directory
  from cellprofiler_core.preferences import set_pixel_size
  from ._progress_watcher import ProgressWatcher
  from ..constants.preferences_view import WELCOME_MESSAGE
  from ..html.utils import rst_to_html_fragment
  from ..htmldialog import HTMLDialog
  from ..utilities.preferences_view import secs_to_timestr
label_desc: Use image node_id 23 for calling the PreferencesView obj's underlying member method code with example usage: obj.__on_edit_box_change(event, edit_box, text, actions) without return types