Index: src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py
===================================================================
--- src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py	(revision 82ce1d00568b4ebf4a59963bb6e66418e612d31f)
+++ src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py	(revision 3f7520319806aec1dcc6c9315e3a6982b1fac928)
@@ -1,4 +1,5 @@
 
 
+import os
 import wx
 import wx.lib.newevent
@@ -7,8 +8,8 @@
 from sas.sasgui.guiframe.utils import format_number
 from sas.sasgui.guiframe.events import EVT_SLICER
-from sas.sasgui.guiframe.events import SlicerParameterEvent, SlicerEvent
+from sas.sasgui.guiframe.events import SlicerParameterEvent
 from Plotter2D import ModelPanel2D
 apply_params, EVT_APPLY_PARAMS = wx.lib.newevent.NewEvent()
-auto_save, EVT_AUTO_SAVE = wx.lib.newevent.NewEvent()
+save_files, EVT_AUTO_SAVE = wx.lib.newevent.NewEvent()
 
 FIT_OPTIONS = ["No fitting", "Fitting", "Batch Fitting"]
@@ -18,10 +19,10 @@
                 "BoxInteractorY": "SlabY"}
 
+
 class SlicerParameterPanel(wx.Dialog):
     """
-    Panel class to show the slicer parameters
+    Panel for dynamically changing slicer parameters and apply the same slicer
+    to multiple 2D plot panels
     """
-    # TODO: show units
-    # TODO: order parameters properly
 
     def __init__(self, parent, *args, **kwargs):
@@ -34,4 +35,6 @@
         self.iter = 0
         self.parent = parent
+        self.main_window = parent.parent
+        self.data_panel = self.main_window._data_panel
         self.type = None
         self.listeners = []
@@ -43,7 +46,11 @@
         self.fitting_options = None
         self.type_list = []
+        self.loaded_data = []
+        self.always_on = None
         self.type_select = None
         self.append_name = None
         self.data_list = None
+        self.default_value = ""
+        self.batch_slicer_button = None
         label = "Right-click on 2D plot for slicer options"
         title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT)
@@ -51,10 +58,10 @@
                      flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15)
         # Bindings
-        self.parent.Bind(EVT_SLICER, self.onEVT_SLICER)
-        self.Bind(EVT_SLICER_PARS, self.onParamChange)
+        self.parent.Bind(EVT_SLICER, self.on_evt_slicer)
+        self.Bind(EVT_SLICER_PARS, self.on_param_change)
         self.Bind(EVT_APPLY_PARAMS, self.apply_params_list_and_process)
         self.Bind(EVT_AUTO_SAVE, self.save_files)
 
