Index: invariantview/perspectives/invariant/invariant_details.py
===================================================================
--- invariantview/perspectives/invariant/invariant_details.py	(revision 277fad8096790e12e5261ff730c0e28c6cb029dd)
+++ invariantview/perspectives/invariant/invariant_details.py	(revision d0cc0bbcd6f7d8af8bc2bb071bbac3da14085536)
@@ -9,22 +9,92 @@
 RECTANGLE_WIDTH  = 400.0  
 RECTANGLE_HEIGHT = 20
-RECTANGLE_SCALE  = 0.0001
-DEFAULT_QSTAR = 1.0
 #Invariant panel size 
 _BOX_WIDTH = 76
-_BOX_PERCENT_WIDTH = 100  
+
+#scale to use for a bar of value zero
+RECTANGLE_SCALE  = 0.0001
+DEFAULT_QSTAR = 1.0  
   
 if sys.platform.count("win32")>0:
     _STATICBOX_WIDTH = 450
     PANEL_WIDTH = 500
-    PANEL_HEIGHT = 700
+    PANEL_HEIGHT = 430
     FONT_VARIANT = 0
 else:
     _STATICBOX_WIDTH = 480
     PANEL_WIDTH = 530
-    PANEL_HEIGHT = 700
+    PANEL_HEIGHT = 430
     FONT_VARIANT = 1
     
+  
     
+class InvariantContainer(wx.Object):
+    def __init__(self):
+        #invariant at low range
+        self.qstar_low = 0.0
+        #invariant at low range error
+        self.qstar_low_err = 0.0
+        #invariant 
+        self.qstar = 0.0
+        #invariant error
+        self.qstar_err = 0.0
+        #invariant at high range
+        self.qstar_high = 0.0
+        #invariant at high range error
+        self.qstar_high_err = 0.0
+        #invariant total
+        self.qstar_total = None
+        #invariant error
+        self.qstar_total_err = None
+        #scale
+        self.qstar_low_percent = 0.0
+        self.qstar_high_percent = 0.0
+        self.qstar_percent = 0.0
+        # warning message
+        self.existing_warning = False
+        self.warning_msg = "No Details on calculations available...\n"
+        
+    def compute_percentage(self):
+        """
+            Compute percentage of each invariant
+        """
+        if self.qstar_total is not None and self.qstar_total != 0:
+            #compute invariant percentage
+            if self.qstar is None:
+                self.qstar = 0.0
+            self.qstar_percent = self.qstar/self.qstar_total
+            #compute low q invariant percentage
+            if self.qstar_low is None:
+                self.qstar_low = 0.0
+            self.qstar_low_percent = self.qstar_low/self.qstar_total
+            #compute high q invariant percentage
+            if self.qstar_high is None:
+                self.qstar_high = 0.0
+            self.qstar_high_percent = self.qstar_high/self.qstar_total
+        self.check_values()
+   
+    def check_values(self):
+        """
+            check the validity if invariant
+        """
+        #warning to the user when the extrapolated invariant is greater than %5
+        if self.qstar_low_percent >= 0.05:
+            self.existing_warning = True
+            self.warning_msg += "Extrapolated contribution at Low Q is higher "
+            self.warning_msg += "than 5% of the invariant.\n"
+        if self.qstar_high_percent >= 0.05:
+            self.existing_warning = True
+            self.warning_msg += "Extrapolated contribution at High Q is higher "
+            self.warning_msg += "than 5% of the invariant.\n"
+        if self.qstar_low_percent + self.qstar_high_percent >= 0.05:
+            self.existing_warning = True
+            self.warning_msg += "The sum of all extrapolated contributions is higher "
+            self.warning_msg += "than 5% of the invariant.\n"
+            
+        if self.existing_warning:
+            self.warning_msg += "The calculations are likely to be unreliable!\n"
+        else:
+            self.warning_msg = "No Details on calculations available...\n"
+            
 class InvariantDetailsPanel(wx.Dialog):
     """
@@ -32,7 +102,7 @@
     """
     def __init__(self, parent=None, id=-1, qstar_container=None, title="",
-                 size=(PANEL_WIDTH, 450)):
+                 size=(PANEL_WIDTH, PANEL_HEIGHT)):
         wx.Dialog.__init__(self, parent, id=id, title=title, size=size)
-       
+        
         #Font size 
         self.SetWindowVariant(variant=FONT_VARIANT)
@@ -40,14 +110,18 @@
         #self.qstar_container
         self.qstar_container = qstar_container
-        self.compute_scale()
         #warning message
-        self.warning_msg = ""
+        self.warning_msg = self.qstar_container.warning_msg
+   
         #Define scale of each bar
