Index: sansguiframe/src/sans/guiframe/data_panel.py
===================================================================
--- sansguiframe/src/sans/guiframe/data_panel.py	(revision 38226d266fdb5abe984cca9678478e3097ddd057)
+++ sansguiframe/src/sans/guiframe/data_panel.py	(revision 5e5704d5237b5071e2300dab8f6b4e8853525c14)
@@ -156,5 +156,24 @@
         self.data_menu = None
         self.popUpMenu = None
-       
+        self.plot3d_id = None
+        self.editmask_id = None
+        # Default attr
+        self.vbox  = None
+        self.sizer1 = None
+        self.sizer2 = None
+        self.sizer3 = None
+        self.sizer4 = None
+        self.sizer5 = None
+        self.selection_cbox = None
+        self.bt_add = None
+        self.bt_remove = None
+        self.bt_import = None
+        self.bt_append_plot = None
+        self.bt_plot = None
+        self.bt_freeze = None
+        self.cb_plotpanel = None
+        self.rb_single_mode = None
+        self.rb_batch_mode = None
+
         self.owner = None
         self.do_layout()
@@ -176,4 +195,5 @@
     def disable_app_combo(self, enable):
         """
+        Disable app combo box
         """
         self.perspective_cbox.Enable(enable)
@@ -217,6 +237,6 @@
             self.selection_cbox.Append(str(option))
         self.selection_cbox.SetValue('Select all Data')
-        wx.EVT_COMBOBOX(self.selection_cbox,-1, self._on_selection_type)
-        self.sizer5.AddMany([(select_txt,0, wx.ALL,5),
+        wx.EVT_COMBOBOX(self.selection_cbox, -1, self._on_selection_type)
+        self.sizer5.AddMany([(select_txt, 0, wx.ALL,5), 
                             (self.selection_cbox,0, wx.ALL,5)])
         self.enable_selection()
@@ -235,6 +255,6 @@
         option = self.selection_cbox.GetString(pos)
         for item in self.list_cb_data.values():
-            data_ctrl, _, _, _, _, _, _, _= item
-            data_id, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl) 
+            data_ctrl, _, _, _, _, _, _, _ = item
+            _, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl) 
             if option == 'Select all Data':
                 self.tree_ctrl.CheckItem(data_ctrl, True) 
@@ -266,6 +286,4 @@
         Layout widgets related to buttons
         """
-        w, _ = self.GetSize()
-       
         self.bt_add = wx.Button(self, wx.NewId(), "Load Data", 
                                 size=(BUTTON_WIDTH, -1))
@@ -278,5 +296,5 @@
         self.bt_import = wx.Button(self, wx.NewId(), "Send To",
                                     size=(BUTTON_WIDTH, -1))
-        self.bt_import.SetToolTipString("Send set of Data to active perspective")
+        self.bt_import.SetToolTipString("Send Data set to active perspective")
         wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import)
         self.perspective_cbox = wx.ComboBox(self, -1,
@@ -289,5 +307,6 @@
         self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To",
                                         size=(BUTTON_WIDTH, -1))
-        self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel")
+        self.bt_append_plot.SetToolTipString( \
+                                "Plot the selected data in the active panel")
         wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot)
         
@@ -311,5 +330,5 @@
             self.cb_plotpanel = wx.ComboBox(self, -1, 
                                             style=wx.CB_READONLY|wx.CB_SORT)
-        wx.EVT_COMBOBOX(self.cb_plotpanel,-1, self._on_plot_selection)
+        wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection)
         self.cb_plotpanel.Disable()
 
@@ -323,9 +342,11 @@
                              ((10, 10)),
                              (self.bt_append_plot),
-                             (self.cb_plotpanel, wx.EXPAND|wx.ADJUST_MINSIZE, 5),
+                             (self.cb_plotpanel, 
+                              wx.EXPAND|wx.ADJUST_MINSIZE, 5),
                              ((5, 5)),
                              ((5, 5)),
                              (self.bt_import, 0, wx.EXPAND|wx.RIGHT, 5),
-                             (self.perspective_cbox, wx.EXPAND|wx.ADJUST_MINSIZE, 5),
+                             (self.perspective_cbox, 
+                              wx.EXPAND|wx.ADJUST_MINSIZE, 5),
                              ((10, 10)),
                              (self.sizer4),
@@ -365,6 +386,5 @@
         """
         if self.parent is not None:
