Index: prview/perspectives/pr/inversion_panel.py
===================================================================
--- prview/perspectives/pr/inversion_panel.py	(revision b65955159b1d1b4d2bd00638c586ef52777d1d45)
+++ prview/perspectives/pr/inversion_panel.py	(revision aa4b8379ab733d444eb3a18e3390d30388cdc69f)
@@ -115,5 +115,5 @@
     pos_err  = 1.0
     
-    def __init__(self, parent, id = -1, plots = None, **kwargs):
+    def __init__(self, parent, id = -1, plots = None, standalone=False, **kwargs):
         wx.Panel.__init__(self, parent, id = id, **kwargs)
         
@@ -147,4 +147,7 @@
         ## Data manager
         self.manager   = None
+        
+        ## Standalone flage
+        self.standalone = standalone
         
         self._do_layout()
@@ -181,6 +184,11 @@
             #self.label_sugg.Show()
         elif name=='plotname':
-            self.plot_data.SetValue(str(value))
-            self.plot_radio.SetValue(True)
+            if self.standalone==False:
+                self.plot_data.SetValue(str(value))
+                self.plot_radio.SetValue(True)
+                self._on_pars_changed(None)
+        elif name=='datafile':
+            self.data_file.SetValue(str(value))
+            self.file_radio.SetValue(True)
             self._on_pars_changed(None)
         else:
@@ -214,5 +222,8 @@
             self.alpha_estimate_ctl.GetValue()
         elif name=='plotname':
-            self.plot_data.GetValue()
+            if self.standalone==False:
+                self.plot_data.GetValue()
+        elif name=='datafile':
+            self.data_file.GetValue()
         else:
             wx.Panel.__getattr__(self, name)
@@ -230,5 +241,5 @@
 
         # ----- I(q) data -----
-        databox = wx.StaticBox(self, -1, "I(q) data")
+        databox = wx.StaticBox(self, -1, "I(q) data source")
         
         boxsizer1 = wx.StaticBoxSizer(databox, wx.VERTICAL)