-        low_inv_scale = self.qstar_container.qstar_low_scale
-        self.low_scale = self.check_scale(scale=low_inv_scale, scale_name="Low")
-        inv_scale = self.qstar_container.qstar_scale
-        self.inv_scale = self.check_scale(scale=inv_scale, scale_name="Inv")
-        high_inv_scale = self.qstar_container.qstar_high_scale
-        self.high_scale = self.check_scale(scale=high_inv_scale, scale_name="High")
+        self.low_inv_percent = self.qstar_container.qstar_low_percent
+        self.low_scale = self.get_scale(percentage=self.low_inv_percent,
+                                         scale_name="Extrapolated at Low Q")
+        self.inv_percent = self.qstar_container.qstar_percent
+        self.inv_scale = self.get_scale(percentage=self.inv_percent, 
+                                            scale_name="Inv in Q range")
+        self.high_inv_percent = self.qstar_container.qstar_high_percent
+        self.high_scale = self.get_scale(percentage=self.high_inv_percent,
+                                         scale_name="Extrapolated at High Q")
+        
         #Default color the extrapolation bar is grey
         self.extrapolation_color_low = wx.Colour(169,  169, 168, 128)
@@ -58,5 +132,5 @@
         self._do_layout()
         self.set_values()
- 
+   
     def _define_structure(self):
         """
@@ -68,7 +142,12 @@
         chart_box = wx.StaticBox(self, -1, "Invariant Chart")
         self.chart_sizer = wx.StaticBoxSizer(chart_box, wx.VERTICAL)
-        self.chart_sizer.SetMinSize((PANEL_WIDTH - 50,-1))
+        self.chart_sizer.SetMinSize((PANEL_WIDTH - 50,100))
         #Sizer related to invariant values
         self.invariant_sizer =  wx.GridBagSizer(4, 4)
+        invariant_box = wx.StaticBox(self, -1, "Numerical Values")
+        self.invariant_box_sizer = wx.StaticBoxSizer(invariant_box,
+                                                      wx.HORIZONTAL)
+
+        self.invariant_box_sizer.SetMinSize((PANEL_WIDTH - 50,-1))
         #Sizer related to warning message
         warning_box = wx.StaticBox(self, -1, "Warning")
@@ -91,5 +170,5 @@
         """
         uncertainty = "+/-" 
-        unit_invariant = '[1/cm 1/A]'
+        unit_invariant = '[1/(cm * A)]'
      
         invariant_txt = wx.StaticText(self, -1, 'Invariant')
@@ -115,5 +194,5 @@
    
         #Invariant low