-                wx.PostEvent(self.parent, 
-                             NewBatchEvent(enable=False))
+            wx.PostEvent(self.parent, NewBatchEvent(enable=False))
        
     def on_batch_mode(self, event):
@@ -386,5 +406,5 @@
         id, _, _ = self.FindFocus().GetSelection().GetData()
         data_list, theory_list = \
-                            self.parent._data_manager.get_by_id(id_list=[id])
+                        self.parent.get_data_manager().get_by_id(id_list=[id])
         if data_list:
             data = data_list.values()[0]
@@ -483,9 +503,9 @@
         wx.EVT_MENU(self, id, self.on_save_as)
     
-        self.quickplot_id = wx.NewId()
+        quickplot_id = wx.NewId()
         name = "Quick Plot"
         msg = "Plot the current Data"
-        self.data_menu.Append(self.quickplot_id, name, msg)
-        wx.EVT_MENU(self, self.quickplot_id, self.on_quick_plot)
+        self.data_menu.Append(quickplot_id, name, msg)
+        wx.EVT_MENU(self, quickplot_id, self.on_quick_plot)
         
         self.plot3d_id = wx.NewId()
@@ -522,5 +542,5 @@
                             self.tree_ctrl_theory.GetSelection().GetData()
             data_list, _ = \
-                            self.parent._data_manager.get_by_id(id_list=[id])
+                            self.parent.get_data_manager().get_by_id(id_list=[id])
         except:
             return
@@ -535,10 +555,10 @@
         Allow Editing Data
         """
-        selection = event.GetSelection()
+        #selection = event.GetSelection()
         is_data = True
         try:
             id, data_class_name, _ = self.tree_ctrl.GetSelection().GetData()
             data_list, _ = \
-                            self.parent._data_manager.get_by_id(id_list=[id])
+                            self.parent.get_data_manager().get_by_id(id_list=[id])
             if not data_list:
                 is_data = False
@@ -565,4 +585,5 @@
     def on_check_item(self, event):
         """
+        On check item
         """
         item = event.GetItem()
@@ -613,7 +634,7 @@
                     if state_id not in self.list_cb_data:
                         #new state
-                        data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0,
-                                                           data_name, ct_type=1, 
-                                             data=(data_id, data_class, state_id))
+                        data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,
+                                        0, data_name, ct_type=1, 
+                                        data=(data_id, data_class, state_id))
                         data_c.Check(True)
                         d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info')
@@ -632,8 +653,7 @@
                             if len(process_str)>20:
                                 process_str = process_str[:20]+' [...]'
-                            i_t_c = self.tree_ctrl.AppendItem(d_p_c,
-                                                              process_str)
-                        theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES")
-                       
+                            self.tree_ctrl.AppendItem(d_p_c, process_str)
+                        theory_child = self.tree_ctrl.AppendItem(data_c, 
+                                                                 "THEORIES")
                         self.list_cb_data[state_id] = [data_c, 
                                                        d_i_c,
@@ -641,16 +661,19 @@
                                                        r_n_c,
                                                        i_c_c,
-                                                        p_c_c,
-                                                         d_p_c,
-                                                         theory_child]
+                                                       p_c_c,
+                                                       d_p_c,
+                                                       theory_child]
                     else:
                         data_ctrl_list =  self.list_cb_data[state_id]
                         #This state is already display replace it contains
-                        data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list
+                        data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, t_c \
+                                = data_ctrl_list
                         self.tree_ctrl.SetItemText(data_c, data_name) 
                         temp = (data_id, data_class, state_id)
                         self.tree_ctrl.SetItemPyData(data_c, temp) 
-                        self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class)
-                        self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % s_path) 
+                        self.tree_ctrl.SetItemText(i_c_c, 
+                                                   'Type: %s' % data_class)
+                        self.tree_ctrl.SetItemText(p_c_c, 
+                                                   'Path: %s' % s_path) 
                         self.tree_ctrl.DeleteChildren(d_p_c) 
                         for process in process_list:
@@ -672,5 +695,5 @@
         """
         for item in self.list_cb_data.values():