-    def onEVT_SLICER(self, event):
+    def on_evt_slicer(self, event):
         """
         Process EVT_SLICER events
@@ -94,5 +101,5 @@
                 iy += 1
                 ix = 0
-                if not item in ["count", "errors"]:
+                if item not in ["count", "errors"]:
                     text = wx.StaticText(self, -1, item, style=wx.ALIGN_LEFT)
                     self.bck.Add(text, (iy, ix), (1, 1),
@@ -105,5 +112,5 @@
                     ix = 1
                     ctl.SetValue(format_number(str(params[item])))
-                    self.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter)
+                    self.Bind(wx.EVT_TEXT_ENTER, self.on_text_enter)
                     self.parameters.append([item, ctl])
                     self.bck.Add(ctl, (iy, ix), (1, 1),
@@ -131,8 +138,7 @@
             self.bck.Add(text, (iy, ix), (1, 1),
                          wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
-            self.type_list = ["SectorInteractor", "AnnulusInteractor",
-                              "BoxInteractorX", "BoxInteractorY"]
+            self.type_list = CONVERT_DICT.keys()
             self.type_select = wx.ComboBox(parent=self, choices=self.type_list)
-            self.type_select.Bind(wx.EVT_COMBOBOX, self.onChangeSlicer)
+            self.type_select.Bind(wx.EVT_COMBOBOX, self.on_change_slicer)
             index = self.type_select.FindString(type)
             self.type_select.SetSelection(index)
@@ -158,5 +164,5 @@
                          wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
 
-            # Checkbox for autosaving data
+            # Checkbox to enable saving and fitting options
             iy += 1
             self.auto_save = wx.CheckBox(parent=self, id=wx.NewId(),
@@ -169,5 +175,6 @@
             save_to = "Save files to:"
             save = wx.StaticText(self, -1, save_to, style=wx.ALIGN_LEFT)
-            self.path = wx.DirPickerCtrl(self, id=wx.NewId(), path="",
+            path = os.getcwd()
+            self.path = wx.DirPickerCtrl(self, id=wx.NewId(), path=path,
                                          message=save_to)
             self.path.Enable(False)
@@ -178,13 +185,13 @@
             # Append to file
             iy += 1
-            default_value = ""
-            for key in params:
-                default_value += "_{0}".format(key).split(" [")[0]
-                default_value += "-{:.5f}".format(params[key])
+            self.update_file_append(params)
             append_text = "Append to file name:"
             append = wx.StaticText(self, -1, append_text, style=wx.ALIGN_LEFT)
             self.append_name = wx.TextCtrl(parent=self, id=wx.NewId(),
                                            name="Append to file name:")
-            self.append_name.SetValue(default_value)
+            append_tool_tip = "Files will be saved as <SlicerType><FileName>"
+            append_tool_tip += "<AppendToText>.xml"
+            self.append_name.SetToolTipString(append_tool_tip)
+            self.append_name.SetValue(self.default_value)
             self.append_name.Enable(False)
             self.bck.Add(append, (iy, ix), (1, 1),
@@ -196,5 +203,6 @@
             iy += 1
             fit_text = "Fitting Options:"
-            fit_text_item = wx.StaticText(self, -1, fit_text, style=wx.ALIGN_LEFT)
+            fit_text_item = wx.StaticText(self, -1, fit_text,
+                                          style=wx.ALIGN_LEFT)
             self.bck.Add(fit_text_item, (iy, ix), (1, 1),
                          wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
@@ -221,5 +229,5 @@
         self.parent.GetSizer().Layout()
 
-    def onParamChange(self, evt):
+    def on_param_change(self, evt):
         """
         receive an event end reset value text fields
@@ -233,5 +241,5 @@
                     item[1].Refresh()
 
-    def onTextEnter(self, evt):
+    def on_text_enter(self, evt):
         """
         Parameters have changed
@@ -253,4 +261,7 @@
             # Post parameter event
             # parent here is plotter2D
+            self.update_file_append(params)
+            self.append_name.SetValue(self.default_value)
+            self.append_name.Refresh()
             event = SlicerParameterEvent(type=self.type, params=params)
             wx.PostEvent(self.parent, event)
@@ -258,11 +269,11 @@
     def on_batch_slicer(self, evt=None):
         """
-        Method invoked when batch slicing button is pressed
-        :param evt: Event triggering hide/show of the batch slicer parameters
+        Event triggered when batch slicing button is pressed
+        :param evt: Event triggering the batch slicing
         """
         apply_to_list = []
         spp = self.parent.parent
         params = self.parent.slicer.get_params()
-        type = self.type_select.GetStringSelection()
+        slicer_type = self.type_select.GetStringSelection()
         save = self.auto_save.IsChecked()
         append = self.append_name.GetValue()
@@ -277,13 +288,14 @@
         # Apply slicer type to selected panels
         for item in apply_to_list:
-            self._apply_slicer_to_plot(item, type)
+            self._apply_slicer_to_plot(item, slicer_type)
 
         # Post an event to apply appropriate slicer params to each slicer
+        # Pass all variables, including class variables
         event_params = apply_params(params=params, apply_to_list=apply_to_list,
-                             auto_save=save, append=append, fit=fit,
-                             path=path, type=type)
+                                    auto_save=save, append=append, fit=fit,
+                                    path=path, type=slicer_type)
         wx.PostEvent(self, event_params)
 
-    def onChangeSlicer(self, evt):
+    def on_change_slicer(self, evt):
         """
         Event driven slicer change when self.type_select changes
@@ -292,25 +304,25 @@
         self._apply_slicer_to_plot(self.parent)
 