-        iy = 1
+        iy = 0
         ix = 0 
         self.invariant_sizer.Add(invariant_low_txt, (iy, ix), (1,1),
@@ -164,5 +243,6 @@
         ix += 1
         self.invariant_sizer.Add(invariant_high_units_txt
-                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
+                         ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        self.invariant_box_sizer.Add(self.invariant_sizer, 0, wx.TOP|wx.BOTTOM, 10)  
        
     def _layout_warning(self):
@@ -172,5 +252,6 @@
         #Warning [string]
         self.warning_msg_txt = wx.StaticText(self, -1,self.warning_msg)  
-        self.warning_msg_txt.SetForegroundColour('red') 
+        if self.qstar_container.existing_warning:
+            self.warning_msg_txt.SetForegroundColour('red') 
         self.warning_sizer.AddMany([(self.warning_msg_txt, 0,
                                      wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)])
@@ -196,6 +277,6 @@
         self._layout_warning()
         self._layout_button()
-        self.main_sizer.AddMany([(self.chart_sizer, 1, wx.ALL, 10),
-                                 (self.invariant_sizer, 0, wx.ALL, 10),
+        self.main_sizer.AddMany([(self.chart_sizer, 0, wx.ALL, 10),
+                                 ( self.invariant_box_sizer, 0, wx.ALL, 10),
                                   (self.warning_sizer, 0, wx.ALL, 10),
                                   (self.button_sizer, 0, wx.ALL, 10)])
@@ -213,46 +294,18 @@
         self.invariant_high_tcl.SetValue(format_number(self.qstar_container.qstar_high))
         self.invariant_high_err_tcl.SetValue(format_number(self.qstar_container.qstar_high_err)) 
-    
-    def compute_scale(self):
-        """
-            Compute scale
-        """
-        qstar_total = self.qstar_container.qstar_total
-        if qstar_total is None:
-            qstar_total = DEFAULT_QSTAR
-        #compute the percentage of invariant
-        inv = self.qstar_container.qstar
-        if inv is None:
-            inv = 0.0 
-        inv_scale = inv/qstar_total
-        self.qstar_container.qstar_scale = inv_scale
-        #compute the percentage of low q invariant
-        inv_low = self.qstar_container.qstar_low
-        if inv_low is None:
-            inv_low = 0.0 
-        inv_scale = inv_low/qstar_total
-        self.qstar_container.qstar_low_scale = inv_scale
-        #compute the percentage of high q invariant
-        inv_high = self.qstar_container.qstar_high
-        if inv_high is None:
-            inv_high = 0.0 
-        inv_scale = inv_high/qstar_total
-        self.qstar_container.qstar_high_scale = inv_scale
-       
-    def check_scale(self, scale, scale_name='scale'):
-        """
-            Check scale receive in this panel. i
+
+    def get_scale(self, percentage, scale_name='scale'):
+        """
+            Check scale receive in this panel. 
         """
         try: 
-            if scale is None:
-                scale = 0.0
-            scale = float(scale)
-            if  scale == 0.0:
-                scale = RECTANGLE_SCALE
+            if percentage is None or percentage == 0.0:
+                 percentage = RECTANGLE_SCALE
+            percentage = float(percentage) 
         except:
-            scale = RECTANGLE_SCALE
+            percentage = RECTANGLE_SCALE
             self.warning_msg += "Receive an invalid scale for %s\n"
-            self.warning_msg += "check this value : %s\n"%(str(scale_name),str(scale))
-        return scale
+            self.warning_msg += "check this value : %s\n"%(str(scale_name),str(percentage))
+        return  percentage
     
     def set_color_bar(self):
@@ -263,11 +316,7 @@
         if self.low_scale >= 0.05:
             self.extrapolation_color_low = wx.Colour(255,  0, 0, 128)
-            self.warning_msg += "The value of invariant extrapolated at \n"
-            self.warning_msg += "low q range is %s percent \n"%(str(self.low_scale*100))
         if self.high_scale >= 0.05:
             self.extrapolation_color_high = wx.Colour(255,  0, 0, 128)
-            self.warning_msg += "The value of invariant extrapolated at \n"
-            self.warning_msg += "high q range is %s percent \n"%(str(self.high_scale*100))
-    
+            
     def on_close(self, event):
         """
@@ -295,9 +344,9 @@
         path.AddRectangle(-RECTANGLE_WIDTH/2,-RECTANGLE_HEIGHT/2,
                           RECTANGLE_WIDTH/2,RECTANGLE_HEIGHT/2)
-        x_origine = 50
+        x_origine = 20
         y_origine = 15
         #Draw low rectangle
         gc.PushState()        
-        label = "Low"
+        label = "Q* At Low-Q"
         PathFunc = gc.DrawPath
         w, h = gc.GetTextExtent(label)
@@ -309,4 +358,8 @@
         gc.SetPen(wx.Pen("black", 1))
         gc.SetBrush(wx.Brush(self.extrapolation_color_low))
+        low_percent = format_number(self.low_inv_percent*100)+ '%'
+        x_center = 20
+        y_center = -h
+        gc.DrawText(low_percent, x_center, y_center)
         # Increase width by self.low_scale
         gc.Scale(self.low_scale, 1.0) 
@@ -316,5 +369,5 @@
         gc.PushState()    # save it again
         y_origine += 20         
-        gc.DrawText("Inv", x_origine, y_origine)
+        gc.DrawText("Q* In range", x_origine, y_origine)
         # offset to the lower part of the window
         x_center = x_origine + RECTANGLE_WIDTH * self.inv_scale/2 + w + 10
@@ -324,4 +377,8 @@
         gc.SetBrush(wx.Brush(wx.Colour(67,  208,  128, 128))) 
         # Increase width by self.inv_scale
+        inv_percent = format_number(self.inv_percent*100)+ '%'
+        x_center = 20 
+        y_center = -h
+        gc.DrawText(inv_percent, x_center, y_center)
         gc.Scale(self.inv_scale, 1.0)    
         gc.DrawPath(path)
@@ -331,5 +388,5 @@
         gc.PushState() 
         y_origine += 20 
-        gc.DrawText("High", x_origine, y_origine) 
+        gc.DrawText("Q* At High-Q", x_origine, y_origine) 
         #define the position of the new rectangle
         x_center = x_origine + RECTANGLE_WIDTH * self.high_scale/2 + w + 10
@@ -338,4 +395,9 @@
         gc.SetBrush(wx.Brush(self.extrapolation_color_high)) 
         # increase scale by self.high_scale
+        high_percent = format_number(self.high_inv_percent*100)+ '%'
+        x_center = 20
+        y_center = -h
+        gc.DrawText(high_percent, x_center, y_center)
+       
         gc.Scale(self.high_scale, 1.0)  
         gc.DrawPath(path)
@@ -348,7 +410,6 @@
         self.container = qstar_container
         if self.container is None:
-            from invariant_panel import InvariantContainer
             self.container = InvariantContainer()
-            self.container.qstar_total = 1
+            self.container.qstar_total = 1.0
             self.container.qstar = 0.75
             self.container.qstar_low = 0.60
@@ -362,11 +423,10 @@
 class InvariantDetailsTest(wx.Frame):
     def __init__(self, parent, qstar_container=None, *args, **kwds):
-        kwds["size"]= (PANEL_WIDTH , 450)
+        kwds["size"]= (PANEL_WIDTH , PANEL_HEIGHT)
         wx.Frame.__init__(self, parent, *args, **kwds)
         self.container = qstar_container
         if self.container is None:
-            from invariant_panel import InvariantContainer
             self.container = InvariantContainer()
-            self.container.qstar_total = 1
+            self.container.qstar_total = 1.0
             self.container.qstar = 0.75
             self.container.qstar_low = 0.60
@@ -381,12 +441,14 @@
 if __name__ =="__main__":
     app  = wx.App()
-    from invariant_panel import InvariantContainer
+
     container = InvariantContainer()
-    container.qstar_total = 1
-    container.qstar = 0.75
-    container.qstar_low = 0.60
-    container.qstar_high = 0.0049
+    container.qstar_total = 100.0
+    container.qstar = 15.0
+    container.qstar_low = 0.001
+    container.qstar_high = 100.0
+    container.compute_percentage()
+   
     window = InvariantDetailsTest(parent=None, id=-1,qstar_container=container,
-                                    title="Source Editor")
+                                    title="Invariant Details")
     window.Show()
     app.MainLoop()
Index: invariantview/perspectives/invariant/invariant_panel.py
===================================================================
--- invariantview/perspectives/invariant/invariant_panel.py	(revision f338d3bf1895f475ab0b62ef31fd80ed2535ed8d)
+++ invariantview/perspectives/invariant/invariant_panel.py	(revision d0cc0bbcd6f7d8af8bc2bb071bbac3da14085536)
@@ -10,5 +10,5 @@
 from sans.guiframe.utils import format_number, check_float
 from sans.guicomm.events import NewPlotEvent, StatusEvent
-from invariant_details import InvariantDetailsPanel
+from invariant_details import InvariantDetailsPanel, InvariantContainer
 from invariant_widgets import OutputTextCtrl, InvTextCtrl
 # The minimum q-value to be used when extrapolating
@@ -26,8 +26,8 @@
 #default value of the contrast
 CONTRAST = 1.0
+#default value of the power used for power law
+POWER = 4.0
 #Invariant panel size 
 _BOX_WIDTH = 76
-#scale to use for a bar of value zero
-RECTANGLE_SCALE  = 0.0001
 
 if sys.platform.count("win32")>0:
@@ -41,28 +41,6 @@
     PANEL_HEIGHT = 700
     FONT_VARIANT = 1
-    
-class InvariantContainer(wx.Object):
-    def __init__(self):
-        #invariant at low range
-        self.qstar_low = None
-        #invariant at low range error
-        self.qstar_low_err = None
-        #invariant 
-        self.qstar = None
-        #invariant error
-        self.qstar_err = None
-        #invariant at high range
-        self.qstar_high = None
-        #invariant at high range error
-        self.qstar_high_err = None
-        #invariant total
-        self.qstar_total = None
-        #invariant error
-        self.qstar_total_err = None
-        #scale
-        self.qstar_low_scale = RECTANGLE_SCALE
-        self.qstar_scale = RECTANGLE_SCALE
-        self.qstar_high_scale = RECTANGLE_SCALE
- 
+
+
 class InvariantPanel(wx.ScrolledWindow):
     """
@@ -83,6 +61,4 @@
         #plug-in using this panel
         self._manager = manager 
-        #Default power value
-        self.power_law_exponant = 4 
         #Data uses for computation
         self._data = data
@@ -91,4 +67,5 @@
         #Draw the panel
         self._do_layout()
+        self.reset_panel()
         if self.parent is not None:
             msg = ""
@@ -123,5 +100,23 @@
             self.data_max_tcl.SetLabel(str(data_qmax))
             self.hint_msg_txt.SetLabel('')
-        
+            self.reset_panel()
+            self.compute_invariant(event=None)
+            
+    def set_message(self):
+        """
+            Display warning message if available
+        """
+        if self.inv_container is not None:
+            if self.inv_container.existing_warning:
+                msg = "Warning! Computations on invariant require your "
+                msg += "attention.\n Please click on Details button."
+                self.hint_msg_txt.SetForegroundColour("red")
+            else:
+                msg = "For more information, click on Details button."
+                self.hint_msg_txt.SetForegroundColour("black")
+            self.hint_msg_txt.SetLabel(msg)
+            wx.PostEvent(self.parent, StatusEvent(status=msg))
+        self.data_name_boxsizer.Layout()
+       
     def set_manager(self, manager):
         """
@@ -239,5 +234,5 @@
                 power_low = inv.get_extrapolation_power(range='low')  
                 if self.power_law_low.GetValue():
-                    self.power_low_tcl.SetValue(str(power_low))
+                    self.power_low_tcl.SetValue(format_number(power_low))
                 self._manager.plot_theory(data=extrapolated_data,
                                            name="Low-Q extrapolation")
@@ -257,5 +252,5 @@
                 self.inv_container.qstar_high_err = qstar_high_err
                 power_high = inv.get_extrapolation_power(range='high') 
-                self.power_high_tcl.SetValue(str(power_high))
+                self.power_high_tcl.SetValue(format_number(power_high))
                 high_out_data = inv.get_extra_data_high(q_end=Q_MAXIMUM_PLOT)
                 self._manager.plot_theory(data=high_out_data,
@@ -346,12 +341,11 @@
             open another panel for more details on invariant calculation
         """
-        #panel = InvariantDetailsWindow(parent=self.parent,
-        #                               qstar_container=self.inv_container)
         panel = InvariantDetailsPanel(parent=self, 
                                            qstar_container=self.inv_container)
         panel.ShowModal()
         panel.Destroy()
-        
-    def compute_invariant(self, event):
+        self.button_calculate.SetFocus()
+        
+    def compute_invariant(self, event=None):
         """
             compute invariant 
@@ -418,7 +412,12 @@
             msg= "Error occurred computing invariant: %s"%sys.exc_value
             wx.PostEvent(self.parent, StatusEvent(status= msg))
-      
+            
+        #compute percentage of each invariant
+        self.inv_container.compute_percentage()
+        #display a message
+        self.set_message()
         #enable the button_ok for more details
-        self.button_ok.Enable()
+        self.button_details.Enable()
+        self.button_details.SetFocus()
     
     def reset_panel(self):
@@ -426,4 +425,24 @@
             set the panel at its initial state.
         """
+        self.background_tcl.SetValue(str(BACKGROUND))
+        self.scale_tcl.SetValue(str(SCALE)) 
+        self.contrast_tcl.SetValue(str(CONTRAST)) 
+        self.npts_low_tcl.SetValue(str(NPTS))
+        self.enable_low_cbox.SetValue(False)
+        self.fix_enable_low.SetValue(True)
+        self.power_low_tcl.SetValue(str(POWER))
+        self.guinier.SetValue(True)
+        self.power_low_tcl.Disable()
+        self.enable_high_cbox.SetValue(False)
+        self.fix_enable_high.SetValue(True)
+        self.power_high_tcl.SetValue(str(POWER))
+        self.npts_high_tcl.SetValue(str(NPTS))
+        self.button_details.Disable()
+        #Change the state of txtcrtl to enable/disable
+        self._enable_low_q_section()
+        #Change the state of txtcrtl to enable/disable
+        self._enable_high_q_section()
+        self._reset_output()
+        self.button_calculate.SetFocus()
         
     def _reset_output(self):
@@ -457,17 +476,16 @@
         self.data_name_sizer = wx.BoxSizer(wx.HORIZONTAL)
         self.data_range_sizer = wx.BoxSizer(wx.HORIZONTAL)
-        #Sizer related to background
-        self.background_sizer = wx.BoxSizer(wx.HORIZONTAL) 
-        #Sizer related to scale
-        self.scale_sizer = wx.BoxSizer(wx.HORIZONTAL) 
-        #Sizer related to contrast
-        self.contrast_sizer = wx.BoxSizer(wx.HORIZONTAL) 
-        #Sizer related to Porod Constant
-        self.porod_constant_sizer = wx.BoxSizer(wx.HORIZONTAL) 
+        #Sizer related to background and scale
+        self.bkg_scale_sizer = wx.BoxSizer(wx.HORIZONTAL) 
+        #Sizer related to contrast and porod constant
+        self.contrast_porod_sizer = wx.BoxSizer(wx.HORIZONTAL) 
+        #Sizer related to inputs
+        inputs_box = wx.StaticBox(self, -1, "Customized Inputs")
+        self.inputs_sizer = wx.StaticBoxSizer(inputs_box, wx.VERTICAL)
+        #Sizer related to extrapolation
         extrapolation_box = wx.StaticBox(self, -1, "Extrapolation")
         self.extrapolation_sizer = wx.StaticBoxSizer(extrapolation_box,
                                                         wx.VERTICAL)
         self.extrapolation_sizer.SetMinSize((PANEL_WIDTH,-1))
-        self.extrapolation_hint_sizer = wx.BoxSizer(wx.HORIZONTAL)
         self.extrapolation_range_sizer = wx.BoxSizer(wx.HORIZONTAL)
         self.extrapolation_low_high_sizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -520,47 +538,32 @@
                                          (self.data_range_sizer, 0 , wx.ALL, 10)])
     
-    def _layout_background(self):
-        """
-            Draw widgets related to background
+    def _layout_bkg_scale(self):
+        """
+            Draw widgets related to background and scale
         """
         background_txt = wx.StaticText(self, -1, 'Background : ')  
         self.background_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 
-        self.background_tcl.SetValue(str(BACKGROUND))
         background_hint_txt = "background"
         self.background_tcl.SetToolTipString(background_hint_txt)
         background_unit_txt = wx.StaticText(self, -1, '[1/cm]')  
-        self.background_sizer.AddMany([(background_txt, 0, wx.LEFT, 10),
-                                       (self.background_tcl, 0, wx.LEFT, 15),
-                                       (background_unit_txt, 0, wx.LEFT, 10)])
-    def _layout_scale(self):
-        """
-            Draw widgets related to scale
-        """
         scale_txt = wx.StaticText(self, -1, 'Scale : ')  
         self.scale_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)
         scale_hint_txt = "Scale"
         self.scale_tcl.SetToolTipString(scale_hint_txt)
-        self.scale_tcl.SetValue(str(SCALE)) 
-        self.scale_sizer.AddMany([(scale_txt, 0, wx.LEFT|wx.RIGHT, 10),
-                                       (self.scale_tcl, 0, wx.LEFT, 35)])
-        
-    def _layout_contrast(self):
-        """
-            Draw widgets related to contrast
+        self.bkg_scale_sizer.AddMany([(background_txt, 0, wx.LEFT, 10),
+                                       (self.background_tcl, 0, wx.LEFT, 5),
+                                       (background_unit_txt, 0, wx.LEFT, 10),
+                                       (scale_txt, 0, wx.LEFT, 70),
+                                       (self.scale_tcl, 0, wx.LEFT, 40)])
+ 
+    def _layout_contrast_porod(self):
+        """
+            Draw widgets related to porod constant and contrast
         """
         contrast_txt = wx.StaticText(self, -1, 'Contrast : ')  
         self.contrast_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)
-        self.contrast_tcl.SetValue(str(CONTRAST)) 
         contrast_hint_txt = "Contrast"
         self.contrast_tcl.SetToolTipString(contrast_hint_txt)
         contrast_unit_txt = wx.StaticText(self, -1, '[1/A^(2)]')  
-        self.contrast_sizer.AddMany([(contrast_txt, 0, wx.LEFT|wx.RIGHT, 10),
-                                       (self.contrast_tcl, 0, wx.LEFT, 18),
-                                       (contrast_unit_txt, 0, wx.LEFT, 10)])
-    
-    def _layout_porod_constant(self):
-        """
-            Draw widgets related to porod constant
-        """
         porod_const_txt = wx.StaticText(self, -1, 'Porod Constant:')  
         self.porod_constant_tcl = InvTextCtrl(self, -1, 
@@ -569,5 +572,8 @@
         self.porod_constant_tcl.SetToolTipString(porod_const_hint_txt)
         optional_txt = wx.StaticText(self, -1, '(Optional)')  
-        self.porod_constant_sizer.AddMany([(porod_const_txt, 0, wx.LEFT, 10),
+        self.contrast_porod_sizer.AddMany([(contrast_txt, 0, wx.LEFT, 10),
+                                           (self.contrast_tcl, 0, wx.LEFT, 20),
+                                           (contrast_unit_txt, 0, wx.LEFT, 10),
+                                           (porod_const_txt, 0, wx.LEFT, 50),
                                        (self.porod_constant_tcl, 0, wx.LEFT, 0),
                                        (optional_txt, 0, wx.LEFT, 10)])
@@ -602,4 +608,5 @@
         self._enable_power_law_low()
         self._enable_fit_power_law_low()
+        self.button_calculate.SetFocus()
     
     def _enable_power_law_low(self, event=None):
@@ -622,10 +629,8 @@
         """
         self.enable_low_cbox = wx.CheckBox(self, -1, "Enable Extrapolate Low Q")
-        self.enable_low_cbox.SetValue(False)
         wx.EVT_CHECKBOX(self, self.enable_low_cbox.GetId(),
                                          self._enable_low_q_section)
         self.fix_enable_low = wx.RadioButton(self, -1, 'Fix',
                                          (10, 10),style=wx.RB_GROUP)
-        self.fix_enable_low.SetValue(True)
         self.fit_enable_low = wx.RadioButton(self, -1, 'Fit', (10, 10))
         self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_low,
@@ -635,5 +640,4 @@
         self.guinier = wx.RadioButton(self, -1, 'Guinier',
                                          (10, 10),style=wx.RB_GROUP)
-        self.guinier.SetValue(True)
         self.power_law_low = wx.RadioButton(self, -1, 'Power Law', (10, 10))
         self.Bind(wx.EVT_RADIOBUTTON, self._enable_power_law_low,
@@ -644,5 +648,4 @@
         npts_low_txt = wx.StaticText(self, -1, 'Npts')
         self.npts_low_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1))
-        self.npts_low_tcl.SetValue(str(NPTS))
         msg_hint = "Number of Q points to consider"
         msg_hint +="while extrapolating the low-Q region"
@@ -650,6 +653,5 @@
         power_txt = wx.StaticText(self, -1, 'Power')
         self.power_low_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1))