-            data_ctrl, _, _, _, _, _,_, _ = item
+            data_ctrl, _, _, _, _, _, _, _ = item
             self.tree_ctrl.CheckItem(data_ctrl, False) 
         self.enable_append()
@@ -696,5 +719,5 @@
             tree = self.tree_ctrl
         if root is not None:
-             wx.CallAfter(self.append_theory_helper, tree=tree, root=root, 
+            wx.CallAfter(self.append_theory_helper, tree=tree, root=root, 
                                        state_id=state_id, 
                                        theory_list=theory_list)
@@ -703,4 +726,5 @@
     def append_theory_helper(self, tree, root, state_id, theory_list):
         """
+        Append theory helper
         """
         if state_id in self.list_cb_theory.keys():
@@ -709,5 +733,5 @@
 
             for theory_id, item in theory_list.iteritems():
-                theory_data, theory_state = item
+                theory_data, _ = item
                 if theory_data is None:
                     name = "Unknown"
@@ -732,6 +756,5 @@
                     
                     for process in theory_data.process:
-                        i_t_c = tree.AppendItem(t_p_c,
-                                                          process.__str__())
+                        tree.AppendItem(t_p_c, process.__str__())
                     theory_list_ctrl[theory_id] = [t_child, 
                                                    i_c_c, 
@@ -745,6 +768,5 @@
                     tree.DeleteChildren(t_p_c) 
                     for process in theory_data.process:
-                        i_t_c = tree.AppendItem(t_p_c,
-                                                          process.__str__())
+                        tree.AppendItem(t_p_c, process.__str__())
               
         else:
@@ -769,6 +791,5 @@
                     
                     for process in theory_data.process:
-                        i_t_c = tree.AppendItem(t_p_c,
-                                                          process.__str__())
+                        tree.AppendItem(t_p_c, process.__str__())
             
                     theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c]
@@ -780,4 +801,5 @@
     def set_data_helper(self):
         """
+        Set data helper
         """
         data_to_plot = []
@@ -793,5 +815,5 @@
            
         for theory_dict in self.list_cb_theory.values():
-            for key, value in theory_dict.iteritems():
+            for _, value in theory_dict.iteritems():
                 item, _, _ = value
                 if item.IsChecked():
@@ -804,7 +826,8 @@
     def remove_by_id(self, id):
         """
+        Remove_dat by id
         """
         for item in self.list_cb_data.values():
-            data_c, _, _, _, _, _,  _, theory_child = item
+            data_c, _, _, _, _, _,  _, _ = item
             data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c) 
             if id == data_id:
@@ -820,6 +843,7 @@
         """
         if error is not None or str(error).strip() != "":
-            dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File',
-                                wx.OK | wx.ICON_EXCLAMATION)
+            dial = wx.MessageDialog(self.parent, str(error), 
+                                    'Error Loading File',
+                                    wx.OK | wx.ICON_EXCLAMATION)
             dial.ShowModal()  
         
@@ -848,5 +872,5 @@
         #remove  data from treectrl
         for d_key, item in self.list_cb_data.iteritems():
-            data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, t_c = item
+            data_c, _, _, _,  _, _, _, _ = item
             if data_c.IsChecked():
                 self.tree_ctrl.Delete(data_c)
@@ -856,5 +880,5 @@
                     theory_to_remove += theory_list_ctrl.keys()
         # Remove theory from treectrl       
-        for t_key, theory_dict in self.list_cb_theory.iteritems():
+        for _, theory_dict in self.list_cb_theory.iteritems():
             for  key, value in theory_dict.iteritems():
                 item, _, _ = value
@@ -957,5 +981,5 @@
         from the combobox of the current panel
         """