-    def _apply_slicer_to_plot(self, plot, type=None):
+    def _apply_slicer_to_plot(self, plot, slicer_type=None):
         """
         Apply a slicer to *any* plot window, not just parent window
         :param plot: 2D plot panel to apply a slicer to
-        :param type: The type of slicer to apply to the panel
-        """
-        # Skip redrawing the current plot if no change
-        if self.parent == plot and self.type == type:
+        :param slicer_type: The type of slicer to apply to the panel
+        """
+        # Skip redrawing the current plot if no change in slicer type
+        if self.parent == plot and self.type == slicer_type:
             return
         # Do not draw a slicer on a 1D plot
         if not isinstance(plot, ModelPanel2D):
             return
-        if type is None:
-            type = self.type_select.GetStringSelection()
-        if type == "SectorInteractor":
+        if slicer_type is None:
+            slicer_type = self.type_select.GetStringSelection()
+        if slicer_type == self.type_list[0]:
             plot.onSectorQ(None)
-        elif type == "AnnulusInteractor":
+        elif slicer_type == self.type_list[1]:
             plot.onSectorPhi(None)
-        elif type == "BoxInteractorX":
+        elif slicer_type == self.type_list[2]:
             plot.onBoxavgX(None)
-        elif type == "BoxInteractorY":
+        elif slicer_type == self.type_list[3]:
             plot.onBoxavgY(None)
 
@@ -319,16 +331,12 @@
         Populate the check list from the currently plotted 2D data
         """
-        self.checkme = None
-        main_window = self.parent.parent
-        self.loaded_data = []
-        id = wx.NewId()
         # Iterate over the loaded plots and find all 2D panels
-        for key, value in main_window.plot_panels.iteritems():
+        for key, value in self.main_window.plot_panels.iteritems():
             if isinstance(value, ModelPanel2D):
                 self.loaded_data.append(value.data2D.name)
                 if value.data2D.id == self.parent.data2D.id:
                     # Set current plot panel as uncheckable