-        self.power_low_tcl.SetValue(str(self.power_law_exponant))
-        self.power_low_tcl.Disable()
+       
         power_hint_txt = "Exponent to apply to the Power_law function."
         self.power_low_tcl.SetToolTipString(power_hint_txt)
@@ -689,8 +691,7 @@
         self.low_q_sizer.Add(self.power_low_tcl, (iy, ix), (1,1),
                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        #Change the state of txtcrtl to enable/disable
-        self._enable_low_q_section()
         self.low_extrapolation_sizer.AddMany([(self.low_q_sizer, 0,
-                                                wx.BOTTOM|wx.RIGHT, 10)])
+                                                wx.BOTTOM|wx.RIGHT, 15)])
+        
     def _enable_fit_power_law_high(self, event=None):
         """
@@ -720,4 +721,5 @@
             self.fit_enable_high.Disable()
         self._enable_fit_power_law_high()
+        self.button_calculate.SetFocus()
   
     def _layout_extrapolation_high(self):
@@ -726,5 +728,4 @@
         """
         self.enable_high_cbox = wx.CheckBox(self, -1, "Enable Extrapolate high-Q")
-        self.enable_high_cbox.SetValue(False)
         wx.EVT_CHECKBOX(self, self.enable_high_cbox.GetId(),
                                          self._enable_high_q_section)
