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 __make_folder_panel(
      self,
      panel,
      value,
      list_fn,
      text,
      help_text,
      actions,
      refresh_action=None,
  ):
      sizer = wx.BoxSizer(wx.HORIZONTAL)
      help_button = wx.Button(panel, label="?", style=wx.BU_EXACTFIT)
      sizer.Add(help_button, 0, wx.ALIGN_CENTER)
      sizer.AddSpacer(2)
      text_static = wx.StaticText(panel, -1, text + ":")
      sizer.Add(text_static, 0, wx.ALIGN_CENTER)
      choices = list(set(list_fn()))
      if value not in choices:
          choices.insert(0, value)
      edit_box = wx.ComboBox(panel, -1, value, choices=choices)
      sizer.Add(edit_box, 1, wx.ALIGN_CENTER)
      sizer.AddSpacer(2)
      browse_bmp = wx.ArtProvider.GetBitmap(
          wx.ART_FOLDER_OPEN, wx.ART_CMN_DIALOG, (16, 16)
      )
      browse_button = wx.BitmapButton(panel, -1, bitmap=browse_bmp)
      browse_button.SetToolTip("Browse for %s folder" % text)
      sizer.Add(browse_button, 0, wx.ALIGN_CENTER)
      sizer.AddSpacer(2)
  
      new_bmp = wx.ArtProvider.GetBitmap(
          wx.ART_NEW_DIR, wx.ART_CMN_DIALOG, (16, 16)
      )
      new_button = wx.BitmapButton(panel, -1, bitmap=new_bmp)
      new_button.SetToolTip("Make a new sub-folder")
      if os.path.isdir(value):
          new_button.Disable()
      sizer.Add(new_button, 0, wx.ALIGN_CENTER)
      if refresh_action is not None:
          refresh_bitmap = wx.ArtProvider.GetBitmap(
              wx.ART_REDO, wx.ART_CMN_DIALOG, (16, 16)
          )
          refresh_button = wx.BitmapButton(
              panel, -1, bitmap=refresh_bitmap
          )
          sizer.AddSpacer(2)
          sizer.Add(refresh_button, 0, wx.ALIGN_CENTER, 1)
          refresh_button.SetToolTip(
              "Refresh the Default Input Folder list"
          )
  
          def on_refresh(event):
              refresh_action()
  
          refresh_button.Bind(wx.EVT_BUTTON, on_refresh)
      panel.SetSizer(sizer)
  
      def on_new_folder(event):
          if os.path.exists(edit_box.GetValue()):
              return
          if (
              wx.MessageBox(
                  "Do you really want to create the %s folder?"
                  % edit_box.GetValue(),
                  style=wx.YES_NO,
              )
              == wx.YES
          ):
              os.makedirs(edit_box.GetValue())
              self.__on_edit_box_change(event, edit_box, text, actions)
  
      def on_edit_box_change(event):
          if os.path.isdir(edit_box.GetValue()):
              new_button.Disable()
              new_button.SetToolTip(
                  "%s is a directory" % edit_box.GetValue()
              )
          else:
              new_button.Enable()
              new_button.SetToolTip(
                  "Press button to create the %s folder"
                  % edit_box.GetValue()
              )
          self.__on_edit_box_change(event, edit_box, text, actions)
          event.Skip()
  
      help_button.Bind(
          wx.EVT_BUTTON, lambda event: self.__on_help(event, help_text)
      )
      panel.Bind(
          wx.EVT_BUTTON,
          lambda event: self.__on_browse(event, edit_box, text),
          browse_button,
      )
      panel.Bind(wx.EVT_TEXT, on_edit_box_change, edit_box)
      panel.Bind(wx.EVT_COMBOBOX, on_edit_box_change, edit_box)
      panel.Bind(wx.EVT_BUTTON, on_new_folder, new_button)
      return edit_box
  
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 6 for calling the PreferencesView obj's underlying member method code with example usage: obj.__make_folder_panel(panel, value, list_fn, text, help_text, actions, refresh_action) and returns: edit_box