-        name = event.name
+        #name = event.name
         caption = event.caption
         if self.cb_plotpanel is not None:
@@ -969,5 +993,5 @@
         set the plot panel on focus
         """
-        for key, value in self.parent.plot_panels.iteritems():
+        for _, value in self.parent.plot_panels.iteritems():
             name_plot_panel = str(value.window_caption)
             if name_plot_panel not in self.cb_plotpanel.GetItems():
@@ -1087,6 +1111,6 @@
             self.cb_plotpanel.Disable()
         elif self.cb_plotpanel.GetCount() <= 0:
-                self.cb_plotpanel.Disable()
-                self.bt_append_plot.Disable()
+            self.cb_plotpanel.Disable()
+            self.bt_append_plot.Disable()
         else:
             self.bt_append_plot.Enable()
@@ -1183,5 +1207,5 @@
         iy = 0
         ix = 0
-        data_count = 0
+        #data_count = 0
         for (data_name, in_use, sub_menu) in range(len(data_list)):
             if in_use == True:
@@ -1189,5 +1213,5 @@
                 ctrl_in_use = wx.StaticBox(self, -1, " is used by ")
                 plug_name = str(sub_menu) + "\n"
-                ctrl_sub_menu = wx.StaticBox(self, -1, plug_name)
+                #ctrl_sub_menu = wx.StaticBox(self, -1, plug_name)
                 self.sizer.Add(ctrl_name, (iy, ix),
                            (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
@@ -1232,4 +1256,7 @@
             
 class DataFrame(wx.Frame):
+    """
+    Data Frame
+    """
     ## Internal name for the AUI manager
     window_name = "Data Panel"
@@ -1240,9 +1267,9 @@
     ALWAYS_ON = True
     
-    def __init__(self, parent=None, owner=None, manager=None,size=(300, 800),
-                         list_of_perspective=[],list=[], *args, **kwds):
+    def __init__(self, parent=None, owner=None, manager=None, size=(300, 800),
+                         list_of_perspective=[], list=[], *args, **kwds):
         kwds['size'] = size
         kwds['id'] = -1
-        kwds['title']= "Loaded Data"
+        kwds['title'] = "Loaded Data"
         wx.Frame.__init__(self, parent=parent, *args, **kwds)
         self.parent = parent
@@ -1261,9 +1288,12 @@
    
     
-from dataFitting import Data1D
-from dataFitting import Data2D, Theory1D
-from data_state import DataState
-import sys
+from sans.guiframe.dataFitting import Data1D
+from sans.guiframe.dataFitting import Data2D, Theory1D
+from sans.guiframe.data_state import DataState
+
 class State():
+    """
+    DataPanel State
+    """
     def __init__(self):
         self.msg = ""
@@ -1275,4 +1305,7 @@
     
 def set_data_state(data=None, path=None, theory=None, state=None):
+    """
+    Set data state
+    """
     dstate = DataState(data=data)
     dstate.set_path(path=path)
@@ -1280,34 +1313,28 @@
   
     return dstate
-"""'
-data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"), 
-            ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"), 
-            ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"), 
-            ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"), 
-            ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")] 
-"""      
+    
 if __name__ == "__main__":
     
     app = wx.App()
     try:
-        list_of_perspective = [('perspective2', False), ('perspective1', True)]
-        data_list = {}
+        #list_of_perspective = [('perspective2', False), ('perspective1', True)]
+        data_list1 = {}
         # state 1
-        data = Data2D()
-        data.name = "data2"
-        data.id = 1
-        data.append_empty_process()
-        process = data.process[len(data.process)-1]
-        process.data = "07/01/2010"
+        data1 = Data2D()
+        data1.name = "data2"
+        data1.id = 1
+        data1.append_empty_process()
+        process1 = data1.process[len(data1.process)-1]
+        process1.data = "07/01/2010"
         theory = Data2D()
         theory.id = 34
         theory.name = "theory1"
         path = "path1"
-        state = State()
-        data_list['1']=set_data_state(data, path,theory, state)
+        state1 = State()
+        data_list1['1'] = set_data_state(data1, path,theory, state1)
         #state 2
-        data = Data2D()
-        data.name = "data2"
-        data.id = 76
+        data1 = Data2D()
+        data1.name = "data2"
+        data1.id = 76
         theory = Data2D()
         theory.id = 78
@@ -1315,36 +1342,36 @@
         path = "path2"
         #state3
-        state = State()
-        data_list['2']=set_data_state(data, path,theory, state)
-        data = Data1D()
-        data.id = 3
-        data.name = "data2"
+        state1 = State()
+        data_list1['2'] = set_data_state(data1, path,theory, state1)
+        data1 = Data1D()
+        data1.id = 3
+        data1.name = "data2"
         theory = Theory1D()
         theory.name = "CoreShell"
         theory.id = 4
         theory.append_empty_process()
-        process = theory.process[len(theory.process)-1]
-        process.description = "this is my description"
+        process1 = theory.process[len(theory.process)-1]
+        process1.description = "this is my description"
         path = "path3"
-        data.append_empty_process()
-        process = data.process[len(data.process)-1]
-        process.data = "07/22/2010"
-        data_list['4']=set_data_state(data, path,theory, state)
+        data1.append_empty_process()
+        process1 = data1.process[len(data1.process)-1]
+        process1.data = "07/22/2010"
+        data_list1['4'] = set_data_state(data1, path,theory, state1)
         #state 4
         temp_data_list = {}
-        data.name = "data5 erasing data2"
-        temp_data_list['4'] = set_data_state(data, path,theory, state)
+        data1.name = "data5 erasing data2"
+        temp_data_list['4'] = set_data_state(data1, path,theory, state1)
         #state 5
-        data = Data2D()
-        data.name = "data3"
-        data.id = 5
-        data.append_empty_process()
-        process = data.process[len(data.process)-1]
-        process.data = "07/01/2010"
+        data1 = Data2D()
+        data1.name = "data3"
+        data1.id = 5
+        data1.append_empty_process()
+        process1 = data.process[len(data1.process)-1]
+        process1.data = "07/01/2010"
         theory = Theory1D()
         theory.name = "Cylinder"
         path = "path2"
-        state = State()
-        dstate= set_data_state(data, path,theory, state)
+        state1 = State()
+        dstate= set_data_state(data, path,theory, state1)
         theory = Theory1D()
         theory.id = 6
@@ -1355,19 +1382,19 @@
         theory.name = "CoreShell replacing coreshell in data3"
         dstate.set_theory(theory)
-        data_list['3'] = dstate
+        data_list1['3'] = dstate
         #state 6
-        data_list['6']=set_data_state(None, path,theory, state)
-        data_list['6']=set_data_state(theory=theory, state=None)
+        data_list1['6'] = set_data_state(None, path, theory, state1)
+        data_list1['6'] = set_data_state(theory=theory, state=None)
         theory = Theory1D()
         theory.id = 7
-        data_list['6']=set_data_state(theory=theory, state=None)
-        data_list['7']=set_data_state(theory=theory, state=None)
-        window = DataFrame(list=data_list)
-        window.load_data_list(list=data_list)
+        data_list1['6'] = set_data_state(theory=theory, state=None)
+        data_list1['7'] = set_data_state(theory=theory, state=None)
+        window = DataFrame(list=data_list1)
+        window.load_data_list(list=data_list1)
         window.Show(True)
         window.load_data_list(list=temp_data_list)
     except:
         #raise
-        print "error",sys.exc_value
+        print "error", sys.exc_value
         
     app.MainLoop()  