@@ -732,5 +733,4 @@
         self.fix_enable_high = wx.RadioButton(self, -1, 'Fix',
                                          (10, 10),style=wx.RB_GROUP)
-        self.fix_enable_high.SetValue(True)
         self.fit_enable_high = wx.RadioButton(self, -1, 'Fit', (10, 10))
         self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_high,
@@ -740,6 +740,6 @@
         
         self.power_law_high = wx.StaticText(self, -1, 'Power Law')
-        #msg_hint ="Check to extrapolate data at high-Q"
-        #self.power_law_high.SetToolTipString(msg_hint)
+        msg_hint ="Check to extrapolate data at high-Q"
+        self.power_law_high.SetToolTipString(msg_hint)
         npts_high_txt = wx.StaticText(self, -1, 'Npts')
         self.npts_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1))
@@ -747,8 +747,6 @@
         msg_hint += "while extrapolating the high-Q region"
         self.npts_high_tcl.SetToolTipString(msg_hint)
-        self.npts_high_tcl.SetValue(str(NPTS))
         power_txt = wx.StaticText(self, -1, 'Power')
         self.power_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1))
-        self.power_high_tcl.SetValue(str(self.power_law_exponant))
         power_hint_txt = "Exponent to apply to the Power_law function."
         self.power_high_tcl.SetToolTipString(power_hint_txt)
