Index: prview/perspectives/pr/explore_dialog.py
===================================================================
--- prview/perspectives/pr/explore_dialog.py	(revision 96c430df39c2174abb34f0619efbfc9c27386b4a)
+++ prview/perspectives/pr/explore_dialog.py	(revision 9ff861b6a3b2f5a1168a423f45b19cf132d15791)
@@ -27,4 +27,6 @@
 from danse.common.plottools.plottables import Graph
 
+from pr_widgets import PrTextCtrl
+
 # Default number of points on the output plot
 DEFAULT_NPTS = 10
@@ -148,9 +150,9 @@
         
         # Control for number of points
-        self.npts_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+        self.npts_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
         # Control for the minimum value of D_max
-        self.dmin_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+        self.dmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
         # Control for the maximum value of D_max
-        self.dmax_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+        self.dmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
 
         # Output selection box for the y axis
Index: prview/perspectives/pr/inversion_panel.py
===================================================================
--- prview/perspectives/pr/inversion_panel.py	(revision 0ccd2143efef3cd9861d3dfbd07322430a1812f7)
+++ prview/perspectives/pr/inversion_panel.py	(revision 9ff861b6a3b2f5a1168a423f45b19cf132d15791)
@@ -9,99 +9,12 @@
 import sys
 import logging
+from wx.lib.scrolledpanel import ScrolledPanel
 from sans.guicomm.events import StatusEvent    
 from inversion_state import InversionState
-
-class InversionDlg(wx.Dialog):
-    def __init__(self, parent, id, title, plots, file=False, pars=True):
-        
-        # Estimate size
-        nplots = len(plots)
-        # y size for data set only
-        ysize  = 110 + nplots*20
-        # y size including parameters
-        if pars:
-            ysize  += 90
-        
-        wx.Dialog.__init__(self, parent, id, title, size=(250, ysize))
-        self.SetTitle(title)
-
-        # Data set
-        self.datasets = InversionPanel(self, -1, plots)
-        vbox = wx.BoxSizer(wx.VERTICAL)
-
-        vbox.Add(self.datasets)
-
-        # Parameters
-        self.pars_flag = False
-        if pars==True:
-            self.pars_flag = True
-            self.pars = ParsDialog(self, -1, file=file)
-            vbox.Add(self.pars)
-
-        static_line = wx.StaticLine(self, -1)
-        vbox.Add(static_line, 0, wx.EXPAND, 0)
-        
-        button_OK = wx.Button(self, wx.ID_OK, "OK")
-        button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
-        
-        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(button_OK, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10)
-        sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)        
-        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
-
-        self.SetSizer(vbox)
-        self.SetAutoLayout(True)
-        
-        self.Layout()
-        self.Centre()
-
-    def get_content(self):
-        dataset = self.datasets.get_selected()
-        if self.pars_flag:
-            nfunc, alpha, dmax, file = self.pars.getContent()
-            return dataset, nfunc, alpha, dmax
-        else:
-            return dataset
-    
-    def set_content(self, dataset, nfunc, alpha, dmax):
-        if not dataset==None and dataset in self.datasets.radio_buttons.keys():
-            self.datasets.radio_buttons[dataset].SetValue(True)
-        if self.pars_flag:
-            self.pars.setContent(nfunc, alpha, dmax, None)
-
-class InversionPanel(wx.Panel):
-    
-    def __init__(self, parent, id = -1, plots = None, **kwargs):
-        wx.Panel.__init__(self, parent, id = id, **kwargs)
-        
-        self.plots = plots
-        self.radio_buttons = {}
-        
-        self._do_layout()
-        
-    def _do_layout(self):
-        panel = wx.Panel(self, -1)
-        vbox = wx.BoxSizer(wx.VERTICAL)
-
-        ysize = 30+20*len(self.plots)
-        wx.StaticBox(panel, -1, 'Choose a data set', (5, 5), (230, ysize))
-        ypos = 30
-        self.radio_buttons = {}
-        for item in self.plots.keys():
-            self.radio_buttons[self.plots[item].name] = wx.RadioButton(panel, -1, self.plots[item].name, (15, ypos))
-            ypos += 20
-        
-        vbox.Add(panel)
-
-        self.SetSizer(vbox)
-        
-    def get_selected(self):
-        for item in self.radio_buttons:
-            if self.radio_buttons[item].GetValue():
-                return item
-        return None
-
-class InversionControl(wx.Panel):
+from pr_widgets import PrTextCtrl, DataFileTextCtrl, OutputTextCtrl
+
+
+
+class InversionControl(ScrolledPanel):
     window_name = 'pr_control'
     window_caption = "P(r) control panel"
