Changeset 3e41f43 in sasview for prview/perspectives


Ignore:
Timestamp:
Jan 10, 2011 12:42:27 PM (14 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
3658abed
Parents:
d65a00a
Message:

make pr plugin inheriting from pluginbase in guiframe

Location:
prview/perspectives/pr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • prview/perspectives/pr/explore_dialog.py

    r7116b6e0 r3e41f43  
    6868  
    6969        # Plot area 
    70         self.plot = Model1D(self.x,y=y,dy=dy) 
     70        self.plot = Model1D(self.x, y=y, dy=dy) 
    7171        self.plot.name = DEFAULT_OUTPUT 
    7272 
     
    8989        id = wx.NewId() 
    9090        slicerpop = wx.Menu() 
    91         slicerpop.Append(id,'&Save image', 'Save image as PNG') 
     91        slicerpop.Append(id, '&Save image', 'Save image as PNG') 
    9292        wx.EVT_MENU(self, id, self.onSaveImage) 
    9393         
     
    126126        self.outputs['Oscillation parameter'] = ["Osc", "a.u.", self.osc]     
    127127        self.outputs['Positive fraction'] = ["P^+", "a.u.", self.pos]     
    128         self.outputs['1-sigma positive fraction'] = ["P^+_{1\ \sigma}", "a.u.", self.pos_err]     
     128        self.outputs['1-sigma positive fraction'] = ["P^+_{1\ \sigma}",  
     129                                                     "a.u.", self.pos_err]     
    129130        self.outputs['Rg'] = ["R_g", "A", self.rg]     
    130131        self.outputs['I(q=0)'] = ["I(q=0)", "1/A", self.iq0]     
     
    157158         
    158159        # Control for number of points 
    159         self.npts_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
     160        self.npts_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     161                                   size=(60,20)) 
    160162        # Control for the minimum value of D_max 
    161         self.dmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
     163        self.dmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     164                                   size=(60,20)) 
    162165        # Control for the maximum value of D_max 
    163         self.dmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
     166        self.dmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     167                                   size=(60,20)) 
    164168 
    165169        # Output selection box for the y axis 
     
    167171 
    168172        # Create the plot object 
    169         self.plotpanel = OutputPlot(self._default_min, self._default_max, self, -1, style=wx.RAISED_BORDER) 
     173        self.plotpanel = OutputPlot(self._default_min, self._default_max, 
     174                                    self, -1, style=wx.RAISED_BORDER) 
    170175         
    171176        # Create the layout of the dialog 
     
    258263            self.plotpanel.plot.y = self.results.outputs[output_type][2] 
    259264            self.plotpanel.plot.name = '_nolegend_' 
    260             self.plotpanel.graph.yaxis("\\rm{%s}" % self.results.outputs[output_type][0], self.results.outputs[output_type][1]) 
     265            y_label = "\\rm{%s}" % self.results.outputs[output_type][0] 
     266            self.plotpanel.graph.yaxis(y_label, 
     267                                       self.results.outputs[output_type][1]) 
    261268             
    262269            # Redraw 
     
    264271            self.plotpanel.subplot.figure.canvas.draw_idle() 
    265272        else: 
    266             msg =  "ExploreDialog: the Results object's dictionary does not contain " 
    267             msg += "the [%s] output type. This must be indicative of a change in the " % str(output_type) 
     273            msg =  "ExploreDialog: the Results object's dictionary " 
     274            msg += "does not contain " 
     275            msg += "the [%s] output type. This must be indicative of " 
     276            msg += "a change in the " % str(output_type) 
    268277            msg += "ExploreDialog code." 
    269278            logging.error(msg) 
     
    279288        sizer_main = wx.BoxSizer(wx.VERTICAL) 
    280289        sizer_button = wx.BoxSizer(wx.HORIZONTAL) 
    281         sizer_params = wx.GridBagSizer(5,5) 
     290        sizer_params = wx.GridBagSizer(5, 5) 
    282291 
    283292        iy = 0 
    284293        ix = 0 
    285294        label_npts  = wx.StaticText(self, -1, "Npts") 
    286         sizer_params.Add(label_npts, (iy,ix), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     295        sizer_params.Add(label_npts, (iy, ix), (1, 1),  
     296                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    287297        ix += 1 
    288         sizer_params.Add(self.npts_ctl,   (iy,ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     298        sizer_params.Add(self.npts_ctl,   (iy, ix), (1, 1),  
     299                         wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    289300        self.npts_ctl.SetValue("%g" % DEFAULT_NPTS) 
    290301        self.npts_ctl.Bind(wx.EVT_KILL_FOCUS, self._recalc) 
     
    292303        ix += 1 
    293304        label_dmin   = wx.StaticText(self, -1, "Min Distance [A]") 
    294         sizer_params.Add(label_dmin, (iy,ix), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     305        sizer_params.Add(label_dmin, (iy, ix), (1, 1), 
     306                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    295307        ix += 1 
    296         sizer_params.Add(self.dmin_ctl,   (iy,ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     308        sizer_params.Add(self.dmin_ctl, (iy, ix), (1, 1), 
     309                         wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    297310        self.dmin_ctl.SetValue(str(self._default_min)) 
    298311        self.dmin_ctl.Bind(wx.EVT_KILL_FOCUS, self._recalc) 
     
    300313        ix += 1 
    301314        label_dmax = wx.StaticText(self, -1, "Max Distance [A]") 
    302         sizer_params.Add(label_dmax, (iy,ix), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     315        sizer_params.Add(label_dmax, (iy, ix), (1, 1), 
     316                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    303317        ix += 1 
    304         sizer_params.Add(self.dmax_ctl,   (iy,ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     318        sizer_params.Add(self.dmax_ctl,   (iy, ix), (1, 1), 
     319                         wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    305320        self.dmax_ctl.SetValue(str(self._default_max)) 
    306321        self.dmax_ctl.Bind(wx.EVT_KILL_FOCUS, self._recalc) 
     
    314329        self.output_box.SetStringSelection(DEFAULT_OUTPUT) 
    315330         
    316         output_sizer = wx.GridBagSizer(5,5) 
    317         output_sizer.Add(selection_msg, (0,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    318         output_sizer.Add(self.output_box, (0,1), (1,2), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    319          
    320         wx.EVT_COMBOBOX(self.output_box,-1, self._plot_output)  
     331        output_sizer = wx.GridBagSizer(5, 5) 
     332        output_sizer.Add(selection_msg, (0, 0), (1, 1), 
     333                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
     334        output_sizer.Add(self.output_box, (0, 1), (1, 2), 
     335                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
     336         
     337        wx.EVT_COMBOBOX(self.output_box, -1, self._plot_output)  
    321338        sizer_main.Add(output_sizer, 0, wx.EXPAND | wx.ALL, 10) 
    322339         
    323340        sizer_main.Add(self.plotpanel, 0, wx.EXPAND | wx.ALL, 10) 
    324         sizer_main.SetItemMinSize(self.plotpanel, 400,400) 
     341        sizer_main.SetItemMinSize(self.plotpanel, 400, 400) 
    325342         
    326343        sizer_main.Add(sizer_params, 0, wx.EXPAND|wx.ALL, 10) 
     
    357374         
    358375        # Loop over d_max values 
    359         for i in range(content.npts):     
    360             d = content.dmin + i * (content.dmax - content.dmin)/(content.npts-1.0) 
     376        for i in range(content.npts):  
     377            temp = (content.dmax - content.dmin)/(content.npts - 1.0)    
     378            d = content.dmin + i * temp 
     379                 
    361380            self.pr_state.d_max = d 
    362381            try: 
     
    380399            except: 
    381400                # This inversion failed, skip this D_max value 
    382                 logging.error("ExploreDialog: inversion failed for D_max=%s\n%s" % (str(d), sys.exc_value)) 
     401                msg = "ExploreDialog: inversion failed " 
     402                msg += "for D_max=%s\n%s" % (str(d), sys.exc_value) 
     403                logging.error(msg) 
    383404             
    384405        self.results = results             
  • prview/perspectives/pr/inversion_panel.py

    rb35d3d1 r3e41f43  
    1212from sans.guicomm.events import StatusEvent     
    1313from inversion_state import InversionState 
    14 from pr_widgets import PrTextCtrl, DataFileTextCtrl, OutputTextCtrl 
     14from pr_widgets import PrTextCtrl 
     15from pr_widgets import DataFileTextCtrl 
     16from pr_widgets import OutputTextCtrl 
    1517 
    1618 
     
    2830    oscillation_max = 1.5 
    2931     
    30     def __init__(self, parent, id = -1, plots = None, standalone=False, **kwargs): 
    31         """ 
    32         """ 
    33         ScrolledPanel.__init__(self, parent, id = id, **kwargs) 
     32    def __init__(self, parent, id=-1, plots=None,  
     33                 standalone=False, **kwargs): 
     34        """ 
     35        """ 
     36        ScrolledPanel.__init__(self, parent, id=id, **kwargs) 
    3437        self.SetupScrolling() 
    3538         
     
    9194        Allow direct hooks to text boxes 
    9295        """ 
    93         if name=='nfunc': 
     96        if name == 'nfunc': 
    9497            self.nfunc_ctl.SetValue(str(int(value))) 
    95         elif name=='d_max': 
     98        elif name == 'd_max': 
    9699            self.dmax_ctl.SetValue(str(value)) 
    97         elif name=='alpha': 
     100        elif name == 'alpha': 
    98101            self.alpha_ctl.SetValue(str(value)) 
    99         elif name=='chi2': 
     102        elif name == 'chi2': 
    100103            self.chi2_ctl.SetValue("%-5.2g" % value) 
    101         elif name=='bck': 
     104        elif name == 'bck': 
    102105            self.bck_ctl.SetValue("%-5.2g" % value) 
    103         elif name=='q_min': 
     106        elif name == 'q_min': 
    104107            self.qmin_ctl.SetValue("%-5.2g" % value) 
    105         elif name=='q_max': 
     108        elif name == 'q_max': 
    106109            self.qmax_ctl.SetValue("%-5.2g" % value) 
    107         elif name=='elapsed': 
     110        elif name == 'elapsed': 
    108111            self.time_ctl.SetValue("%-5.2g" % value) 
    109         elif name=='rg': 
     112        elif name ==' rg': 
    110113            self.rg_ctl.SetValue("%-5.2g" % value) 
    111         elif name=='iq0': 
     114        elif name == 'iq0': 
    112115            self.iq0_ctl.SetValue("%-5.2g" % value) 
    113         elif name=='oscillation': 
     116        elif name == 'oscillation': 
    114117            self.osc_ctl.SetValue("%-5.2g" % value) 
    115         elif name=='slit_width': 
     118        elif name == 'slit_width': 
    116119            self.swidth_ctl.SetValue("%-5.2g" % value) 
    117         elif name=='slit_height': 
     120        elif name == 'slit_height': 
    118121            self.sheight_ctl.SetValue("%-5.2g" % value) 
    119         elif name=='positive': 
     122        elif name == 'positive': 
    120123            self.pos_ctl.SetValue("%-5.2g" % value) 
    121         elif name=='pos_err': 
     124        elif name == 'pos_err': 
    122125            self.pos_err_ctl.SetValue("%-5.2g" % value) 
    123         elif name=='alpha_estimate': 
     126        elif name == 'alpha_estimate': 
    124127            self.alpha_estimate_ctl.SetToolTipString("Click to accept value.") 
    125128            self.alpha_estimate_ctl.Enable(True) 
     
    127130            #self.alpha_estimate_ctl.Show() 
    128131            #self.label_sugg.Show() 
    129         elif name=='nterms_estimate': 
     132        elif name == 'nterms_estimate': 
    130133            self.nterms_estimate_ctl.SetToolTipString("Click to accept value.") 
    131134            self.nterms_estimate_ctl.Enable(True) 
    132135            self.nterms_estimate_ctl.SetLabel("%-g" % value) 
    133         elif name=='plotname': 
     136        elif name == 'plotname': 
    134137            self.plot_data.SetValue(str(value)) 
    135138            self._on_pars_changed(None) 
    136         elif name=='datafile': 
     139        elif name == 'datafile': 
    137140            self.plot_data.SetValue(str(value)) 
    138141            self._on_pars_changed(None) 
     
    144147        Allow direct hooks to text boxes 
    145148        """ 
    146         if name=='nfunc': 
     149        if name == 'nfunc': 
    147150            try: 
    148151                return int(self.nfunc_ctl.GetValue()) 
    149152            except: 
    150153                return -1 
    151         elif name=='d_max': 
     154        elif name == 'd_max': 
    152155            try: 
    153156                return self.dmax_ctl.GetValue() 
    154157            except: 
    155158                return -1.0 
    156         elif name=='alpha': 
     159        elif name == 'alpha': 
    157160            try: 
    158161                return self.alpha_ctl.GetValue() 
    159162            except: 
    160163                return -1.0 
    161         elif name=='chi2': 
     164        elif name == 'chi2': 
    162165            try: 
    163166                return float(self.chi2_ctl.GetValue()) 
    164167            except: 
    165168                return None 
    166         elif name=='bck': 
     169        elif name == 'bck': 
    167170            try: 
    168171                return float(self.bck_ctl.GetValue()) 
    169172            except: 
    170173                return None 
    171         elif name=='q_min': 
     174        elif name == 'q_min': 
    172175            try: 
    173176                return float(self.qmin_ctl.GetValue()) 
     
    179182            except: 
    180183                return 0.0 
    181         elif name=='elapsed': 
     184        elif name == 'elapsed': 
    182185            try: 
    183186                return float(self.time_ctl.GetValue()) 
    184187            except: 
    185188                return None 
    186         elif name=='rg': 
     189        elif name == 'rg': 
    187190            try: 
    188191                return float(self.rg_ctl.GetValue()) 
     
    194197            except: 
    195198                return None 
    196         elif name=='oscillation': 
     199        elif name == 'oscillation': 
    197200            try: 
    198201                return float(self.osc_ctl.GetValue()) 
    199202            except: 
    200203                return None 
    201         elif name=='slit_width': 
     204        elif name == 'slit_width': 
    202205            try: 
    203206                return float(self.swidth_ctl.GetValue()) 
     
    209212            except: 
    210213                return None 
    211         elif name=='pos': 
     214        elif name == 'pos': 
    212215            try: 
    213216                return float(self.pos_ctl.GetValue()) 
    214217            except: 
    215218                return None 
    216         elif name=='pos_err': 
     219        elif name == 'pos_err': 
    217220            try: 
    218221                return float(self.pos_err_ctl.GetValue()) 
    219222            except: 
    220223                return None 
    221         elif name=='alpha_estimate': 
     224        elif name == 'alpha_estimate': 
    222225            try: 
    223226                return float(self.alpha_estimate_ctl.GetLabel()) 
    224227            except: 
    225228                return None 
    226         elif name=='nterms_estimate': 
     229        elif name == 'nterms_estimate': 
    227230            try: 
    228231                return int(self.nterms_estimate_ctl.GetLabel()) 
    229232            except: 
    230233                return None 
    231         elif name=='plotname': 
     234        elif name == 'plotname': 
    232235            return self.plot_data.GetValue() 
    233         elif name=='datafile': 
     236        elif name == 'datafile': 
    234237            return self.plot_data.GetValue() 
    235238        else: 
     
    244247        # Ask the user the location of the file to write to. 
    245248        path = None 
    246         dlg = wx.FileDialog(self, "Choose a file", self._default_save_location, "", "*.prv", wx.SAVE) 
     249        dlg = wx.FileDialog(self, "Choose a file", 
     250                            self._default_save_location, "", "*.prv", wx.SAVE) 
    247251        if dlg.ShowModal() == wx.ID_OK: 
    248252            path = dlg.GetPath() 
     
    372376         
    373377        boxsizer1 = wx.StaticBoxSizer(databox, wx.VERTICAL) 
    374         boxsizer1.SetMinSize((self._default_width,50)) 
    375         pars_sizer = wx.GridBagSizer(5,5) 
     378        boxsizer1.SetMinSize((self._default_width, 50)) 
     379        pars_sizer = wx.GridBagSizer(5, 5) 
    376380 
    377381        iy = 0 
    378382        self.file_radio = wx.StaticText(self, -1, "Data:") 
    379         pars_sizer.Add(self.file_radio, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     383        pars_sizer.Add(self.file_radio, (iy, 0), (1, 1), 
     384                       wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    380385         
    381386        self.plot_data = DataFileTextCtrl(self, -1, size=(260,20)) 
    382387         
    383         pars_sizer.Add(self.plot_data, (iy,1), (1,1), wx.EXPAND|wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 15) 
     388        pars_sizer.Add(self.plot_data, (iy, 1), (1, 1), 
     389                       wx.EXPAND|wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 15) 
    384390         
    385391        self.bck_chk = wx.CheckBox(self, -1, "Estimate background level") 
    386         self.bck_chk.SetToolTipString("Check box to let the fit estimate the constant background level.") 
     392        hint_msg = "Check box to let the fit estimate " 
     393        hint_msg += "the constant background level." 
     394        self.bck_chk.SetToolTipString(hint_msg) 
    387395        self.bck_chk.Bind(wx.EVT_CHECKBOX, self._on_pars_changed) 
    388396        iy += 1 
    389         pars_sizer.Add(self.bck_chk, (iy,0), (1,2), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     397        pars_sizer.Add(self.bck_chk, (iy, 0), (1, 2), 
     398                       wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    390399        boxsizer1.Add(pars_sizer, 0, wx.EXPAND)   
    391         vbox.Add(boxsizer1, (iy_vb,0), (1,1), wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE|wx.TOP, 5) 
     400        vbox.Add(boxsizer1, (iy_vb, 0), (1, 1), 
     401                 wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE|wx.TOP, 5) 
    392402         
    393403        # ----- Add slit parameters ----- 
     
    395405            sbox = wx.StaticBox(self, -1, "Slit parameters") 
    396406            sboxsizer = wx.StaticBoxSizer(sbox, wx.VERTICAL) 
    397             sboxsizer.SetMinSize((self._default_width,20)) 
     407            sboxsizer.SetMinSize((self._default_width, 20)) 
    398408             
    399             sizer_slit = wx.GridBagSizer(5,5) 
    400      
    401             label_sheight = wx.StaticText(self, -1, "Height", size=(40,20)) 
    402             label_swidth = wx.StaticText(self, -1, "Width", size=(40,20)) 
     409            sizer_slit = wx.GridBagSizer(5, 5) 
     410     
     411            label_sheight = wx.StaticText(self, -1, "Height", size=(40, 20)) 
     412            label_swidth = wx.StaticText(self, -1, "Width", size=(40, 20)) 
    403413            #label_sunits1 = wx.StaticText(self, -1, "[A^(-1)]") 
    404414            label_sunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55,20)) 
    405             self.sheight_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
    406             self.swidth_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
    407             self.sheight_ctl.SetToolTipString("Enter slit height in units of Q or leave blank.") 
    408             self.swidth_ctl.SetToolTipString("Enter slit width in units of Q or leave blank.") 
     415            self.sheight_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     416                                          size=(60,20)) 
     417            self.swidth_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     418                                         size=(60,20)) 
     419            hint_msg = "Enter slit height in units of Q or leave blank." 
     420            self.sheight_ctl.SetToolTipString(hint_msg) 
     421            hint_msg = "Enter slit width in units of Q or leave blank." 
     422            self.swidth_ctl.SetToolTipString(hint_msg) 
    409423            #self.sheight_ctl.Bind(wx.EVT_TEXT, self._on_pars_changed) 
    410424            #self.swidth_ctl.Bind(wx.EVT_TEXT,  self._on_pars_changed) 
    411425             
    412426            iy = 0 
    413             sizer_slit.Add(label_sheight,    (iy,0), (1,1), wx.LEFT|wx.EXPAND, 5) 
    414             sizer_slit.Add(self.sheight_ctl, (iy,1), (1,1), wx.LEFT|wx.EXPAND, 5) 
    415             #sizer_slit.Add(label_sunits1,    (iy,2), (1,1), wx.LEFT|wx.EXPAND, 10) 
    416             sizer_slit.Add(label_swidth,     (iy,2), (1,1), wx.LEFT|wx.EXPAND, 5) 
    417             sizer_slit.Add(self.swidth_ctl,  (iy,3), (1,1), wx.LEFT|wx.EXPAND, 5) 
    418             sizer_slit.Add(label_sunits2,    (iy,4), (1,1), wx.LEFT|wx.EXPAND, 5) 
     427            sizer_slit.Add(label_sheight,    (iy, 0), (1, 1), 
     428                           wx.LEFT|wx.EXPAND, 5) 
     429            sizer_slit.Add(self.sheight_ctl, (iy, 1), (1, 1), 
     430                           wx.LEFT|wx.EXPAND, 5) 
     431     
     432            sizer_slit.Add(label_swidth,     (iy, 2), (1, 1), 
     433                           wx.LEFT|wx.EXPAND, 5) 
     434            sizer_slit.Add(self.swidth_ctl,  (iy, 3), (1, 1), 
     435                           wx.LEFT|wx.EXPAND, 5) 
     436            sizer_slit.Add(label_sunits2,    (iy, 4), (1, 1), 
     437                           wx.LEFT|wx.EXPAND, 5) 
    419438             
    420439            sboxsizer.Add(sizer_slit, wx.TOP, 15) 
    421440            iy_vb += 1 
    422             vbox.Add(sboxsizer, (iy_vb,0), (1,1), wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 
     441            vbox.Add(sboxsizer, (iy_vb, 0), (1, 1), 
     442                     wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 
    423443         
    424444         
     
    426446        qbox = wx.StaticBox(self, -1, "Q range") 
    427447        qboxsizer = wx.StaticBoxSizer(qbox, wx.VERTICAL) 
    428         qboxsizer.SetMinSize((self._default_width,20)) 
    429          
    430         sizer_q = wx.GridBagSizer(5,5) 
    431  
    432         label_qmin = wx.StaticText(self, -1, "Q min", size=(40,20)) 
    433         label_qmax = wx.StaticText(self, -1, "Q max", size=(40,20)) 
     448        qboxsizer.SetMinSize((self._default_width, 20)) 
     449         
     450        sizer_q = wx.GridBagSizer(5, 5) 
     451 
     452        label_qmin = wx.StaticText(self, -1, "Q min", size=(40, 20)) 
     453        label_qmax = wx.StaticText(self, -1, "Q max", size=(40, 20)) 
    434454        #label_qunits1 = wx.StaticText(self, -1, "[A^(-1)]") 
    435         label_qunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55,20)) 
    436         self.qmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
    437         self.qmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
    438         self.qmin_ctl.SetToolTipString("Select a lower bound for Q or leave blank.") 
    439         self.qmax_ctl.SetToolTipString("Select an upper bound for Q or leave blank.") 
     455        label_qunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55, 20)) 
     456        self.qmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     457                                   size=(60,20)) 
     458        self.qmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     459                                   size=(60,20)) 
     460        hint_msg = "Select a lower bound for Q or leave blank." 
     461        self.qmin_ctl.SetToolTipString(hint_msg) 
     462        hint_msg = "Select an upper bound for Q or leave blank." 
     463        self.qmax_ctl.SetToolTipString(hint_msg) 
    440464        self.qmin_ctl.Bind(wx.EVT_TEXT, self._on_pars_changed) 
    441465        self.qmax_ctl.Bind(wx.EVT_TEXT, self._on_pars_changed) 
    442466         
    443467        iy = 0 
    444         sizer_q.Add(label_qmin,    (iy,0), (1,1), wx.LEFT|wx.EXPAND, 5) 
    445         sizer_q.Add(self.qmin_ctl, (iy,1), (1,1), wx.LEFT|wx.EXPAND, 5) 
     468        sizer_q.Add(label_qmin,    (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 5) 
     469        sizer_q.Add(self.qmin_ctl, (iy, 1), (1, 1), wx.LEFT|wx.EXPAND, 5) 
    446470        #sizer_q.Add(label_qunits1, (iy,2), (1,1), wx.LEFT|wx.EXPAND, 15) 
    447         sizer_q.Add(label_qmax,    (iy,2), (1,1), wx.LEFT|wx.EXPAND, 5) 
    448         sizer_q.Add(self.qmax_ctl, (iy,3), (1,1), wx.LEFT|wx.EXPAND, 5) 
    449         sizer_q.Add(label_qunits2, (iy,4), (1,1), wx.LEFT|wx.EXPAND, 5) 
     471        sizer_q.Add(label_qmax,    (iy, 2), (1, 1), wx.LEFT|wx.EXPAND, 5) 
     472        sizer_q.Add(self.qmax_ctl, (iy, 3), (1, 1), wx.LEFT|wx.EXPAND, 5) 
     473        sizer_q.Add(label_qunits2, (iy, 4), (1, 1), wx.LEFT|wx.EXPAND, 5) 
    450474        qboxsizer.Add(sizer_q, wx.TOP, 15) 
    451475 
    452476        iy_vb += 1 
    453         vbox.Add(qboxsizer, (iy_vb,0), (1,1), wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 
    454          
    455          
    456          
    457  
     477        vbox.Add(qboxsizer, (iy_vb,0), (1,1), 
     478                 wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 
     479     
    458480        # ----- Parameters ----- 
    459481        parsbox = wx.StaticBox(self, -1, "Parameters") 
     
    461483        boxsizer2.SetMinSize((self._default_width,50)) 
    462484         
    463         explanation  = "P(r) is found by fitting a set of base functions to I(Q). " 
    464         explanation += "The minimization involves a regularization term to ensure " 
    465         explanation += "a smooth P(r). The regularization constant gives the size of that "   
    466         explanation += "term. The suggested value is the value above which the " 
    467         explanation += "output P(r) will have only one peak." 
     485        explanation  = "P(r) is found by fitting a set of base functions" 
     486        explanation += " to I(Q). The minimization involves" 
     487        explanation += " a regularization term to ensure a smooth P(r)." 
     488        explanation += " The regularization constant gives the size of that "   
     489        explanation += "term. The suggested value is the value above which the" 
     490        explanation += " output P(r) will have only one peak." 
    468491        label_explain = wx.StaticText(self, -1, explanation, size=(280,120)) 
    469492        boxsizer2.Add(label_explain,  wx.LEFT|wx.BOTTOM, 5) 
     
    472495         
    473496        label_nfunc = wx.StaticText(self, -1, "Number of terms") 
    474         label_nfunc.SetMinSize((120,20)) 
     497        label_nfunc.SetMinSize((120, 20)) 
    475498        label_alpha = wx.StaticText(self, -1, "Regularization constant") 
    476499        label_dmax  = wx.StaticText(self, -1, "Max distance [A]") 
     
    478501        #self.label_sugg.Hide() 
    479502         
    480         self.nfunc_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
     503        self.nfunc_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     504                                    size=(60,20)) 
    481505        self.nfunc_ctl.SetToolTipString("Number of terms in the expansion.") 
    482         self.alpha_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
    483         self.alpha_ctl.SetToolTipString("Control parameter for the size of the regularization term.") 
    484         self.dmax_ctl  = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60,20)) 
    485         self.dmax_ctl.SetToolTipString("Maximum distance between any two points in the system.") 
     506        self.alpha_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     507                                    size=(60,20)) 
     508        hint_msg = "Control parameter for the size of the regularization term." 
     509        self.alpha_ctl.SetToolTipString(hint_msg) 
     510        self.dmax_ctl  = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, 
     511                                    size=(60,20)) 
     512        hint_msg = "Maximum distance between any two points in the system." 
     513        self.dmax_ctl.SetToolTipString(hint_msg) 
    486514        id = wx.NewId() 
    487515        self.alpha_estimate_ctl  = wx.Button(self, id, "") 
     
    498526        self.Bind(wx.EVT_BUTTON, self._on_accept_nterms, id = id)    
    499527        self.nterms_estimate_ctl.Enable(False) 
    500         #self.nterms_estimate_ctl.SetBackgroundColour('#ffdf85') 
    501         #self.nterms_estimate_ctl.SetBackgroundColour(self.GetBackgroundColour()) 
     528       
    502529        self.nterms_estimate_ctl.SetToolTipString("Waiting for estimate...") 
    503530         
     
    515542 
    516543        iy = 0 
    517         sizer_params.Add(self.label_sugg,       (iy,2), (1,1), wx.LEFT, 15) 
     544        sizer_params.Add(self.label_sugg, (iy, 2), (1, 1), wx.LEFT, 15) 
    518545        iy += 1 
    519         sizer_params.Add(label_nfunc,      (iy,0), (1,1), wx.LEFT, 15) 
    520         sizer_params.Add(self.nfunc_ctl,   (iy,1), (1,1), wx.RIGHT, 0) 
    521         sizer_params.Add(self.nterms_estimate_ctl, (iy,2), (1,1), wx.LEFT, 15) 
     546        sizer_params.Add(label_nfunc,      (iy, 0), (1, 1), wx.LEFT, 15) 
     547        sizer_params.Add(self.nfunc_ctl,   (iy, 1), (1, 1), wx.RIGHT, 0) 
     548        sizer_params.Add(self.nterms_estimate_ctl, (iy, 2), (1, 1), wx.LEFT, 15) 
    522549        iy += 1 
    523         sizer_params.Add(label_alpha,      (iy,0), (1,1), wx.LEFT, 15) 
    524         sizer_params.Add(self.alpha_ctl,   (iy,1), (1,1), wx.RIGHT, 0) 
    525         sizer_params.Add(self.alpha_estimate_ctl, (iy,2), (1,1), wx.LEFT, 15) 
     550        sizer_params.Add(label_alpha,      (iy, 0), (1, 1), wx.LEFT, 15) 
     551        sizer_params.Add(self.alpha_ctl,   (iy, 1), (1, 1), wx.RIGHT, 0) 
     552        sizer_params.Add(self.alpha_estimate_ctl, (iy, 2), (1, 1), wx.LEFT, 15) 
    526553        iy += 1 
    527         sizer_params.Add(label_dmax, (iy,0), (1,1), wx.LEFT, 15) 
    528         sizer_params.Add(self.dmax_ctl,   (iy,1), (1,1), wx.RIGHT, 0) 
    529         sizer_params.Add(self.distance_explorator_ctl,   (iy,2), (1,1), wx.LEFT, 15) 
     554        sizer_params.Add(label_dmax, (iy, 0), (1, 1), wx.LEFT, 15) 
     555        sizer_params.Add(self.dmax_ctl,   (iy, 1), (1, 1), wx.RIGHT, 0) 
     556        sizer_params.Add(self.distance_explorator_ctl, (iy, 2), 
     557                         (1, 1), wx.LEFT, 15) 
    530558 
    531559        boxsizer2.Add(sizer_params, 0) 
    532560         
    533561        iy_vb += 1 
    534         vbox.Add(boxsizer2, (iy_vb,0), (1,1), wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 
     562        vbox.Add(boxsizer2, (iy_vb, 0), (1, 1), 
     563                 wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 
    535564 
    536565 
     
    538567        resbox = wx.StaticBox(self, -1, "Outputs") 
    539568        ressizer = wx.StaticBoxSizer(resbox, wx.VERTICAL) 
    540         ressizer.SetMinSize((self._default_width,50)) 
     569        ressizer.SetMinSize((self._default_width, 50)) 
    541570         
    542571        label_rg       = wx.StaticText(self, -1, "Rg") 
     
    547576        label_bck_unit = wx.StaticText(self, -1, "[A^(-1)]") 
    548577        self.rg_ctl    = OutputTextCtrl(self, -1, size=(60,20)) 
    549         self.rg_ctl.SetToolTipString("Radius of gyration for the computed P(r).") 
     578        hint_msg = "Radius of gyration for the computed P(r)." 
     579        self.rg_ctl.SetToolTipString(hint_msg) 
    550580        self.iq0_ctl   = OutputTextCtrl(self, -1, size=(60,20)) 
    551         self.iq0_ctl.SetToolTipString("Scattering intensity at Q=0 for the computed P(r).") 
     581        hint_msg = "Scattering intensity at Q=0 for the computed P(r)." 
     582        self.iq0_ctl.SetToolTipString(hint_msg) 
    552583        self.bck_ctl   = OutputTextCtrl(self, -1, size=(60,20)) 
    553584        self.bck_ctl.SetToolTipString("Value of estimated constant background.") 
     
    562593         
    563594        self.time_ctl = OutputTextCtrl(self, -1, size=(60,20)) 
    564         self.time_ctl.SetToolTipString("Computation time for the last inversion, in seconds.") 
     595        hint_msg = "Computation time for the last inversion, in seconds." 
     596        self.time_ctl.SetToolTipString(hint_msg) 
    565597         
    566598        self.chi2_ctl = OutputTextCtrl(self, -1, size=(60,20)) 
     
    569601        # Oscillation parameter 
    570602        self.osc_ctl = OutputTextCtrl(self, -1, size=(60,20)) 
    571         self.osc_ctl.SetToolTipString("Oscillation parameter. P(r) for a sphere has an oscillation parameter of 1.1.") 
     603        hint_msg = "Oscillation parameter. P(r) for a sphere has an " 
     604        hint_msg += " oscillation parameter of 1.1." 
     605        self.osc_ctl.SetToolTipString(hint_msg) 
    572606         
    573607        # Positive fraction figure of merit 
    574608        self.pos_ctl = OutputTextCtrl(self, -1, size=(60,20)) 
    575         self.pos_ctl.SetToolTipString("Fraction of P(r) that is positive. Theoretically, P(r) is defined positive.") 
     609        hint_msg = "Fraction of P(r) that is positive. " 
     610        hint_msg += "Theoretically, P(r) is defined positive." 
     611        self.pos_ctl.SetToolTipString(hint_msg) 
    576612         
    577613        # 1-simga positive fraction figure of merit 
    578614        self.pos_err_ctl = OutputTextCtrl(self, -1, size=(60,20)) 
    579         message  = "Fraction of P(r) that is at least 1 standard deviation greater than zero.\n" 
    580         message += "This figure of merit tells you about the size of the P(r) errors.\n" 
    581         message += "If it is close to 1 and the other figures of merit are bad, consider changing " 
    582         message += "the maximum distance." 
     615        message  = "Fraction of P(r) that is at least 1 standard deviation" 
     616        message += " greater than zero.\n" 
     617        message += "This figure of merit tells you about the size of the " 
     618        message += "P(r) errors.\n" 
     619        message += "If it is close to 1 and the other figures of merit are bad," 
     620        message += " consider changing the maximum distance." 
    583621        self.pos_err_ctl.SetToolTipString(message) 
    584622         
    585         sizer_res = wx.GridBagSizer(5,5) 
     623        sizer_res = wx.GridBagSizer(5, 5) 
    586624 
    587625        iy = 0 
    588         sizer_res.Add(label_rg, (iy,0), (1,1), wx.LEFT|wx.EXPAND, 15) 
    589         sizer_res.Add(self.rg_ctl,   (iy,1), (1,1), wx.RIGHT|wx.EXPAND, 15) 
    590         sizer_res.Add(label_rg_unit,   (iy,2), (1,1), wx.RIGHT|wx.EXPAND, 15) 
     626        sizer_res.Add(label_rg, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15) 
     627        sizer_res.Add(self.rg_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
     628        sizer_res.Add(label_rg_unit,   (iy, 2), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
    591629        iy += 1 
    592         sizer_res.Add(label_iq0, (iy,0), (1,1), wx.LEFT|wx.EXPAND, 15) 
    593         sizer_res.Add(self.iq0_ctl,   (iy,1), (1,1), wx.RIGHT|wx.EXPAND, 15) 
    594         sizer_res.Add(label_iq0_unit,   (iy,2), (1,1), wx.RIGHT|wx.EXPAND, 15) 
     630        sizer_res.Add(label_iq0, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15) 
     631        sizer_res.Add(self.iq0_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
     632        sizer_res.Add(label_iq0_unit, (iy, 2), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
    595633        iy += 1 
    596         sizer_res.Add(label_bck, (iy,0), (1,1), wx.LEFT|wx.EXPAND, 15) 
    597         sizer_res.Add(self.bck_ctl,   (iy,1), (1,1), wx.RIGHT|wx.EXPAND, 15) 
    598         sizer_res.Add(label_bck_unit,   (iy,2), (1,1), wx.RIGHT|wx.EXPAND, 15) 
     634        sizer_res.Add(label_bck, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15) 
     635        sizer_res.Add(self.bck_ctl, (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
     636        sizer_res.Add(label_bck_unit, (iy, 2), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
    599637        iy += 1 
    600         sizer_res.Add(label_time, (iy,0), (1,1), wx.LEFT|wx.EXPAND, 15) 
    601         sizer_res.Add(self.time_ctl,   (iy,1), (1,1), wx.RIGHT|wx.EXPAND, 15) 
    602         sizer_res.Add(label_time_unit,   (iy,2), (1,1), wx.RIGHT|wx.EXPAND, 15) 
     638        sizer_res.Add(label_time, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15) 
     639        sizer_res.Add(self.time_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
     640        sizer_res.Add(label_time_unit, (iy, 2), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
    603641        iy += 1 
    604         sizer_res.Add(label_chi2, (iy,0), (1,1), wx.LEFT|wx.EXPAND, 15) 
    605         sizer_res.Add(self.chi2_ctl,   (iy,1), (1,1), wx.RIGHT|wx.EXPAND, 15) 
     642        sizer_res.Add(label_chi2, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15) 
     643        sizer_res.Add(self.chi2_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
    606644        iy += 1 
    607         sizer_res.Add(label_osc, (iy,0), (1,1), wx.LEFT|wx.EXPAND, 15) 
    608         sizer_res.Add(self.osc_ctl,   (iy,1), (1,1), wx.RIGHT|wx.EXPAND, 15) 
     645        sizer_res.Add(label_osc, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15) 
     646        sizer_res.Add(self.osc_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
    609647 
    610648        iy += 1 
    611         sizer_res.Add(label_pos, (iy,0), (1,1), wx.LEFT|wx.EXPAND, 15) 
    612         sizer_res.Add(self.pos_ctl,   (iy,1), (1,1), wx.RIGHT|wx.EXPAND, 15) 
     649        sizer_res.Add(label_pos, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15) 
     650        sizer_res.Add(self.pos_ctl, (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
    613651 
    614652        iy += 1 
    615         sizer_res.Add(label_pos_err, (iy,0), (1,1), wx.LEFT|wx.EXPAND, 15) 
    616         sizer_res.Add(self.pos_err_ctl,   (iy,1), (1,1), wx.RIGHT|wx.EXPAND, 15) 
     653        sizer_res.Add(label_pos_err, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15) 
     654        sizer_res.Add(self.pos_err_ctl,  (iy,1), (1, 1), wx.RIGHT|wx.EXPAND, 15) 
    617655 
    618656        ressizer.Add(sizer_res, 0) 
    619657        iy_vb += 1 
    620         vbox.Add(ressizer, (iy_vb,0), (1,1), wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 
     658        vbox.Add(ressizer, (iy_vb, 0), (1, 1), 
     659                 wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 
    621660 
    622661        # ----- Buttons ----- 
     
    635674        button_Save = wx.Button(self, id, "Save") 
    636675        button_Save.SetToolTipString("Save the current P(r) work to file.") 
    637         self.Bind(wx.EVT_BUTTON, self._save_state, id = id)    
     676        self.Bind(wx.EVT_BUTTON, self._save_state, id=id)    
    638677         
    639678        sizer_button = wx.BoxSizer(wx.HORIZONTAL) 
     
    642681        sizer_button.Add(button_Reset, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10) 
    643682        sizer_button.Add(button_OK, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10) 
    644         #sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)         
     683        
    645684        iy_vb += 1 
    646         vbox.Add(sizer_button, (iy_vb,0), (1,1), wx.EXPAND|wx.BOTTOM|wx.TOP|wx.RIGHT, 10) 
     685        vbox.Add(sizer_button, (iy_vb, 0), (1, 1), 
     686                 wx.EXPAND|wx.BOTTOM|wx.TOP|wx.RIGHT, 10) 
    647687 
    648688        self.Bind(wx.EVT_TEXT_ENTER, self._on_invert) 
     
    661701        except: 
    662702            # No estimate or bad estimate, either do nothing 
    663             import sys 
     703            #import sys 
    664704            print "InversionControl._on_accept_alpha: %s" % sys.exc_value 
    665705            pass 
     
    742782        try: 
    743783            height_str = self.sheight_ctl.GetValue() 
    744             if len(height_str.lstrip().rstrip())==0: 
     784            if len(height_str.lstrip().rstrip()) == 0: 
    745785                height = 0 
    746786            else: 
     
    791831            nfunc = int(self.nfunc_ctl.GetValue()) 
    792832            npts = self.manager.get_npts() 
    793             if npts>0 and nfunc>npts: 
    794                 message = "Number of function terms should be smaller than the number of points" 
     833            if npts > 0 and nfunc > npts: 
     834                message = "Number of function terms should be smaller " 
     835                message += "than the number of points" 
    795836                wx.PostEvent(self.manager.parent, StatusEvent(status=message)) 
    796837                raise ValueError, message 
     
    805846        try: 
    806847            qmin_str = self.qmin_ctl.GetValue() 
    807             if len(qmin_str.lstrip().rstrip())==0: 
     848            if len(qmin_str.lstrip().rstrip()) == 0: 
    808849                qmin = None 
    809850            else: 
     
    819860        try: 
    820861            qmax_str = self.qmax_ctl.GetValue() 
    821             if len(qmax_str.lstrip().rstrip())==0: 
     862            if len(qmax_str.lstrip().rstrip()) == 0: 
    822863                qmax = None 
    823864            else: 
     
    861902            dataset = self.plot_data.GetValue() 
    862903            if dataset==None or len(dataset.strip())==0: 
    863                 message = "No data to invert. Select a data set before proceeding with P(r) inversion." 
     904                message = "No data to invert. Select a data set before" 
     905                message += " proceeding with P(r) inversion." 
    864906                wx.PostEvent(self.manager.parent, StatusEvent(status=message)) 
    865907            else: 
     
    871913                                                  width=width) 
    872914        else: 
    873             message = "The P(r) form contains invalid values: please submit it again." 
     915            message = "The P(r) form contains invalid values: " 
     916            message += "please submit it again." 
    874917            wx.PostEvent(self.parent, StatusEvent(status=message)) 
    875918         
     
    893936                except: 
    894937                    # Invalid data 
    895                     logging.error("InversionControl._change_file: %s" % sys.exc_value)                     
     938                    msg = "InversionControl._change_file: %s" % sys.exc_value 
     939                    logging.error(msg)                     
    896940 
    897941class HelpDialog(wx.Dialog): 
     
    924968        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    925969        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 
    926         #sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)         
     970         
    927971        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 
    928972 
     
    9671011        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    9681012        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 
    969         sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)         
     1013        sizer_button.Add(button_Cancel, 0, 
     1014                         wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)         
    9701015        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 
    9711016 
  • prview/perspectives/pr/inversion_state.py

    rb35d3d1 r3e41f43  
    1111 
    1212 
    13 import time, os, sys 
     13import time 
     14import os 
     15import sys 
    1416import logging 
    15 import DataLoader 
    1617from xml.dom.minidom import parse 
    1718from lxml import etree 
    18  
     19import DataLoader 
    1920from DataLoader.readers.cansas_reader import Reader as CansasReader 
    2021from DataLoader.readers.cansas_reader import get_content 
     
    136137        Compatible with standalone writing, or appending to an 
    137138        already existing XML document. In that case, the XML document 
    138         is required. An optional entry node in the XML document may also be given. 
     139        is required. An optional entry node in the XML document  
     140        may also be given. 
    139141         
    140142        :param file: file to write to 
     
    188190        for item in in_list: 
    189191            element = newdoc.createElement(item[0]) 
    190             exec "element.appendChild(newdoc.createTextNode(str(self.%s)))" % item[1] 
     192            cmd = "element.appendChild(newdoc.createTextNode(str(self.%s)))" 
     193            exec  cmd % item[1] 
    191194            inputs.appendChild(element) 
    192195               
     
    197200        for item in out_list: 
    198201            element = newdoc.createElement(item[0]) 
    199             exec "element.appendChild(newdoc.createTextNode(str(self.%s)))" % item[1] 
     202            cmd = "element.appendChild(newdoc.createTextNode(str(self.%s)))" 
     203            exec  cmd % item[1] 
    200204            outputs.appendChild(element) 
    201205                     
     
    226230        """ 
    227231        if file is not None: 
    228             raise RuntimeError, "InversionState no longer supports non-CanSAS format for P(r) files" 
    229              
    230         if node.get('version')\ 
    231             and node.get('version') == '1.0': 
     232            msg = "InversionState no longer supports non-CanSAS" 
     233            msg += " format for P(r) files" 
     234            raise RuntimeError, msg 
     235             
     236        if node.get('version') and node.get('version') == '1.0': 
    232237             
    233238            # Get file name 
     
    242247                    self.timestamp = float(entry.get('epoch')) 
    243248                except: 
    244                     logging.error("InversionState.fromXML: Could not read timestamp\n %s" % sys.exc_value) 
     249                    msg = "InversionState.fromXML: Could not read " 
     250                    msg += "timestamp\n %s" % sys.exc_value 
     251                    logging.error(msg) 
    245252             
    246253            # Parse inversion inputs 
     
    251258                    if input_field is not None: 
    252259                        try: 
    253                             exec 'self.%s = float(input_field.text.strip())' % item[1] 
     260                            cmd = 'self.%s = float(input_field.text.strip())'  
     261                            exec  cmd % item[1] 
    254262                        except: 
    255263                            exec 'self.%s = None' % item[1] 
     
    269277                    if input_field is not None: 
    270278                        try: 
    271                             exec 'self.%s = float(input_field.text.strip())' % item[1] 
     279                            cmd = 'self.%s = float(input_field.text.strip())' 
     280                            exec  cmd % item[1] 
    272281                        except: 
    273282                            exec 'self.%s = None' % item[1] 
     
    292301                    # Sanity check 
    293302                    if not len(self.coefficients) == self.nfunc: 
    294                         # Inconsistent number of coefficients. Don't keep the data. 
    295                         err_msg = "InversionState.fromXML: inconsistant number of coefficients: " 
    296                         err_msg += "%d %d" % (len(self.coefficients), self.nfunc) 
     303                        # Inconsistent number of coefficients. 
     304                        # Don't keep the data. 
     305                        err_msg = "InversionState.fromXML: inconsistant " 
     306                        err_msg += "number of coefficients: " 
     307                        err_msg += "%d %d" % (len(self.coefficients), 
     308                                              self.nfunc) 
    297309                        logging.error(err_msg) 
    298310                        self.coefficients = None 
     
    328340                        # Inconsistent dimensions of the covariance matrix. 
    329341                        # Don't keep the data. 
    330                         err_msg = "InversionState.fromXML: inconsistant dimensions of the covariance matrix: " 
     342                        err_msg = "InversionState.fromXML: " 
     343                        err_msg += "inconsistant dimensions of the " 
     344                        err_msg += " covariance matrix: " 
    331345                        err_msg += "%d %d" % (len(self.covariance), self.nfunc) 
    332346                        logging.error(err_msg) 
     
    344358            "SANSView files (*.svs)|*.svs"] 
    345359    ## List of allowed extensions 
    346     ext=['.prv', '.PRV', '.svs', '.SVS']   
     360    ext = ['.prv', '.PRV', '.svs', '.SVS']   
    347361     
    348362    def __init__(self, call_back, cansas=True): 
     
    406420        # Locate the P(r) node 
    407421        try: 
    408             nodes = entry.xpath('ns:%s' % PRNODE_NAME, namespaces={'ns': CANSAS_NS}) 
     422            nodes = entry.xpath('ns:%s' % PRNODE_NAME, 
     423                                namespaces={'ns': CANSAS_NS}) 
    409424            if nodes !=[]: 
    410425                # Create an empty state 
     
    412427                state.fromXML(node=nodes[0]) 
    413428        except: 
    414             logging.info("XML document does not contain P(r) information.\n %s" % sys.exc_value) 
     429            msg = "XML document does not contain P(r) " 
     430            msg += "information.\n %s" % sys.exc_value 
     431            logging.info(msg) 
    415432             
    416433        return state 
     
    437454            #TODO: eventually remove the check for .xml once 
    438455            # the P(r) writer/reader is truly complete. 
    439             if  extension.lower() in self.ext or \ 
    440                 extension.lower() == '.xml': 
     456            if  extension.lower() in self.ext or extension.lower() == '.xml': 
    441457                 
    442458                tree = etree.parse(path, parser=etree.ETCompatXMLParser()) 
    443459                # Check the format version number 
    444                 # Specifying the namespace will take care of the file format version  
     460                # Specifying the namespace will take care of the file  
     461                #format version  
    445462                root = tree.getroot() 
    446463                 
    447                 entry_list = root.xpath('/ns:SASroot/ns:SASentry', namespaces={'ns': CANSAS_NS}) 
     464                entry_list = root.xpath('/ns:SASroot/ns:SASentry', 
     465                                        namespaces={'ns': CANSAS_NS}) 
    448466 
    449467                for entry in entry_list: 
     
    460478         
    461479        # Return output consistent with the loader's api 
    462         if len(output)==0: 
     480        if len(output) == 0: 
    463481            return None 
    464         elif len(output)==1: 
     482        elif len(output) == 1: 
    465483            # Call back to post the new state 
    466484            self.call_back(output[0].meta_data['prstate'], datainfo = output[0]) 
     
    498516            datainfo = DataLoader.data_info.Data1D(x=[], y=[])     
    499517        elif not issubclass(datainfo.__class__, DataLoader.data_info.Data1D): 
    500             raise RuntimeError, "The cansas writer expects a Data1D instance: %s" % str(datainfo.__class__.__name__) 
     518            msg = "The cansas writer expects a Data1D " 
     519            msg += "instance: %s" % str(datainfo.__class__.__name__) 
     520            raise RuntimeError, msg 
    501521     
    502522        # Create basic XML document 
  • prview/perspectives/pr/pr.py

    rb35d3d1 r3e41f43  
    3838(NewPrFileEvent, EVT_PR_FILE) = wx.lib.newevent.NewEvent() 
    3939 
    40  
    41 class Plugin: 
     40from sans.guiframe.plugin_base import PluginBase 
     41 
     42class Plugin(PluginBase): 
    4243    """ 
    4344    """ 
     
    4748     
    4849    def __init__(self, standalone=True): 
    49         """ 
    50         """ 
    51         ## Plug-in name 
    52         self.sub_menu = "Pr inversion" 
    53          
    54         ## Reference to the parent window 
    55         self.parent = None 
    56          
     50        PluginBase.__init__(self, name="Pr inversion", standalone=standalone) 
    5751        ## Simulation window manager 
    5852        self.simview = None 
    59          
    60         ## List of panels for the simulation perspective (names) 
    61         self.perspective = [] 
    62          
     53        
    6354        ## State data 
    6455        self.alpha      = self.DEFAULT_ALPHA 
     
    12881279        """ 
    12891280        self.control_panel._change_file(None) 
    1290      
    1291     def get_perspective(self): 
    1292         """ 
    1293             Get the list of panel names for this perspective 
    1294         """ 
    1295         return self.perspective 
    1296      
    1297     def on_perspective(self, event): 
    1298         """ 
    1299             Call back function for the perspective menu item. 
    1300             We notify the parent window that the perspective 
    1301             has changed. 
    1302         """ 
    1303         self.parent.set_perspective(self.perspective) 
    1304      
     1281 
    13051282    def post_init(self): 
    13061283        """ 
     
    13081285            [Somehow openGL needs this call] 
    13091286        """ 
    1310         if self.standalone==True: 
     1287        if self.standalone: 
    13111288            self.parent.set_perspective(self.perspective) 
    13121289   
Note: See TracChangeset for help on using the changeset viewer.