@@ -784,7 +782,6 @@
         self.high_q_sizer.Add(self.power_high_tcl, (iy, ix), (1,1),
                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        #Change the state of txtcrtl to enable/disable
-        self._enable_high_q_section()
-        self.high_extrapolation_sizer.AddMany([(self.high_q_sizer, 0, wx.RIGHT, 10)])
+        self.high_extrapolation_sizer.AddMany([(self.high_q_sizer, 0, 
+                                                wx.BOTTOM|wx.RIGHT, 10)])
         
     def _layout_extrapolation(self):
@@ -813,8 +810,4 @@
                                                             0, wx.LEFT, 10),
                                                 ])
-        extra_enable_hint = "Hint: Check any box to enable a specific extrapolation !"
-        extra_enable_hint_txt = wx.StaticText(self, -1, extra_enable_hint )
-        self.extrapolation_hint_sizer.AddMany([(extra_enable_hint_txt, 0, wx.LEFT, 0)
-                                               ])
         self._layout_extrapolation_low()
         self._layout_extrapolation_high()
@@ -825,6 +818,4 @@
         self.extrapolation_sizer.AddMany([(self.extrapolation_range_sizer, 0,
                                             wx.RIGHT, 10),
-                                         (self.extrapolation_hint_sizer, 0,
-                                           wx.ALL, 10),
                                         (self.extrapolation_low_high_sizer, 0,
                                            wx.ALL, 10)])