@@ -114,5 +27,6 @@
     
     def __init__(self, parent, id = -1, plots = None, standalone=False, **kwargs):
-        wx.Panel.__init__(self, parent, id = id, **kwargs)
+        ScrolledPanel.__init__(self, parent, id = id, **kwargs)
+        self.SetupScrolling()
         
         self.plots = plots
@@ -451,7 +365,7 @@
         pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
         
-        self.plot_data = wx.TextCtrl(self, -1, size=(220,20))
-        self.plot_data.SetEditable(False)
-        pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        self.plot_data = DataFileTextCtrl(self, -1, size=(260,20))
+        
+        pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 15)
         
         self.bck_chk = wx.CheckBox(self, -1, "Estimate background level")
@@ -475,6 +389,6 @@
             #label_sunits1 = wx.StaticText(self, -1, "[A^(-1)]")
             label_sunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55,20))
-            self.sheight_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
-            self.swidth_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+            self.sheight_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+            self.swidth_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
             self.sheight_ctl.SetToolTipString("Enter slit height in units of Q or leave blank.")
             self.swidth_ctl.SetToolTipString("Enter slit width in units of Q or leave blank.")
@@ -506,6 +420,6 @@
         #label_qunits1 = wx.StaticText(self, -1, "[A^(-1)]")
         label_qunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55,20))
-        self.qmin_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
-        self.qmax_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+        self.qmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+        self.qmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
         self.qmin_ctl.SetToolTipString("Select a lower bound for Q or leave blank.")
         self.qmax_ctl.SetToolTipString("Select an upper bound for Q or leave blank.")
@@ -550,9 +464,9 @@
         #self.label_sugg.Hide()
         
-        self.nfunc_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+        self.nfunc_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
         self.nfunc_ctl.SetToolTipString("Number of terms in the expansion.")
-        self.alpha_ctl = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+        self.alpha_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
         self.alpha_ctl.SetToolTipString("Control parameter for the size of the regularization term.")
-        self.dmax_ctl  = wx.TextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
+        self.dmax_ctl  = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20))
         self.dmax_ctl.SetToolTipString("Maximum distance between any two points in the system.")
         id = wx.NewId()
@@ -618,12 +532,9 @@
         label_bck      = wx.StaticText(self, -1, "Background")
         label_bck_unit = wx.StaticText(self, -1, "[A^(-1)]")
-        self.rg_ctl    = wx.TextCtrl(self, -1, size=(60,20))
-        self.rg_ctl.SetEditable(False)
+        self.rg_ctl    = OutputTextCtrl(self, -1, size=(60,20))
         self.rg_ctl.SetToolTipString("Radius of gyration for the computed P(r).")
-        self.iq0_ctl   = wx.TextCtrl(self, -1, size=(60,20))
-        self.iq0_ctl.SetEditable(False)
+        self.iq0_ctl   = OutputTextCtrl(self, -1, size=(60,20))
         self.iq0_ctl.SetToolTipString("Scattering intensity at Q=0 for the computed P(r).")
-        self.bck_ctl   = wx.TextCtrl(self, -1, size=(60,20))
-        self.bck_ctl.SetEditable(False)
+        self.bck_ctl   = OutputTextCtrl(self, -1, size=(60,20))
         self.bck_ctl.SetToolTipString("Value of estimated constant background.")
         