-                    self.checkme = self.loaded_data.index(value.data2D.name)
-        self.data_list = wx.CheckListBox(parent=self, id=id,
+                    self.always_on = self.loaded_data.index(value.data2D.name)
+        self.data_list = wx.CheckListBox(parent=self, id=wx.NewId(),
                                          choices=self.loaded_data,
                                          name="Apply Slicer to 2D Plots:")
@@ -341,10 +349,10 @@
         """
         Prevent a checkbox item from being unchecked
-        :param e: Event triggered when a checkbox list item is checked
+        :param evt: Event triggered when a checkbox list item is checked
         """
         if evt is None:
             return
         index = evt.GetSelection()
-        if index == self.checkme:
+        if index == self.always_on:
             self.data_list.Check(index)
 
@@ -355,4 +363,6 @@
                     evt should have attrs plot_list and params
         """
+        if evt is None:
+            return
         # Apply parameter list to each plot as desired
         for item in evt.apply_to_list:
@@ -361,7 +371,7 @@
         # Post an event to save each data set to file
         if evt.auto_save:
-            event = auto_save(append_to_name=evt.append, path=evt.path,
-                              type=evt.type, file_list=evt.apply_to_list,
-                              fit=evt.fit)
+            event = save_files(append_to_name=evt.append, path=evt.path,
+                               type=evt.type, file_list=evt.apply_to_list,
+                               fit=evt.fit)
             wx.PostEvent(self, event)
 
@@ -372,5 +382,7 @@
         """
 
-        # Send the event to the end of the wx event queue
+        # Events triggered after this event pass other events to wx that are
+        # necessary before this event is called. If this is the first time
+        # reaching this event, send it to the end of the wx event queue
         if self.iter == 0:
             clone = evt.Clone()
@@ -383,5 +395,4 @@
         # Start definitions
         writer = Reader()
-        main_window = self.parent.parent
         data_dic = {}
         append = evt.append_to_name
@@ -395,5 +406,5 @@
 
         # Find the correct plots to save
-        for key, plot in main_window.plot_panels.iteritems():
+        for key, plot in self.main_window.plot_panels.iteritems():
             if not hasattr(plot, "data2D"):
                 for item in plot.plots:
@@ -404,5 +415,5 @@
         # Save files as XML
         for item, data1d in data_dic.iteritems():
-            base = ('.').join(item.split('.')[:-1])
+            base = '.'.join(item.split('.')[:-1])
             file_name = base + append + ".xml"
             save_to = evt.path + "\\" + file_name
@@ -413,5 +424,5 @@
         # Load files into GUI
         for item in f_path_list:
-            main_window.load_data(item)
+            self.main_window.load_data(item)
 
         # Send to fitting
@@ -425,18 +436,15 @@
         """
         if fit != FIT_OPTIONS[0] and file_list is not None:
-            # Method variable definitions
-            main_window = self.parent.parent
-            datapanel = main_window._data_panel
             # Set perspective to fitting
-            int = datapanel.perspective_cbox.FindString("Fitting")
-            datapanel.perspective_cbox.SetSelection(int)
-            datapanel._on_perspective_selection(None)
+            int = self.data_panel.perspective_cbox.FindString("Fitting")
+            self.data_panel.perspective_cbox.SetSelection(int)
+            self.data_panel._on_perspective_selection(None)
             # Unselect all loaded data
-            datapanel.selection_cbox.SetValue('Unselect all Data')
-            datapanel._on_selection_type(None)
+            self.data_panel.selection_cbox.SetValue('Unselect all Data')
+            self.data_panel._on_selection_type(None)
             # Click each sliced data file
             for f_name in file_list:
                 num = len(f_name)
-                data_list = datapanel.list_cb_data
+                data_list = self.data_panel.list_cb_data
                 for key in data_list:
                     loaded_key = (key[:num]) if len(key) > num else key
@@ -446,19 +454,18 @@
                         self.check_item_and_children(data_ctrl=data_ctrl,
                                                      check_value=True)
-            # TODO: Batch fitting
             # Switch to batch mode if selected
             if fit == FIT_OPTIONS[2]:
-                datapanel.rb_single_mode.SetValue(False)
-                datapanel.rb_batch_mode.SetValue(True)
-                datapanel.on_batch_mode(None)
+                self.data_panel.rb_single_mode.SetValue(False)
+                self.data_panel.rb_batch_mode.SetValue(True)
+                self.data_panel.on_batch_mode(None)
             else:
-                datapanel.rb_single_mode.SetValue(True)
-                datapanel.rb_batch_mode.SetValue(False)
-                datapanel.on_single_mode(None)
+                self.data_panel.rb_single_mode.SetValue(True)
+                self.data_panel.rb_batch_mode.SetValue(False)
+                self.data_panel.on_single_mode(None)
 
             # Post button click event to send data to fitting
             evt = wx.PyCommandEvent(wx.EVT_BUTTON.typeId,
-                                    datapanel.bt_import.GetId())
-            wx.PostEvent(datapanel, evt)
+                                    self.data_panel.bt_import.GetId())
+            wx.PostEvent(self.data_panel, evt)
 
     def on_auto_save_checked(self, evt=None):
@@ -472,11 +479,20 @@
 
     def check_item_and_children(self, data_ctrl, check_value=True):
-        self.parent.parent._data_panel.tree_ctrl.CheckItem(data_ctrl,
-                                                           check_value)
+        self.data_panel.tree_ctrl.CheckItem(data_ctrl, check_value)
         if data_ctrl.HasChildren():
             if check_value and not data_ctrl.IsExpanded():
-                # Only select children if control is expanded
-                # Always deselect children, regardless (see ticket #259)
                 return
             for child_ctrl in data_ctrl.GetChildren():
-                self.tree_ctrl.CheckItem(child_ctrl, check_value)
+                self.data_panel.CheckItem(child_ctrl, check_value)
+
+    def update_file_append(self, params=None):
+        """
+        Update default_value when any parameters are changed
+        :param params: dictionary of parameters
+        """
+        self.default_value = ""
+        if params is None:
+            params = self.params
+        for key in params:
+            self.default_value += "_{0}".format(key).split(" [")[0]
+            self.default_value += "-{:.2f}".format(params[key])