@@ -915,4 +906,13 @@
                           wx.EXPAND|wx.ADJUST_MINSIZE, 10)
  
+    def _layout_inputs_sizer(self):
+        """
+            Draw widgets related to inputs
+        """
+        self._layout_bkg_scale()
+        self._layout_contrast_porod()
+        self.inputs_sizer.AddMany([(self.bkg_scale_sizer, 0, wx.ALL, 5),
+                                    (self.contrast_porod_sizer, 0, wx.ALL, 5)])
+        
     def _layout_outputs_sizer(self):
         """
@@ -931,19 +931,19 @@
         #compute button
         id = wx.NewId()
-        button_calculate = wx.Button(self, id, "Compute")
-        button_calculate.SetToolTipString("Compute invariant")
+        self.button_calculate = wx.Button(self, id, "Compute")
+        self.button_calculate.SetToolTipString("Compute invariant")
         self.Bind(wx.EVT_BUTTON, self.compute_invariant, id=id)   
         #detail button
         id = wx.NewId()
-        self.button_ok = wx.Button(self, id, "Details?")
-        self.button_ok.SetToolTipString("Give Details on Computation")
+        self.button_details = wx.Button(self, id, "Details?")
+        self.button_details.SetToolTipString("Give Details on Computation")
         self.Bind(wx.EVT_BUTTON, self.display_details, id=id)
-        self.button_ok.Disable()
         details = "Details on Invariant Total Calculations"
         details_txt = wx.StaticText(self, -1, details)
-        self.button_sizer.AddMany([((20,20), 0 , wx.LEFT, 100),
-                                   (details_txt, 0 , wx.ALL, 10),
-                                   (self.button_ok, 0 , wx.ALL, 10),
-                        (button_calculate, 0 , wx.RIGHT|wx.TOP|wx.BOTTOM, 10)])
+        self.button_sizer.AddMany([((10,10), 0 , wx.LEFT,0),
+                                   (details_txt, 0 , 
+                                    wx.RIGHT|wx.BOTTOM|wx.TOP, 10),
+                                   (self.button_details, 0 , wx.ALL, 10),
+                        (self.button_calculate, 0 , wx.RIGHT|wx.TOP|wx.BOTTOM, 10)])
         
     def _do_layout(self):
@@ -953,25 +953,16 @@
         self._define_structure()
         self._layout_data_name()
-        self._layout_background()
-        self._layout_scale()
-        self._layout_contrast()
-        self._layout_porod_constant()
         self._layout_extrapolation()
+        self._layout_inputs_sizer()
         self._layout_outputs_sizer()
         self._layout_button()
-        self.main_sizer.AddMany([(self.data_name_boxsizer, 0, wx.ALL, 10),
-                                 (self.background_sizer, 0,
-                                   wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),
-                                 (self.scale_sizer, 0,
-                                   wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),
-                                 (self.contrast_sizer, 0,
-                                  wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),
-                                  (self.porod_constant_sizer, 0,
-                                  wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),
-                                  (self.extrapolation_sizer, 0,
-                                  wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),
+        self.main_sizer.AddMany([(self.data_name_boxsizer, 1, wx.ALL, 10),
                                   (self.outputs_sizer, 0,
                                   wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),
                                   (self.button_sizer, 0,
+                                  wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),
+                                 (self.inputs_sizer, 0,
+                                  wx.LEFT|wx.RIGHT|wx.BOTTOM, 10),
+                                  (self.extrapolation_sizer, 0,
                                   wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)])
         self.SetSizer(self.main_sizer)