@@ -636,25 +547,20 @@
         label_pos_err = wx.StaticText(self, -1, "1-sigma positive fraction")
         
-        self.time_ctl = wx.TextCtrl(self, -1, size=(60,20))
-        self.time_ctl.SetEditable(False)
+        self.time_ctl = OutputTextCtrl(self, -1, size=(60,20))
         self.time_ctl.SetToolTipString("Computation time for the last inversion, in seconds.")
         
-        self.chi2_ctl = wx.TextCtrl(self, -1, size=(60,20))
-        self.chi2_ctl.SetEditable(False)
+        self.chi2_ctl = OutputTextCtrl(self, -1, size=(60,20))
         self.chi2_ctl.SetToolTipString("Chi^2 over degrees of freedom.")
         
         # Oscillation parameter
-        self.osc_ctl = wx.TextCtrl(self, -1, size=(60,20))
-        self.osc_ctl.SetEditable(False)
+        self.osc_ctl = OutputTextCtrl(self, -1, size=(60,20))
         self.osc_ctl.SetToolTipString("Oscillation parameter. P(r) for a sphere has an oscillation parameter of 1.1.")
         
         # Positive fraction figure of merit
-        self.pos_ctl = wx.TextCtrl(self, -1, size=(60,20))
-        self.pos_ctl.SetEditable(False)
+        self.pos_ctl = OutputTextCtrl(self, -1, size=(60,20))
         self.pos_ctl.SetToolTipString("Fraction of P(r) that is positive. Theoretically, P(r) is defined positive.")
         
         # 1-simga positive fraction figure of merit
-        self.pos_err_ctl = wx.TextCtrl(self, -1, size=(60,20))
-        self.pos_err_ctl.SetEditable(False)
+        self.pos_err_ctl = OutputTextCtrl(self, -1, size=(60,20))
         message  = "Fraction of P(r) that is at least 1 standard deviation greater than zero.\n"
         message += "This figure of merit tells you about the size of the P(r) errors.\n"
@@ -1019,5 +925,5 @@
         
         label_npts = wx.StaticText(self, -1, "Number of points")
-        self.npts_ctl = wx.TextCtrl(self, -1, size=(100,20))
+        self.npts_ctl = PrTextCtrl(self, -1, size=(100,20))
                  
         pars_sizer = wx.GridBagSizer(5,5)
@@ -1079,137 +985,4 @@
         self.npts_ctl.SetValue("%i" % npts)
 
