Index: sansview/perspectives/fitting/simfitpage.py
===================================================================
--- sansview/perspectives/fitting/simfitpage.py	(revision 2140e68d04b8406b34c5c4a54bdf7cc8706f5f70)
+++ sansview/perspectives/fitting/simfitpage.py	(revision ac11e4097a0062cd67129b5d46813a436b53703f)
@@ -16,5 +16,4 @@
         self.page = page
         self.fittable_param =[]
-        self.selected_params=[]
         self._set_fittableParam()
         
@@ -51,5 +50,5 @@
         self.page_finder=page_finder
         ## list contaning info to set constraint 
-        ## look like self.constraint_dict[page]=[ model_name, parameter_name, constraint(string)]
+        ## look like self.constraint_dict[page]=FitConstraint(model, page)
         self.constraint_dict={}
         ## item list  self.constraints_list=[combobox1, combobox2,=,textcrtl, button ]
@@ -59,6 +58,4 @@
         ## selected mdoel to fit
         self.model_toFit=[]
-        
-        
         ## draw
         self.define_page_structure()
@@ -99,5 +96,6 @@
         ## making sure all parameters content a constraint
         ## validity of the constraint expression is own by fit engine
-        self._set_constraint()
+        if self.show_constraint.GetValue():
+            self._set_constraint()
         ## get the fit range of very fit problem        
         for page, value in self.page_finder.iteritems():
@@ -262,5 +260,5 @@
             return
         if self.show_constraint.GetValue():
-            self.sizer_couples.Clear(True) 
+            self._hide_constraint()
             self._show_constraint()
             return
@@ -274,5 +272,4 @@
             Show constraint fields
         """
-        flag = False
         if len(self.constraints_list)!= 0:
             nb_fit_param = 0
@@ -281,6 +278,13 @@
             ##Don't add anymore
             if len(self.constraints_list) == nb_fit_param:
-                flag = True
-        if len(self.model_toFit) < 2 or flag:
+                msg= "Cannot add another constraint .Maximum of number "
+                msg += "Parameters name reached %s"%str(nb_fit_param)
+                wx.PostEvent(self.parent.Parent, StatusEvent(status= msg ))
+                self.sizer_couples.Layout()
+                self.sizer2.Layout()
+                self.SetScrollbars(20,20,200,100)
+                return
+            
+        if len(self.model_toFit) < 2 :
             msg= "Select at least 2 model to add constraint "
             wx.PostEvent(self.parent.Parent, StatusEvent(status= msg ))
@@ -300,5 +304,4 @@
         
         ctl2 = wx.TextCtrl(self, -1)
-        ctl2.Bind(wx.EVT_TEXT_ENTER,self._onTextEnter)
         ctl2.Hide()
         
@@ -310,7 +313,5 @@
             ## check if all parameters have been selected for constraint
             ## then do not allow add constraint on parameters
-            if len(value.fittable_param)!= len(value.selected_params):
-                    ## the user can apply constraint only on model select to fit
-                    model_cbox.Append( str(model.name), model)
+            model_cbox.Append( str(model.name), model)
             
            
@@ -337,13 +338,14 @@
         """
             hide buttons related constraint 
-        """
+        """  
         if len(self.constraint_dict)>0:
-            for value in self.constraint_dict.itervalues():
-                value.selected_params=[]
-                param = value.fittable_param## list of parameter name
-                ## reset the constraint to None on fitproblem
-                for item in param:
-                    self.page_finder[value.page].set_model_param(item,None)
-                   
+            for item in self.constraints_list:
+                model = item[0].GetClientData(0)
+                if model  in self.constraint_dict.keys():
+                    page = self.constraint_dict[model].page
+                    self.page_finder[page].clear_model_param()
+                    
+        self.constraint_dict={}
+        self._store_model()
         self.btAdd.Hide()
         self.constraints_list=[]         
@@ -354,5 +356,5 @@
         self.AdjustScrollbars()    
                 
-        
+    
         
     def _on_select_model(self, event):
@@ -370,6 +372,6 @@
         ## insert only fittable paramaters
         for param in param_list:
-            if not param in self.constraint_dict[model].selected_params:
-                param_cbox.Append( str(param), model)
+            param_cbox.Append( str(param), model)
+            
         param_cbox.Show(True)
        
@@ -385,6 +387,5 @@
         model = event.GetClientData()
         param = event.GetString()
-        self.constraint_dict[model].selected_params.append(param)
-        
+      
         length = len(self.constraints_list)
         if length < 1:
@@ -423,5 +424,5 @@
             ctl2 = item[3]
             if ctl2.GetValue().lstrip().rstrip()=="":
-                 msg= " Enter a constraint for %s.%s! "%(model_cbox.GetString(0),
+                 msg= " Enter a constraint for %s.%s! "%(param_cbox.GetClientData(0).name,
                                               param_cbox.GetString(0))           
                  wx.PostEvent(self.parent.Parent, StatusEvent(status= msg ))
@@ -458,7 +459,4 @@
         self.Bind(  wx.EVT_RADIOBUTTON, self._display_constraint,
                          id= self.show_constraint.GetId()    )
-        
-          
-       
         
         sizer_title.Add( wx.StaticText(self,-1," Model") )
@@ -472,10 +470,4 @@
         sizer_title.Add(( 10,10) )
        
-        
-        
-        ## Draw combobox box related to model name and model parameters
-        if self.show_constraint.GetValue():
-            self._fill_sizer_constraint_helper(self.sizer_couples)
-       
         self.btAdd =wx.Button(self,wx.NewId(),'Add')
         self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint,id= self.btAdd.GetId())
@@ -504,13 +496,4 @@
         
         
-    def _onTextEnter(self, event):
-        """
-            callback function for textcrtl
-        """
-        self.btAdd.Show(True)
-        self.sizer2.Layout()
-        self.SetScrollbars(20,20,200,100)
-        self._set_constraint()
-        
     def _set_constraint(self):
         """
@@ -521,11 +504,14 @@
         """
         for item in self.constraints_list:
-            model = item[0].GetClientData(0)
-            param = item[1].GetString(0)
+            
+            model = item[0].GetClientData(item[0].GetCurrentSelection())
+            param = item[1].GetString(item[1].GetCurrentSelection())
             constraint = item[3].GetValue().lstrip().rstrip()
             if model  in self.constraint_dict.keys():
                 page = self.constraint_dict[model].page
-                if constraint != "":
-                    self.page_finder[page].set_model_param(param,constraint)
+                if constraint == "":
+                    constraint = None
+               
+                self.page_finder[page].set_model_param(param,constraint)
         
    