@@ -248,10 +259,11 @@
         pars_sizer.Add(choose_button, (iy,3), (1,1), wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
         
-        iy += 1
-        self.plot_radio = wx.RadioButton(self, -1, "Plot data:")
-        self.plot_data = wx.TextCtrl(self, -1, size=(100,20))
-        self.plot_data.SetEditable(False)
-        pars_sizer.Add(self.plot_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        if self.standalone==False:
+            iy += 1
+            self.plot_radio = wx.RadioButton(self, -1, "Plot data:")
+            self.plot_data = wx.TextCtrl(self, -1, size=(100,20))
+            self.plot_data.SetEditable(False)
+            pars_sizer.Add(self.plot_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+            pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 15)
         
         boxsizer1.Add(pars_sizer, 0, wx.EXPAND)
@@ -476,5 +488,5 @@
         # If the pars are valid, estimate alpha
         if flag:
-            if self.plot_radio.GetValue():
+            if self.standalone==False and self.plot_radio.GetValue():
                 dataset = self.plot_data.GetValue()
                 self.manager.estimate_plot_inversion(alpha=alpha, nfunc=nfunc, 
@@ -571,15 +583,23 @@
         
         if flag:
-            if self.plot_radio.GetValue():
+            if self.standalone==False and self.plot_radio.GetValue():
                 dataset = self.plot_data.GetValue()
-                self.manager.setup_plot_inversion(alpha=alpha, nfunc=nfunc, 
-                                                  d_max=dmax,
-                                                  q_min=qmin, q_max=qmax)
+                if len(dataset.strip())==0:
+                    message = "No data to invert. Select a data set before proceeding with P(r) inversion."
+                    wx.PostEvent(self.manager.parent, StatusEvent(status=message))
+                else:
+                    self.manager.setup_plot_inversion(alpha=alpha, nfunc=nfunc, 
+                                                      d_max=dmax,
+                                                      q_min=qmin, q_max=qmax)
             else:
                 path = self.data_file.GetValue()
-                self.manager.setup_file_inversion(alpha=alpha, nfunc=nfunc, 
-                                                  d_max=dmax, path=path,
-                                                  q_min=qmin, q_max=qmax
-                                                  )
+                if len(path.strip())==0:
+                    message = "No data to invert. Select a data set before proceeding with P(r) inversion."
+                    wx.PostEvent(self.manager.parent, StatusEvent(status=message))
+                else:
+                    self.manager.setup_file_inversion(alpha=alpha, nfunc=nfunc, 
+                                                      d_max=dmax, path=path,
+                                                      q_min=qmin, q_max=qmax
+                                                      )
                 
         else:
Index: prview/perspectives/pr/pr.py
===================================================================
--- prview/perspectives/pr/pr.py	(revision b65955159b1d1b4d2bd00638c586ef52777d1d45)
+++ prview/perspectives/pr/pr.py	(revision aa4b8379ab733d444eb3a18e3390d30388cdc69f)
@@ -6,8 +6,17 @@
 import sys
 import wx
+import logging
 from sans.guitools.plottables import Data1D, Theory1D
 from sans.guicomm.events import NewPlotEvent, StatusEvent    
 import math, numpy
 from sans.pr.invertor import Invertor
+
+PR_FIT_LABEL    = "P_{fit}(r)"
+PR_LOADED_LABEL = "P_{loaded}(r)"
+IQ_DATA_LABEL   = "I_{obs}(q)"
+
+import wx.lib
+(NewPrFileEvent, EVT_PR_FILE) = wx.lib.newevent.NewEvent()
+
 
 class Plugin:
@@ -41,4 +50,5 @@
         # Start with a good default
         self.elapsed = 0.022
+        self.iq_data_shown = False
         
         ## Current invertor
@@ -54,4 +64,11 @@
         ## Number of P(r) points to display on the output plot
         self._pr_npts = 51
+        ## Flag to let the plug-in know that it is running standalone
+        self.standalone = True
+        
+        # Log startup
+        logging.info("Pr(r) plug-in started")
+        
+        
 
     def populate_menu(self, id, owner):
@@ -332,12 +349,14 @@
         """
         # Look whether this Graph contains P(r) data
+        #if graph.selected_plottable==IQ_DATA_LABEL:
         for item in graph.plottables:
-            if item.name=="P_{fit}(r)":
-                
-                return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion],
-                       ["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data],
+            if item.name==PR_FIT_LABEL:
+                return [["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data],
                        ["Change number of P(r) points", "Change the number of points on the P(r) output", self._on_pr_npts]]
-                
-        return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion]]
+
+            elif item.name==graph.selected_plottable:
+                return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion]]      
+                
+        return []
 
     def _on_add_data(self, evt):
@@ -429,10 +448,11 @@
         
         # Make a plot of I(q) data
-        new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err)
-        new_plot.name = "I_{obs}(q)"
-        new_plot.xaxis("\\rm{Q}", 'A^{-1}')
-        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
-        #new_plot.group_id = "test group"
-        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq"))
+        if False:
+            new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err)
+            new_plot.name = "I_{obs}(q)"
+            new_plot.xaxis("\\rm{Q}", 'A^{-1}')
+            new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
+            #new_plot.group_id = "test group"
+            wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq"))
                 
         # Show I(q) fit
@@ -454,7 +474,13 @@
         new_plot.xaxis("\\rm{Q}", 'A^{-1}')
         new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
+        new_plot.interactive = True
         #new_plot.group_id = "test group"
         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq"))
         
+        # Get Q range
+        self.control_panel.q_min = self.pr.x.min()
+        self.control_panel.q_max = self.pr.x.max()
+            
+
         
     def setup_plot_inversion(self, alpha, nfunc, d_max, q_min=None, q_max=None):
@@ -510,4 +536,5 @@
             
         self.pr = pr
+        self.iq_data_shown = True
 
           
@@ -624,13 +651,15 @@
         
         # If we have more than one displayed plot, make the user choose
-        if len(panel.plots)>1:
-            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
+        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]
@@ -646,4 +675,5 @@
         self.control_panel.alpha = self.alpha
         self.parent.set_perspective(self.perspective)
+        self.control_panel._on_invert(None)
             
     def get_panels(self, parent):
@@ -654,5 +684,7 @@
         
         self.parent = parent
-        self.control_panel = InversionControl(self.parent, -1, style=wx.RAISED_BORDER)
+        self.control_panel = InversionControl(self.parent, -1, 
+                                              style=wx.RAISED_BORDER,
+                                              standalone=self.standalone)
         self.control_panel.set_manager(self)
         self.control_panel.nfunc = self.nfunc
@@ -662,5 +694,16 @@
         self.perspective = []
         self.perspective.append(self.control_panel.window_name)
+        
+        self.parent.Bind(EVT_PR_FILE, self._on_new_file)
+        
         return [self.control_panel]
+    
+    def _on_new_file(self, evt):
+        """
+            Called when the application manager posted an
+            EVT_PR_FILE event. Just prompt the control
+            panel to load a new data file.
+        """
+        self.control_panel._change_file(None)
     
     def get_perspective(self):
Index: prview/sansview.py
===================================================================
--- prview/sansview.py	(revision 4a5de6fb907873c63516b0763785b44c8d1f5c15)
+++ prview/sansview.py	(revision aa4b8379ab733d444eb3a18e3390d30388cdc69f)
@@ -1,3 +1,3 @@
-
+import wx
 #import gui_manager
 from sans.guiframe import gui_manager
@@ -5,5 +5,22 @@
 # For py2exe, import config here
 import local_config
+from perspectives.pr.pr import NewPrFileEvent
 
+class PrFrame(gui_manager.ViewerFrame):
+    def _on_open(self, event):
+        wx.PostEvent(self, NewPrFileEvent())
+
+class PrApp(gui_manager.ViewApp):
+    def OnInit(self):
+        #from gui_manager import ViewerFrame
+        self.frame = PrFrame(None, -1, local_config.__appname__)    
+        self.frame.Show(True)
+
+        if hasattr(self.frame, 'special'):
+            print "Special?", self.frame.special.__class__.__name__
+            self.frame.special.SetCurrent()
+        self.SetTopWindow(self.frame)
+        return True
+    
 class SansView():
     
@@ -13,5 +30,6 @@
         """
         #from gui_manager import ViewApp
-        self.gui = gui_manager.ViewApp(0)
+        #self.gui = gui_manager.ViewApp(0) 
+        self.gui = PrApp(0)
         
         # Add perspectives to the basic application
@@ -19,6 +37,6 @@
         # dynamically
         import perspectives.pr as module
-        plug = module.Plugin()
-        self.gui.add_perspective(plug)
+        self.pr_plug = module.Plugin()
+        self.gui.add_perspective(self.pr_plug)
             
         # Build the GUI
@@ -30,4 +48,5 @@
         # Start the main loop
         self.gui.MainLoop()  
+        
 
 if __name__ == "__main__": 