-
-class ParsDialog(wx.Panel):
-    """
-        Dialog box to let the user edit detector settings
-    """
-    
-    def __init__(self, parent, id = id, file=True, **kwargs):
-
-        wx.Panel.__init__(self, parent, id = id, **kwargs)
-        self.file = file
-        
-        self.label_nfunc = wx.StaticText(self, -1, "Number of terms")
-        self.label_alpha = wx.StaticText(self, -1, "Regularization constant")
-        self.label_dmax  = wx.StaticText(self, -1, "Max distance [A]")
-        
-        # Npts, q max
-        self.nfunc_ctl = wx.TextCtrl(self, -1, size=(60,20))
-        self.alpha_ctl = wx.TextCtrl(self, -1, size=(60,20))
-        self.dmax_ctl  = wx.TextCtrl(self, -1, size=(60,20))
-
-        self.label_file = None
-        self.file_ctl   = None
-
-        self.static_line_3 = wx.StaticLine(self, -1)
-        
-        
-
-        self.__do_layout()
-
-        self.Fit()
-        
-    def _load_file(self, evt):
-        import os
-        path = None
-        dlg = wx.FileDialog(self, "Choose a file", os.getcwd(), "", "*.txt", wx.OPEN)
-        if dlg.ShowModal() == wx.ID_OK:
-            path = dlg.GetPath()
-            mypath = os.path.basename(path)
-        dlg.Destroy()
-        
-        if path and os.path.isfile(path):
-            self.file_ctl.SetValue(str(path))
-
-        
-    def checkValues(self, event):
-        flag = True
-        try:
-            float(self.alpha_ctl.GetValue())
-            self.alpha_ctl.SetBackgroundColour(wx.WHITE)
-            self.alpha_ctl.Refresh()
-        except:
-            flag = False
-            self.alpha_ctl.SetBackgroundColour("pink")
-            self.alpha_ctl.Refresh()
-            
-        try:
-            float(self.dmax_ctl.GetValue())
-            self.dmax_ctl.SetBackgroundColour(wx.WHITE)
-            self.dmax_ctl.Refresh()
-        except:
-            flag = False
-            self.dmax_ctl.SetBackgroundColour("pink")
-            self.dmax_ctl.Refresh()
-            
-        try:
-            int(self.nfunc_ctl.GetValue())
-            self.nfunc_ctl.SetBackgroundColour(wx.WHITE)
-            self.nfunc_ctl.Refresh()
-        except:
-            flag = False
-            self.nfunc_ctl.SetBackgroundColour("pink")
-            self.nfunc_ctl.Refresh()
-        
-        if flag:
-            event.Skip(True)
-    
-    def setContent(self, nfunc, alpha, dmax, file):
-        self.nfunc_ctl.SetValue(str(nfunc))
-        self.alpha_ctl.SetValue(str(alpha))
-        self.dmax_ctl.SetValue(str(dmax))
-        if self.file:
-            self.file_ctl.SetValue(str(file))
-
-    def getContent(self):
-        nfunc = int(self.nfunc_ctl.GetValue())
-        alpha = float(self.alpha_ctl.GetValue())
-        dmax = float(self.dmax_ctl.GetValue())
-        file = None
-        if self.file:
-            file = self.file_ctl.GetValue()
-        return nfunc, alpha, dmax, file
-
-
-    def __do_layout(self):
-        sizer_main = wx.BoxSizer(wx.VERTICAL)
-        sizer_params = wx.GridBagSizer(5,5)
-
-        iy = 0
-        sizer_params.Add(self.label_nfunc, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        sizer_params.Add(self.nfunc_ctl,   (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        iy += 1
-        sizer_params.Add(self.label_alpha, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        sizer_params.Add(self.alpha_ctl,   (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        iy += 1
-        sizer_params.Add(self.label_dmax, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        sizer_params.Add(self.dmax_ctl,   (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        iy += 1
-        if self.file:
-            self.label_file  = wx.StaticText(self, -1, "Input file")
-            self.file_ctl  = wx.TextCtrl(self, -1, size=(120,20))
-            sizer_params.Add(self.label_file, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            sizer_params.Add(self.file_ctl,   (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-
-        sizer_main.Add(sizer_params, 0, wx.EXPAND|wx.ALL, 10)
-        
-        
-        if self.file:
-            sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-            self.button_load = wx.Button(self, 1, "Choose file")
-            self.Bind(wx.EVT_BUTTON, self._load_file, id = 1)        
-            sizer_button.Add(self.button_load, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10)
-        
-        
-            sizer_main.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
-        self.SetAutoLayout(True)
-        self.SetSizer(sizer_main)
-        self.Layout()
-        self.Centre()
-        # end wxGlade
-
-
-# end of class DialogAbout
-
 ##### testing code ############################################################
 class TestPlot:
Index: prview/perspectives/pr/pr.py
===================================================================
--- prview/perspectives/pr/pr.py	(revision ceaf16ebbfed884b28e8ca3e7f61155b8de2d33f)
+++ prview/perspectives/pr/pr.py	(revision 9ff861b6a3b2f5a1168a423f45b19cf132d15791)
@@ -1,2 +1,12 @@
+"""
+This software was developed by the University of Tennessee as part of the
+Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+project funded by the US National Science Foundation. 
+
+See the license text in license.txt
+
+copyright 2009, University of Tennessee
+"""
+
 # Make sure the option of saving each curve is available 
 # Use the I(q) curve as input and compare the output to P(r)
@@ -1162,18 +1172,7 @@
         panel = event.GetEventObject()
 
-        from inversion_panel import InversionDlg
-        
         # If we have more than one displayed plot, make the user choose
         if len(panel.plots)>1 and panel.graph.selected_plottable in panel.plots:
             dataset = panel.graph.selected_plottable
-            if False:
-                dialog = InversionDlg(None, -1, "P(r) Inversion", panel.plots, pars=False)
-                dialog.set_content(self.last_data, self.nfunc, self.alpha, self.max_length)
-                if dialog.ShowModal() == wx.ID_OK:
-                    dataset = dialog.get_content()
-                    dialog.Destroy()
-                else:
-                    dialog.Destroy()
-                    return
         elif len(panel.plots)==1:
             dataset = panel.plots.keys()[0]
Index: prview/perspectives/pr/pr_widgets.py
===================================================================
--- prview/perspectives/pr/pr_widgets.py	(revision 9ff861b6a3b2f5a1168a423f45b19cf132d15791)
+++ prview/perspectives/pr/pr_widgets.py	(revision 9ff861b6a3b2f5a1168a423f45b19cf132d15791)
@@ -0,0 +1,97 @@
+"""
+This software was developed by the University of Tennessee as part of the
+Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+project funded by the US National Science Foundation. 
+
+See the license text in license.txt
+
+copyright 2009, University of Tennessee
+"""
+
+"""
+    Text controls for input/output of the main PrView panel
+"""
+
+import wx
+import os
+
+class PrTextCtrl(wx.TextCtrl):
+    """
+        Text control for model and fit parameters.
+        Binds the appropriate events for user interactions.
+    """
+    def __init__(self, *args, **kwds):
+        
+        wx.TextCtrl.__init__(self, *args, **kwds)
+        
+        # Bind appropriate events
+        self.Bind(wx.EVT_LEFT_UP, self._highlight_text)
+        
+    def _highlight_text(self, event):
+        """
+            Highlight text of a TextCtrl only of no text has be selected
+            @param event: mouse event
+        """
+        control  = event.GetEventObject()
+        # Check that we have a TextCtrl
+        if issubclass(control.__class__, wx.TextCtrl):
+            # Check whether text has been selected, 
+            # if not, select the whole string
+
+            (start, end) = control.GetSelection()
+            if start==end:
+                control.SetSelection(-1,-1)
+                
+        # Make sure the mouse event is available to other listeners
+        event.Skip()
+
+class OutputTextCtrl(wx.TextCtrl):
+    """
+        Text control used to display outputs.
+        No editing allowed. The background is 
+        grayed out. User can't select text.
+    """
+    def __init__(self, *args, **kwds):
+        wx.TextCtrl.__init__(self, *args, **kwds)
+        self.SetEditable(False)
+        self.SetBackgroundColour(self.GetParent().GetBackgroundColour())
+        
+        # Bind to mouse event to avoid text highlighting
+        # The event will be skipped once the call-back
+        # is called.
+        self.Bind(wx.EVT_MOUSE_EVENTS, self._click)
+        
+    def _click(self, event):
+        """
+            Prevent further handling of the mouse event
+            by not calling Skip().
+        """ 
+        pass
+        
+
+class DataFileTextCtrl(OutputTextCtrl):
+    """
+        Text control used to display only the file name
+        given a full path.
+         
+        TODO: now that we no longer choose the data file from the panel,
+        it's no longer necessary to pass around the file path. That code
+        should be refactored away and simplified. 
+    """
+    def __init__(self, *args, **kwds):
+        OutputTextCtrl.__init__(self, *args, **kwds)
+        self._complete_path = None
+    
+    def SetValue(self, value):
+        """
+            Sets the file name given a path
+        """
+        self._complete_path = str(value)
+        file = os.path.basename(self._complete_path)
+        OutputTextCtrl.SetValue(self, file)
+        
+    def GetValue(self):
+        """
+            Return the full path
+        """
+        return self._complete_path
