Ignore:
Timestamp:
Mar 4, 2015 1:28:39 PM (9 years ago)
Author:
Doucet, Mathieu <doucetm@…>
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:
2f732b0
Parents:
76aed53
Message:

Take care of white spaces (pylint)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/perspectives/calculator/gen_scatter_panel.py

    r3f5d75b r49ab5d7  
    11""" 
    2 Generic Scattering panel.  
     2Generic Scattering panel. 
    33This module relies on guiframe manager. 
    44""" 
     
    2222from sas.data_util.calcthread import CalcThread 
    2323from sas.guiframe.local_perspectives.plotting.SimplePlot import PlotFrame 
    24 from sas.guiframe.dataFitting import Data2D  
     24from sas.guiframe.dataFitting import Data2D 
    2525from sas.guiframe.dataFitting import Data1D 
    2626from sas.dataloader.data_info import Detector 
     
    2828from sas.guiframe.panel_base import PanelBase 
    2929from sas.guiframe.utils import format_number 
    30 from sas.guiframe.events import StatusEvent   
    31 from sas.calculator import sas_gen  
     30from sas.guiframe.events import StatusEvent 
     31from sas.calculator import sas_gen 
    3232from sas.perspectives.calculator.calculator_widgets import OutputTextCtrl 
    3333from sas.perspectives.calculator.calculator_widgets import InputTextCtrl 
     
    3636from sas.plottools.arrow3d import Arrow3D 
    3737from sas.perspectives.calculator import calculator_widgets as widget 
    38 from sas.guiframe.events import NewPlotEvent     
     38from sas.guiframe.events import NewPlotEvent 
    3939from sas.guiframe.documentation_window import DocumentationWindow 
    4040 
     
    5050    FONT_VARIANT = 1 
    5151_QMAX_DEFAULT = 0.3 
    52 _NPTS_DEFAULT = 50  
     52_NPTS_DEFAULT = 50 
    5353_Q1D_MIN = 0.001 
    5454 
     
    6464                    frame.SetIcon(icon) 
    6565                except: 
    66                     pass   
     66                    pass 
    6767 
    6868def _set_error(panel, item, show_msg=False): 
    69     """  
     69    """ 
    7070    Set_error dialog 
    7171    """ 
     
    7676        msg = "Error: wrong (or out of range) value entered." 
    7777        if panel.parent.parent != None: 
    78             wx.PostEvent(panel.parent.parent,  
    79                      StatusEvent(status=msg, info='Error' ))  
     78            wx.PostEvent(panel.parent.parent, 
     79                     StatusEvent(status=msg, info='Error')) 
    8080            panel.SetFocus() 
    8181    return False 
     
    8888    """ 
    8989    def __init__(self, 
    90                  id=-1, 
    91                  input = None, 
    92                  completefn = None, 
    93                  updatefn   = None, 
     90                 id= -1, 
     91                 input=None, 
     92                 completefn=None, 
     93                 updatefn=None, 
    9494                 #elapsed = 0, 
    95                  yieldtime  = 0.01, 
    96                  worktime   = 0.01): 
     95                 yieldtime=0.01, 
     96                 worktime=0.01): 
    9797        """ 
    9898        """ 
     
    102102                 worktime) 
    103103        self.starttime = 0 
    104         self.id = id  
    105         self.input = input  
     104        self.id = id 
     105        self.input = input 
    106106        self.update_fn = updatefn 
    107          
     107 
    108108    def compute(self): 
    109109        """ 
     
    113113        self.starttime = time.time() 
    114114        self.complete(input=self.input, update=self.update_fn) 
    115              
     115 
    116116class SasGenPanel(ScrolledPanel, PanelBase): 
    117117    """ 
     
    122122    ## Name to appear on the window title bar 
    123123    window_caption = "Generic SAS " 
    124      
     124 
    125125    def __init__(self, parent, *args, **kwds): 
    126         ScrolledPanel.__init__(self, parent, style=wx.RAISED_BORDER,  
     126        ScrolledPanel.__init__(self, parent, style=wx.RAISED_BORDER, 
    127127                               *args, **kwds) 
    128128        #kwds['style'] = wx.SUNKEN_BORDER 
     
    159159        self._create_default_2d_data() 
    160160        wx.CallAfter(self._set_sld_data_helper) 
    161          
     161 
    162162    def _define_structure(self): 
    163163        """ 
     
    180180        self.qrange_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    181181        self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    182         
     182 
    183183    def _layout_data_name(self): 
    184184        """ 
     
    186186        """ 
    187187        data_name_txt = wx.StaticText(self, -1, 'Data: ') 
    188         self.data_name_tcl = OutputTextCtrl(self, -1,  
     188        self.data_name_tcl = OutputTextCtrl(self, -1, 
    189189                                            size=(_BOX_WIDTH * 4, -1)) 
    190190        data_hint = "Loaded data" 
     
    244244                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    245245            self.parameters.append([p_name, ctl, unit]) 
    246                                    
     246 
    247247        self.param_sizer.Add(sizer, 0, wx.LEFT, 10) 
    248      
     248 
    249249    def _layout_hint(self): 
    250250        """ 
    251             Fill the sizer containing hint  
     251            Fill the sizer containing hint 
    252252        """ 
    253253        hint_msg = "We support omf, sld or pdb data files only." 
    254         hint_msg +=  "         " 
     254        hint_msg += "         " 
    255255        if FONT_VARIANT < 1: 
    256             hint_msg +=  "Very " 
     256            hint_msg += "Very " 
    257257        hint_msg += "SLOW drawing -->" 
    258258        hint_txt = wx.StaticText(self, -1, hint_msg) 
    259          
     259 
    260260        id = wx.NewId() 
    261261        self.draw_button = wx.Button(self, id, "Arrow Draw") 
     
    263263        self.draw_button.SetToolTipString(hint_on_draw) 
    264264        self.draw_button.Bind(wx.EVT_BUTTON, self.sld_draw, id=id) 
    265          
     265 
    266266        self.draw_button.Enable(False) 
    267267        self.hint_sizer.AddMany([(hint_txt, 0, wx.LEFT, 15), 
    268268                                 (self.draw_button, 0, wx.LEFT, 7)]) 
    269      
     269 
    270270    def _layout_shape(self): 
    271271        """ 
     
    276276        self.shape_sizer.AddMany([(label_txt, 0, wx.LEFT, 15), 
    277277                                (self.shape_combo, 0, wx.LEFT, 5)]) 
    278      
     278 
    279279    def _fill_shape_combo(self): 
    280280        """ 
    281281        Fill up the shape combo box 
    282282        """ 
    283         shape_combo = wx.ComboBox(self, -1, size=(150, -1),  
    284                                       style=wx.CB_READONLY)  
     283        shape_combo = wx.ComboBox(self, -1, size=(150, -1), 
     284                                      style=wx.CB_READONLY) 
    285285        shape_combo.Append('Rectangular') 
    286286        shape_combo.Append('Ellipsoid') 
     
    288288        shape_combo.SetSelection(0) 
    289289        return shape_combo 
    290      
     290 
    291291    def _on_shape_select(self, event): 
    292292        """ 
     
    294294        """ 
    295295        event.Skip() 
    296         label = event.GetEventObject().GetValue().lower()  
     296        label = event.GetEventObject().GetValue().lower() 
    297297        self.default_shape = label 
    298298        self.parent.set_omfpanel_default_shap(self.default_shape) 
    299299        self.parent.set_omfpanel_npts() 
    300          
     300 
    301301    def _fill_orient_combo(self): 
    302302        """ 
    303303        Fill up the orientation combo box: used only for atomic structure 
    304304        """ 
    305         orient_combo = wx.ComboBox(self, -1, size=(150, -1),  
    306                                       style=wx.CB_READONLY)  
     305        orient_combo = wx.ComboBox(self, -1, size=(150, -1), 
     306                                      style=wx.CB_READONLY) 
    307307        orient_combo.Append('Fixed orientation') 
    308308        orient_combo.Append('Debye full avg.') 
    309309        #orient_combo.Append('Debye sph. sym.') 
    310          
     310 
    311311        orient_combo.Bind(wx.EVT_COMBOBOX, self._on_orient_select) 
    312312        orient_combo.SetSelection(0) 
    313313        return orient_combo 
    314      
     314 
    315315    def _on_orient_select(self, event): 
    316316        """ 
     
    325325            self.is_avg = is_avg 
    326326        self.model.set_is_avg(self.is_avg) 
    327         self.set_est_time()     
    328             
     327        self.set_est_time() 
     328 
    329329    def _layout_qrange(self): 
    330330        """ 
     
    359359        self.qmax_ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH * 1.5, 20), 
    360360                            style=wx.TE_PROCESS_ENTER) 
    361         self.qmax_ctl.Bind(wx.EVT_TEXT, self._onparamEnter ) 
     361        self.qmax_ctl.Bind(wx.EVT_TEXT, self._onparamEnter) 
    362362        self.qmax_ctl.SetValue(format_number(self.qmax_x, True)) 
    363363        sizer.Add(self.qmax_ctl, (iy, ix), (1, 1), wx.EXPAND) 
     
    368368                        wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    369369        self.qrange_sizer.Add(sizer, 0, wx.LEFT, 10) 
    370      
    371     def _layout_button(self):   
     370 
     371    def _layout_button(self): 
    372372        """ 
    373373            Do the layout for the button widgets 
    374         """  
     374        """ 
    375375        self.est_time = '*Estimated Computation time :\n  %s' 
    376         self.time_text = wx.StaticText(self, -1, self.est_time% str('2 sec') ) 
     376        self.time_text = wx.StaticText(self, -1, self.est_time % str('2 sec')) 
    377377        self.orient_combo = self._fill_orient_combo() 
    378378        self.orient_combo.Show(False) 
    379         self.bt_compute = wx.Button(self, wx.NewId(),'Compute') 
     379        self.bt_compute = wx.Button(self, wx.NewId(), 'Compute') 
    380380        self.bt_compute.Bind(wx.EVT_BUTTON, self.on_compute) 
    381381        self.bt_compute.SetToolTipString("Compute 2D Scattering Pattern.") 
    382         self.bt_help = wx.Button(self, wx.NewId(),'HELP') 
     382        self.bt_help = wx.Button(self, wx.NewId(), 'HELP') 
    383383        self.bt_help.Bind(wx.EVT_BUTTON, self.on_help) 
    384384        self.bt_help.SetToolTipString("Help on Scatter Calculator") 
     
    387387                                   (self.bt_compute, 0, wx.LEFT, 20), 
    388388                                   (self.bt_help, 0, wx.LEFT, 5)]) 
    389          
     389 
    390390    def estimate_ctime(self): 
    391391        """ 
     
    401401            n_pixs *= (n_pixs / 200) 
    402402        x_in = n_qbins * n_pixs / 100000 
    403         etime = factor + 0.085973 * x_in  
     403        etime = factor + 0.085973 * x_in 
    404404        return int(etime) 
    405          
     405 
    406406    def set_est_time(self): 
    407407        """ 
     
    417417                self.time_text.SetForegroundColour('red') 
    418418            time_str = str(etime) + ' ' + unit 
    419             self.time_text.SetLabel(self.est_time% time_str) 
    420          
     419            self.time_text.SetLabel(self.est_time % time_str) 
     420 
    421421    def _do_layout(self): 
    422422        """ 
     
    431431        self._layout_button() 
    432432        self.boxsizer_source.AddMany([(self.data_name_sizer, 0, 
    433                                         wx.EXPAND|wx.TOP|wx.BOTTOM, 5), 
     433                                        wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 
    434434                                      (self.hint_sizer, 0, 
    435                                         wx.EXPAND|wx.TOP|wx.BOTTOM, 5), 
    436                                       (self.shape_sizer, 0,  
    437                                         wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 
     435                                        wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 
     436                                      (self.shape_sizer, 0, 
     437                                        wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 
    438438        self.boxsizer_parameters.AddMany([(self.param_sizer, 0, 
    439                                      wx.EXPAND|wx.TOP|wx.BOTTOM, 5),]) 
     439                                     wx.EXPAND | wx.TOP | wx.BOTTOM, 5), ]) 
    440440        self.boxsizer_qrange.AddMany([(self.qrange_sizer, 0, 
    441                                      wx.EXPAND|wx.TOP|wx.BOTTOM, 5),]) 
    442         self.main_sizer.AddMany([(self.boxsizer_source, 0,  
    443                                   wx.EXPAND|wx.ALL, 10), 
    444                                  (self.boxsizer_parameters, 0,  
    445                                   wx.EXPAND|wx.ALL, 10), 
    446                                  (self.boxsizer_qrange, 0,  
    447                                   wx.EXPAND|wx.ALL, 10), 
     441                                     wx.EXPAND | wx.TOP | wx.BOTTOM, 5), ]) 
     442        self.main_sizer.AddMany([(self.boxsizer_source, 0, 
     443                                  wx.EXPAND | wx.ALL, 10), 
     444                                 (self.boxsizer_parameters, 0, 
     445                                  wx.EXPAND | wx.ALL, 10), 
     446                                 (self.boxsizer_qrange, 0, 
     447                                  wx.EXPAND | wx.ALL, 10), 
    448448                                 (self.button_sizer, 0, 
    449                                   wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 
     449                                  wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 
    450450        self.SetSizer(self.main_sizer) 
    451451        self.SetAutoLayout(True) 
    452      
     452 
    453453    def _create_default_sld_data(self): 
    454454        """ 
     
    463463        self.sld_data.filename = "Default SLD Profile" 
    464464        self.sld_data.set_sldn(sld_n_default) 
    465         self.data_name_tcl.SetValue(self.sld_data.filename)        
    466                 
     465        self.data_name_tcl.SetValue(self.sld_data.filename) 
     466 
    467467    def choose_data_file(self, location=None): 
    468468        """ 
     
    477477        exts += ", *" + self.sldreader.ext[0] 
    478478        exts += ", *" + self.pdbreader.ext[0] 
    479         all_type = "All GEN files (%s, %s) | %s"% (exts.upper(), exts.lower(),  
    480                                                exts.lower().replace(',', ';'))         
     479        all_type = "All GEN files (%s, %s) | %s" % (exts.upper(), exts.lower(), 
     480                                               exts.lower().replace(',', ';')) 
    481481        wildcard = [all_type] 
    482482        omf_type = self.omfreader.type 
     
    496496            path = dlg.GetPath() 
    497497            filename = os.path.basename(path) 
    498         dlg.Destroy()  
     498        dlg.Destroy() 
    499499        return path 
    500          
     500 
    501501    def on_load_data(self, event): 
    502502        """ 
     
    508508        path = self.choose_data_file(location=location) 
    509509        if path is None: 
    510             return  
    511          
     510            return 
     511 
    512512        self.shape_sizer.ShowItems(False) 
    513513        self.default_shape = 'rectangular' 
    514514        self.parent.set_omfpanel_default_shap(self.default_shape) 
    515          
     515 
    516516        self.parent.set_file_location(os.path.dirname(path)) 
    517517        try: 
     
    531531            self.browse_button.SetLabel("Loading...") 
    532532            if self.parent.parent is not None: 
    533                 wx.PostEvent(self.parent.parent,  
     533                wx.PostEvent(self.parent.parent, 
    534534                                StatusEvent(status="Loading...", 
    535535                                type="progress")) 
     
    542542            self.ext = None 
    543543            if self.parent.parent is None: 
    544                 return  
     544                return 
    545545            msg = "Generic SAS Calculator: %s" % (sys.exc_value) 
    546546            wx.PostEvent(self.parent.parent, 
    547547                          StatusEvent(status=msg, type='stop')) 
    548548            self.SetFocus() 
    549             return  
    550          
     549            return 
     550 
    551551    def load_update(self): 
    552552        """ 
    553553        print update on the status bar 
    554         """        
     554        """ 
    555555        if self.parent.parent is None: 
    556                 return  
     556                return 
    557557        if self.reader.isrunning(): 
    558558            type = "progress" 
     
    561561        wx.PostEvent(self.parent.parent, StatusEvent(status="", 
    562562                                                  type=type)) 
    563              
     563 
    564564    def complete_loading(self, data=None, filename=''): 
    565565        """ 
     
    596596                raise 
    597597            msg = "Loading Error: This file format is not supported " 
    598             msg += "for GenSAS."  
     598            msg += "for GenSAS." 
    599599            wx.PostEvent(self.parent.parent, 
    600600                          StatusEvent(status=msg, type='stop', info='Error')) 
    601601            self.SetFocus() 
    602             return  
     602            return 
    603603        if self.parent.parent is None: 
    604             return  
    605          
     604            return 
     605 
    606606        msg = "Load Complete" 
    607607        wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 
    608608        self.SetFocus() 
    609          
     609 
    610610    def _set_sld_data_helper(self, is_draw=False): 
    611611        """ 
     
    615615        self.model.set_is_avg(self.is_avg) 
    616616        self.model.set_sld_data(self.sld_data) 
    617          
    618         self.draw_button.Enable(self.sld_data!=None) 
     617 
     618        self.draw_button.Enable(self.sld_data != None) 
    619619        wx.CallAfter(self.parent.set_sld_data, self.sld_data) 
    620620        self._update_model_params() 
    621621        if is_draw: 
    622622            wx.CallAfter(self.sld_draw, None, False) 
    623      
     623 
    624624    def _update_model_params(self): 
    625625        """ 
     
    630630            val = str(self.model.params[param_name]) 
    631631            list[1].SetValue(val) 
    632      
     632 
    633633    def set_volume_ctl_val(self, val): 
    634634        """ 
     
    641641                list[1].Refresh() 
    642642                break 
    643                              
     643 
    644644    def _onparamEnter(self, event): 
    645645        """ 
     
    652652        except: 
    653653            pass 
    654      
     654 
    655655    def sld_draw(self, event=None, has_arrow=True): 
    656656        """ 
     
    668668 
    669669        self.sld_data = self.parent.get_sld_from_omf() 
    670         output = self.sld_data   
     670        output = self.sld_data 
    671671        #frame_size = wx.Size(470, 470)     
    672672        self.plot_frame = PlotFrame(self, -1, 'testView') 
     
    674674        frame.Show(False) 
    675675        add_icon(self.parent, frame) 
    676         panel = frame.plotpanel     
     676        panel = frame.plotpanel 
    677677        try: 
    678678            # mpl >= 1.0.0 
     
    686686                logging.error("PlotPanel could not import Axes3D") 
    687687                raise 
    688         panel.dimension = 3    
     688        panel.dimension = 3 
    689689        graph_title = self._sld_plot_helper(ax, output, has_arrow) 
    690690        # Use y, z axes (in mpl 3d) as z, y axes  
    691691        # that consistent with our SAS detector coords. 
    692         ax.set_xlabel('x ($\A%s$)'% output.pos_unit) 
    693         ax.set_ylabel('z ($\A%s$)'% output.pos_unit) 
    694         ax.set_zlabel('y ($\A%s$)'% output.pos_unit) 
    695         panel.subplot.figure.subplots_adjust(left=0.05, right=0.95,  
     692        ax.set_xlabel('x ($\A%s$)' % output.pos_unit) 
     693        ax.set_ylabel('z ($\A%s$)' % output.pos_unit) 
     694        ax.set_zlabel('y ($\A%s$)' % output.pos_unit) 
     695        panel.subplot.figure.subplots_adjust(left=0.05, right=0.95, 
    696696                                             bottom=0.05, top=0.96) 
    697697        if output.pix_type == 'atom': 
    698698            ax.legend(loc='upper left', prop={'size':10}) 
    699699        num_graph = str(self.graph_num) 
    700         frame.SetTitle('Graph %s: %s'% (num_graph, graph_title))         
     700        frame.SetTitle('Graph %s: %s' % (num_graph, graph_title)) 
    701701        wx.CallAfter(frame.Show, True) 
    702702        self.graph_num += 1 
     
    710710        """ 
    711711        # Set the locals 
    712         color_dic = {'H':'blue', 'D':'purple', 'N': 'orange',  
     712        color_dic = {'H':'blue', 'D':'purple', 'N': 'orange', 
    713713                     'O':'red', 'C':'green', 'P':'cyan', 'Other':'k'} 
    714714        marker = ',' 
     
    721721        sld_mx = output.sld_mx 
    722722        sld_my = output.sld_my 
    723         sld_mz = output.sld_mz  
    724         pix_symbol = output.pix_symbol  
     723        sld_mz = output.sld_mz 
     724        pix_symbol = output.pix_symbol 
    725725        if output.pix_type == 'atom': 
    726726            marker = 'o' 
     
    728728        sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) + \ 
    729729                   numpy.fabs(sld_mz) + numpy.fabs(output.sld_n)) 
    730         is_nonzero = sld_tot > 0.0   
    731         is_zero = sld_tot == 0.0    
     730        is_nonzero = sld_tot > 0.0 
     731        is_zero = sld_tot == 0.0 
    732732        # I. Plot null points 
    733733        if is_zero.any(): 
    734             ax.plot(pos_x[is_zero], pos_z[is_zero], pos_y[is_zero], marker,  
    735                     c="y", alpha=0.5, markeredgecolor='y', markersize=m_size)  
     734            ax.plot(pos_x[is_zero], pos_z[is_zero], pos_y[is_zero], marker, 
     735                    c="y", alpha=0.5, markeredgecolor='y', markersize=m_size) 
    736736            pos_x = pos_x[is_nonzero] 
    737737            pos_y = pos_y[is_nonzero] 
     
    746746            chosen_color = pix_symbol == key 
    747747            if numpy.any(chosen_color): 
    748                 other_color = other_color  & (chosen_color != True) 
     748                other_color = other_color & (chosen_color != True) 
    749749                color = color_dic[key] 
    750                 ax.plot(pos_x[chosen_color], pos_z[chosen_color],  
    751                         pos_y[chosen_color], marker, c=color, alpha=0.5,  
    752                         markeredgecolor=color, markersize=m_size, label=key)  
     750                ax.plot(pos_x[chosen_color], pos_z[chosen_color], 
     751                        pos_y[chosen_color], marker, c=color, alpha=0.5, 
     752                        markeredgecolor=color, markersize=m_size, label=key) 
    753753        # III. Plot All others         
    754754        if numpy.any(other_color): 
     
    764764                        a_name += new_name 
    765765            # plot in black 
    766             ax.plot(pos_x[other_color], pos_z[other_color], pos_y[other_color],  
    767                     marker, c="k", alpha=0.5, markeredgecolor="k",  
    768                     markersize=m_size, label=a_name)  
     766            ax.plot(pos_x[other_color], pos_z[other_color], pos_y[other_color], 
     767                    marker, c="k", alpha=0.5, markeredgecolor="k", 
     768                    markersize=m_size, label=a_name) 
    769769        # IV. Draws atomic bond with grey lines if any 
    770770        if output.has_conect: 
    771771            for ind in range(len(output.line_x)): 
    772                 ax.plot(output.line_x[ind], output.line_z[ind],  
    773                         output.line_y[ind], '-', lw=0.6, c="grey", alpha=0.3)  
     772                ax.plot(output.line_x[ind], output.line_z[ind], 
     773                        output.line_y[ind], '-', lw=0.6, c="grey", alpha=0.3) 
    774774        # V. Draws magnetic vectors 
    775         if has_arrow and len(pos_x) > 0:      
    776             graph_title += " - Magnetic Vector as Arrow -"  
     775        if has_arrow and len(pos_x) > 0: 
     776            graph_title += " - Magnetic Vector as Arrow -" 
    777777            panel = self.plot_frame.plotpanel 
    778778            def _draw_arrow(input=None, update=None): 
     
    785785                max_m = max(max_mx, max_my, max_mz) 
    786786                try: 
    787                     max_step = max(output.xstepsize, output.ystepsize,  
     787                    max_step = max(output.xstepsize, output.ystepsize, 
    788788                                   output.zstepsize) 
    789789                except: 
     
    807807                        z_arrow = numpy.column_stack((pos_z, z2)) 
    808808                        colors = numpy.column_stack((color_x, color_y, color_z)) 
    809                         arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow,  
    810                                         colors, mutation_scale=10, lw=1,  
    811                                         arrowstyle="->", alpha = 0.5) 
    812                         ax.add_artist(arrows)  
     809                        arrows = Arrow3D(panel, x_arrow, z_arrow, y_arrow, 
     810                                        colors, mutation_scale=10, lw=1, 
     811                                        arrowstyle="->", alpha=0.5) 
     812                        ax.add_artist(arrows) 
    813813                except: 
    814                     pass  
     814                    pass 
    815815                msg = "Arrow Drawing completed.\n" 
    816816                status_type = 'stop' 
    817                 self._status_info(msg, status_type)  
     817                self._status_info(msg, status_type) 
    818818            msg = "Arrow Drawing is in progress..." 
    819819            status_type = 'progress' 
    820             self._status_info(msg, status_type)  
     820            self._status_info(msg, status_type) 
    821821            draw_out = CalcGen(input=ax, 
    822822                             completefn=_draw_arrow, updatefn=self._update) 
    823823            draw_out.queue() 
    824824        return graph_title 
    825   
     825 
    826826    def set_input_params(self): 
    827827        """ 
     
    832832            param_value = float(list[1].GetValue()) 
    833833            self.model.setParam(param_name, param_value) 
    834              
     834 
    835835    def on_compute(self, event): 
    836836        """ 
     
    870870                self._create_default_2d_data() 
    871871                i_out = numpy.zeros(len(self.data.data)) 
    872                 inputs=[self.data.qx_data, self.data.qy_data, i_out] 
    873                  
     872                inputs = [self.data.qx_data, self.data.qy_data, i_out] 
     873 
    874874            msg = "Computation is in progress..." 
    875875            status_type = 'progress' 
    876876            self._status_info(msg, status_type) 
    877             cal_out = CalcGen(input=inputs,  
    878                               completefn=self.complete,  
     877            cal_out = CalcGen(input=inputs, 
     878                              completefn=self.complete, 
    879879                              updatefn=self._update) 
    880             cal_out.queue()               
    881              
     880            cal_out.queue() 
     881 
    882882        except: 
    883             msg = "%s."% sys.exc_value 
     883            msg = "%s." % sys.exc_value 
    884884            status_type = 'stop' 
    885885            self._status_info(msg, status_type) 
     
    888888            self.SetFocus() 
    889889 
    890     def on_help(self, event):     
     890    def on_help(self, event): 
    891891        """ 
    892892        Bring up the General scattering Calculator Documentation whenever 
    893         the HELP button is clicked.  
    894          
     893        the HELP button is clicked. 
     894 
    895895        Calls DocumentationWindow with the path of the location within the 
    896         documentation tree (after /doc/ ....".  Note that when using old  
    897         versions of Wx (before 2.9) and thus not the release version of  
    898         installers, the help comes up at the top level of the file as  
     896        documentation tree (after /doc/ ....".  Note that when using old 
     897        versions of Wx (before 2.9) and thus not the release version of 
     898        installers, the help comes up at the top level of the file as 
    899899        webbrowser does not pass anything past the # to the browser when it is 
    900900        running "file:///...." 
    901      
     901 
    902902    :param evt: Triggers on clicking the help button 
    903903    """ 
    904                  
     904 
    905905        _TreeLocation = "user/perspectives/calculator/sas_calculator_help.html" 
    906906        _doc_viewer = DocumentationWindow(self, -1, \ 
    907              _TreeLocation,"General Scattering Calculator Help") 
     907             _TreeLocation, "General Scattering Calculator Help") 
    908908 
    909909    def _check_value(self): 
     
    915915        self.qmax_ctl.SetBackgroundColour("white") 
    916916        try: 
    917             npt_val = float(self.npt_ctl.GetValue())   
     917            npt_val = float(self.npt_ctl.GetValue()) 
    918918            if npt_val < 2 or npt_val > 1000: 
    919919                raise 
     
    921921            self.set_est_time() 
    922922        except: 
    923             flag =  _set_error(self, self.npt_ctl) 
     923            flag = _set_error(self, self.npt_ctl) 
    924924        try: 
    925             qmax_val = float(self.qmax_ctl.GetValue())  
     925            qmax_val = float(self.qmax_ctl.GetValue()) 
    926926            if qmax_val <= 0 or qmax_val > 1000: 
    927927                raise 
    928928        except: 
    929             flag = _set_error(self, self.qmax_ctl)        
     929            flag = _set_error(self, self.qmax_ctl) 
    930930        for list in self.parameters: 
    931931            list[1].SetBackgroundColour("white") 
    932932            param_name = list[0].GetLabelText() 
    933             try:  
     933            try: 
    934934                param_val = float(list[1].GetValue()) 
    935935                if param_name.count('frac') > 0: 
     
    939939                flag = _set_error(self, list[1]) 
    940940        return flag 
    941                     
    942     def _status_info(self, msg = '', type = "update"): 
     941 
     942    def _status_info(self, msg='', type="update"): 
    943943        """ 
    944944        Status msg 
     
    947947            label = "Compute" 
    948948            able = True 
    949         else:    
     949        else: 
    950950            label = "Wait..." 
    951951            able = False 
     
    954954        self.bt_compute.SetToolTipString(label) 
    955955        if self.parent.parent != None: 
    956             wx.PostEvent(self.parent.parent,  
    957                              StatusEvent(status = msg, type = type ))  
     956            wx.PostEvent(self.parent.parent, 
     957                             StatusEvent(status=msg, type=type)) 
    958958 
    959959    def _update(self, time=None): 
     
    967967        wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 
    968968                                                  type=type)) 
    969                                  
    970     def complete(self, input, update=None):    
     969 
     970    def complete(self, input, update=None): 
    971971        """ 
    972972        Gen compute complete function 
     
    980980                    update() 
    981981                    time.sleep(0.1) 
    982                 inputi = [input[0][ind:ind+1], [], input[2][ind:ind+1]] 
     982                inputi = [input[0][ind:ind + 1], [], input[2][ind:ind + 1]] 
    983983                outi = self.model.run(inputi) 
    984984                out = numpy.append(out, outi) 
     
    987987                    update() 
    988988                    time.sleep(0.001) 
    989                 inputi = [input[0][ind:ind+1], input[1][ind:ind+1],  
    990                           input[2][ind:ind+1]] 
     989                inputi = [input[0][ind:ind + 1], input[1][ind:ind + 1], 
     990                          input[2][ind:ind + 1]] 
    991991                outi = self.model.runXY(inputi) 
    992992                out = numpy.append(out, outi) 
     
    997997            #out = self.model.runXY(input) 
    998998            self._draw2D(out) 
    999              
     999 
    10001000        msg = "Gen computation completed.\n" 
    10011001        status_type = 'stop' 
    10021002        self._status_info(msg, status_type) 
    1003                 
     1003 
    10041004    def _create_default_2d_data(self): 
    10051005        """ 
     
    10971097        page_id = self.id 
    10981098        data = self.data 
    1099          
     1099 
    11001100        model = self.model 
    11011101        state = None 
    1102          
     1102 
    11031103        new_plot = Data1D(x=data.x, y=y_out) 
    11041104        new_plot.dx = data.dx 
     
    11121112        new_plot.title = "Generic model1D " 
    11131113        new_plot.id = str(page_id) + ': ' + self.file_name \ 
    1114                         + ' #%s'% str(self.graph_num) + "_1D" 
    1115         new_plot.group_id = str(page_id) + " Model1D"  +\ 
    1116                              ' #%s'% str(self.graph_num) + "_1D" 
     1114                        + ' #%s' % str(self.graph_num) + "_1D" 
     1115        new_plot.group_id = str(page_id) + " Model1D" + \ 
     1116                             ' #%s' % str(self.graph_num) + "_1D" 
    11171117        new_plot.is_data = False 
    11181118 
     
    11221122        new_plot.xaxis(str(_xaxis), str(_xunit)) 
    11231123        new_plot.yaxis(str(_yaxis), str(_yunit)) 
    1124          
     1124 
    11251125        if new_plot.is_data: 
    11261126            data_name = str(new_plot.name) 
     
    11291129 
    11301130        if len(title) > 1: 
    1131             new_plot.title = "Gen Theory for %s "% model.name + data_name 
     1131            new_plot.title = "Gen Theory for %s " % model.name + data_name 
    11321132        new_plot.name = new_plot.id 
    11331133        new_plot.label = new_plot.id 
     
    11391139        title = new_plot.title 
    11401140        num_graph = str(self.graph_num) 
    1141         wx.CallAfter(self.parent.draw_graph, new_plot,  
    1142                      title="GEN Graph %s: "% num_graph + new_plot.id ) 
     1141        wx.CallAfter(self.parent.draw_graph, new_plot, 
     1142                     title="GEN Graph %s: " % num_graph + new_plot.id) 
    11431143        self.graph_num += 1 
    1144                  
     1144 
    11451145    def _draw2D(self, image): 
    11461146        """ 
     
    11501150        page_id = self.id 
    11511151        data = self.data 
    1152          
     1152 
    11531153        model = self.model 
    11541154        qmin = 0.0 
    11551155        state = None 
    1156          
     1156 
    11571157        numpy.nan_to_num(image) 
    11581158        new_plot = Data2D(image=image, err_image=data.err_data) 
     
    11601160        new_plot.title = "Generic model 2D " 
    11611161        new_plot.id = str(page_id) + ': ' + self.file_name \ 
    1162                         + ' #%s'% str(self.graph_num) + "_2D" 
     1162                        + ' #%s' % str(self.graph_num) + "_2D" 
    11631163        new_plot.group_id = str(page_id) + " Model2D" \ 
    1164                         + ' #%s'% str(self.graph_num) + "_2D" 
     1164                        + ' #%s' % str(self.graph_num) + "_2D" 
    11651165        new_plot.detector = data.detector 
    11661166        new_plot.source = data.source 
     
    11801180        new_plot.xaxis(str(_xaxis), str(_xunit)) 
    11811181        new_plot.yaxis(str(_yaxis), str(_yunit)) 
    1182          
     1182 
    11831183        new_plot.is_data = False 
    11841184        if data.is_data: 
     
    11881188 
    11891189        if len(title) > 1: 
    1190             new_plot.title = "Gen Theory for %s "% model.name + data_name 
     1190            new_plot.title = "Gen Theory for %s " % model.name + data_name 
    11911191        new_plot.name = new_plot.id 
    11921192        new_plot.label = new_plot.id 
     
    11981198        title = new_plot.title 
    11991199        num_graph = str(self.graph_num) 
    1200         wx.CallAfter(self.parent.draw_graph, new_plot,  
    1201                      title="GEN Graph %s: "% num_graph + new_plot.id ) 
     1200        wx.CallAfter(self.parent.draw_graph, new_plot, 
     1201                     title="GEN Graph %s: " % num_graph + new_plot.id) 
    12021202        self.graph_num += 1 
    1203           
     1203 
    12041204    def set_scale2d(self, scale): 
    12051205        """ 
     
    12071207        """ 
    12081208        self.scale2d = None 
    1209          
     1209 
    12101210    def on_panel_close(self, event): 
    12111211        """ 
     
    12131213        """ 
    12141214        #Not implemented    
    1215                    
     1215 
    12161216class OmfPanel(ScrolledPanel, PanelBase): 
    12171217    """ 
     
    12221222    ## Name to appear on the window title bar 
    12231223    window_caption = "SLD Pixel Info " 
    1224      
     1224 
    12251225    def __init__(self, parent, *args, **kwds): 
    1226         ScrolledPanel.__init__(self, parent, style=wx.RAISED_BORDER,  
     1226        ScrolledPanel.__init__(self, parent, style=wx.RAISED_BORDER, 
    12271227                               *args, **kwds) 
    12281228        PanelBase.__init__(self) 
    12291229        #Font size  
    12301230        self.SetWindowVariant(variant=FONT_VARIANT) 
    1231         self.SetupScrolling()   
     1231        self.SetupScrolling() 
    12321232        # Object that receive status event 
    12331233        self.parent = parent 
    1234         self.sld_data = sas_gen.MagSLD([0], [0], [0])  
     1234        self.sld_data = sas_gen.MagSLD([0], [0], [0]) 
    12351235        self.sld_ctl = None 
    12361236        self.default_shape = 'rectangular' 
    12371237        self._do_layout() 
    1238         
     1238 
    12391239    def set_slddata(self, slddata): 
    12401240        """ 
     
    12451245        # Make sure that self._set_slddata_ctr_val() is finished 
    12461246        wx.CallAfter(self._set_omfdata_ctr, slddata) 
    1247      
     1247 
    12481248    def get_sld_val(self): 
    12491249        """ 
     
    12851285        self.sld_data.set_sldms(mx, my, mz) 
    12861286        self._set_slddata_ctr_val(self.sld_data) 
    1287          
     1287 
    12881288        return self.sld_data 
    1289      
     1289 
    12901290    def get_pix_volumes(self): 
    12911291        """ 
     
    12931293        """ 
    12941294        vol = self.sld_data.vol_pix 
    1295          
     1295 
    12961296        return vol 
    1297                  
    1298     def _get_other_val(self):   
     1297 
     1298    def _get_other_val(self): 
    12991299        """ 
    13001300        """ 
     
    13161316                    sets[lst[0]] = None 
    13171317                    return 
    1318                      
     1318 
    13191319            for key in sets.keys(): 
    1320                 exec "omfdata.%s = sets['%s']"% (key, key)             
     1320                exec "omfdata.%s = sets['%s']" % (key, key) 
    13211321 
    13221322            omf2sld = sas_gen.OMF2SLD() 
     
    13261326            self.sld_data.filename = "Default SLD Profile" 
    13271327        except: 
    1328             msg = "OMF Panel: %s"% sys.exc_value 
     1328            msg = "OMF Panel: %s" % sys.exc_value 
    13291329            infor = 'Error' 
    13301330            #logging.error(msg) 
     
    13341334                        StatusEvent(status=msg, info=infor)) 
    13351335                self.SetFocus() 
    1336                  
     1336 
    13371337    def _set_slddata_ctr_val(self, slddata): 
    13381338        """ 
     
    13441344            val = 'Unknown' 
    13451345        self.npix_ctl.SetValue(val) 
    1346          
    1347     def _set_omfdata_ctr(self, omfdata):     
     1346 
     1347    def _set_omfdata_ctr(self, omfdata): 
    13481348        """ 
    13491349        Set the textctr box values 
    13501350        """ 
    1351          
     1351 
    13521352        if omfdata == None: 
    13531353            self._set_none_text() 
     
    13661366                    ctr_list[1].SetValue(format_number(step_list[key], True)) 
    13671367                    ctr_list[1].Enable(not omfdata.is_data) 
    1368                     break    
    1369                  
     1368                    break 
     1369 
    13701370    def _set_none_text(self): 
    13711371        """ 
     
    13771377        for ctr_list in self.stepsize: 
    13781378            ctr_list[1].SetValue(val) 
    1379                  
     1379 
    13801380    def _define_structure(self): 
    13811381        """ 
     
    13831383        """ 
    13841384        self.main_sizer = wx.BoxSizer(wx.VERTICAL) 
    1385          
     1385 
    13861386        self.npixels_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    1387         self.box_sld = wx.StaticBox(self, -1,  
     1387        self.box_sld = wx.StaticBox(self, -1, 
    13881388                                    str("Mean SLD")) 
    13891389        self.box_node = wx.StaticBox(self, -1, str("Nodes")) 
     
    13981398        self.hint_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    13991399        self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    1400                  
     1400 
    14011401    def _layout_npix(self): 
    14021402        """ 
    14031403        Build No of pixels sizer 
    14041404        """ 
    1405         num_pix_text = wx.StaticText(self, -1, "No. of Pixels: ")   
     1405        num_pix_text = wx.StaticText(self, -1, "No. of Pixels: ") 
    14061406        self.npix_ctl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    14071407                                style=wx.TE_PROCESS_ENTER) 
    14081408        self._set_slddata_ctr_val(self.sld_data) 
    1409         self._set_omfdata_ctr(self.sld_data)  
     1409        self._set_omfdata_ctr(self.sld_data) 
    14101410        self.npixels_sizer.AddMany([(num_pix_text, 0, 
    1411                                           wx.EXPAND|wx.LEFT|wx.TOP, 5), 
     1411                                          wx.EXPAND | wx.LEFT | wx.TOP, 5), 
    14121412                                     (self.npix_ctl, 0, 
    1413                                      wx.EXPAND|wx.TOP, 5)]) 
     1413                                     wx.EXPAND | wx.TOP, 5)]) 
    14141414 
    14151415    def _layout_slds(self): 
     
    14511451                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    14521452            self.slds.append([key, ctl, unit]) 
    1453         self.sld_sizer.Add(sizer, 0, wx.LEFT, 10)  
    1454                 
     1453        self.sld_sizer.Add(sizer, 0, wx.LEFT, 10) 
     1454 
    14551455    def _layout_nodes(self): 
    14561456        """ 
     
    14761476            ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    14771477                                style=wx.TE_PROCESS_ENTER) 
    1478             ctl.Bind(wx.EVT_TEXT, self._onparamEnter ) 
     1478            ctl.Bind(wx.EVT_TEXT, self._onparamEnter) 
    14791479            ctl.SetValue(format_number(value, True)) 
    14801480            ctl.Enable(not is_data) 
     
    14871487            self.nodes.append([key, ctl, unit]) 
    14881488        self.node_sizer.Add(sizer, 0, wx.LEFT, 10) 
    1489              
     1489 
    14901490    def _layout_stepsize(self): 
    14911491        """ 
     
    15121512            ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    15131513                                style=wx.TE_PROCESS_ENTER) 
    1514             ctl.Bind(wx.EVT_TEXT, self._onstepsize ) 
     1514            ctl.Bind(wx.EVT_TEXT, self._onstepsize) 
    15151515            ctl.SetValue(format_number(value, True)) 
    15161516            ctl.Enable(not is_data) 
     
    15241524            self.stepsize.append([key, ctl, unit]) 
    15251525        self.step_sizer.Add(sizer, 0, wx.LEFT, 10) 
    1526      
     1526 
    15271527    def _layout_hint(self): 
    15281528        """ 
    1529         Fill the sizer containing hint  
     1529        Fill the sizer containing hint 
    15301530        """ 
    15311531        hint_msg = "Load an omf or 3d sld profile data file." 
    15321532        self.hint_txt = wx.StaticText(self, -1, hint_msg) 
    15331533        self.hint_sizer.AddMany([(self.hint_txt, 0, wx.LEFT, 15)]) 
    1534      
    1535     def _layout_button(self):   
     1534 
     1535    def _layout_button(self): 
    15361536        """ 
    15371537        Do the layout for the button widgets 
    1538         """  
    1539         self.bt_draw = wx.Button(self, wx.NewId(),'Draw Points') 
     1538        """ 
     1539        self.bt_draw = wx.Button(self, wx.NewId(), 'Draw Points') 
    15401540        self.bt_draw.Bind(wx.EVT_BUTTON, self.on_sld_draw) 
    15411541        self.bt_draw.SetToolTipString("Draw a scatter plot for sld profile.") 
    1542         self.bt_save = wx.Button(self, wx.NewId(),'Save SLD Data') 
     1542        self.bt_save = wx.Button(self, wx.NewId(), 'Save SLD Data') 
    15431543        self.bt_save.Bind(wx.EVT_BUTTON, self.on_save) 
    15441544        self.bt_save.Enable(False) 
     
    15461546        self.button_sizer.AddMany([(self.bt_draw, 0, wx.LEFT, 10), 
    15471547                                   (self.bt_save, 0, wx.LEFT, 10)]) 
    1548          
     1548 
    15491549    def _do_layout(self): 
    15501550        """ 
    15511551        Draw omf panel content, used to define sld s. 
    1552          
     1552 
    15531553        """ 
    15541554        self._define_structure() 
     
    15601560        self._layout_button() 
    15611561        self.boxsizer_node.AddMany([(self.node_sizer, 0, 
    1562                                     wx.EXPAND|wx.TOP, 5), 
     1562                                    wx.EXPAND | wx.TOP, 5), 
    15631563                                     (self.hint_sizer, 0, 
    1564                                      wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 
     1564                                     wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 
    15651565        self.boxsizer_stepsize.AddMany([(self.step_sizer, 0, 
    1566                                      wx.EXPAND|wx.TOP|wx.BOTTOM, 5),]) 
     1566                                     wx.EXPAND | wx.TOP | wx.BOTTOM, 5), ]) 
    15671567        self.boxsizer_sld.AddMany([(self.sld_sizer, 0, 
    1568                                      wx.EXPAND|wx.BOTTOM, 5),]) 
    1569         self.main_sizer.AddMany([(self.npixels_sizer, 0, wx.EXPAND|wx.ALL, 10), 
    1570                         (self.boxsizer_sld, 0, wx.EXPAND|wx.ALL, 10), 
    1571                         (self.boxsizer_node, 0, wx.EXPAND|wx.ALL, 10), 
    1572                         (self.boxsizer_stepsize, 0, wx.EXPAND|wx.ALL, 10), 
    1573                         (self.button_sizer, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 
     1568                                     wx.EXPAND | wx.BOTTOM, 5), ]) 
     1569        self.main_sizer.AddMany([(self.npixels_sizer, 0, wx.EXPAND | wx.ALL, 10), 
     1570                        (self.boxsizer_sld, 0, wx.EXPAND | wx.ALL, 10), 
     1571                        (self.boxsizer_node, 0, wx.EXPAND | wx.ALL, 10), 
     1572                        (self.boxsizer_stepsize, 0, wx.EXPAND | wx.ALL, 10), 
     1573                        (self.button_sizer, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 
    15741574        self.SetSizer(self.main_sizer) 
    15751575        self.SetAutoLayout(True) 
    1576          
     1576 
    15771577    def _get_nodes_key_list(self, data): 
    15781578        """ 
    15791579        Return nodes key list 
    1580          
     1580 
    15811581        :Param data: OMFData 
    15821582        """ 
    1583         key_list = {'xnodes' : data.xnodes,  
     1583        key_list = {'xnodes' : data.xnodes, 
    15841584                    'ynodes' : data.ynodes, 
    15851585                    'znodes' : data.znodes} 
    15861586        return key_list 
    1587          
     1587 
    15881588    def _get_slds_key_list(self, data): 
    15891589        """ 
    15901590        Return nodes key list 
    1591          
     1591 
    15921592        :Param data: OMFData 
    15931593        """ 
    1594         key_list = {'Nucl.' : data.sld_n,  
     1594        key_list = {'Nucl.' : data.sld_n, 
    15951595                    'Mx' : data.sld_mx, 
    15961596                    'My' : data.sld_my, 
     
    16011601        """ 
    16021602        Return step key list 
    1603          
     1603 
    16041604        :Param data: OMFData 
    16051605        """ 
    1606         key_list = {'xstepsize' : data.xstepsize,  
     1606        key_list = {'xstepsize' : data.xstepsize, 
    16071607                    'ystepsize' : data.ystepsize, 
    16081608                    'zstepsize' : data.zstepsize} 
    1609         return key_list         
    1610      
     1609        return key_list 
     1610 
    16111611    def set_sld_ctr(self, sld_data): 
    16121612        """ 
     
    16181618                #break    
    16191619            return 
    1620          
     1620 
    16211621        self.sld_data = sld_data 
    16221622        sld_list = self._get_slds_key_list(sld_data) 
     
    16321632                    ctr_list[1].Enable(enable) 
    16331633                    #ctr_list[2].SetLabel("[" + sld_data.sld_unit + "]") 
    1634                     break    
     1634                    break 
    16351635 
    16361636    def on_sld_draw(self, event): 
     
    16391639        """ 
    16401640        self.parent.sld_draw() 
    1641           
     1641 
    16421642    def on_save(self, event): 
    16431643        """ 
     
    16501650        self.sld_data = self.get_sld_val() 
    16511651        self.parent.set_main_panel_sld_data(self.sld_data) 
    1652          
    1653         reader = sas_gen.SLDReader()  
     1652 
     1653        reader = sas_gen.SLDReader() 
    16541654        extension = '*.sld' 
    16551655        path = None 
    1656         data= None 
     1656        data = None 
    16571657        location = self.parent.get_path() 
    16581658        dlg = wx.FileDialog(self, "Save sld file", 
    16591659                            location, "sld_file", 
    1660                              extension,  
     1660                             extension, 
    16611661                             wx.SAVE) 
    16621662        if dlg.ShowModal() == wx.ID_OK: 
     
    16691669            if path is None: 
    16701670                return 
    1671              
     1671 
    16721672            data = self.parent.get_sld_data() 
    16731673            fName = os.path.splitext(path)[0] + '.' + extension.split('.')[-1] 
     
    16931693                # inform msg to wx 
    16941694                wx.PostEvent(self.parent.parent, 
    1695                         StatusEvent(status=msg, info=infor))  
    1696                 self.SetFocus()    
     1695                        StatusEvent(status=msg, info=infor)) 
     1696                self.SetFocus() 
    16971697 
    16981698    def _onparamEnter(self, event): 
     
    17241724                    nop = npts 
    17251725                self.display_npts(nop) 
    1726                  
     1726 
    17271727        ctl.Refresh() 
    17281728        return flag 
    1729      
     1729 
    17301730    def _set_volume_ctr_val(self, npts): 
    17311731        """ 
     
    17341734        total_volume = npts * self.sld_data.vol_pix[0] 
    17351735        self.parent.set_volume_ctr_val(total_volume) 
    1736                      
     1736 
    17371737    def _onstepsize(self, event): 
    17381738        """ 
     
    17631763                pass 
    17641764        ctl.Refresh() 
    1765    
    1766           
     1765 
     1766 
    17671767    def set_npts_from_slddata(self): 
    17681768        """ 
     
    17761776            nop = None 
    17771777        return nop 
    1778      
     1778 
    17791779    def display_npts(self, nop): 
    17801780        """ 
     
    17891789            # On Init 
    17901790            pass 
    1791      
     1791 
    17921792    def check_inputs(self): 
    17931793        """ 
     
    18001800            flag = self._check_input_helper(self.stepsize) 
    18011801        return flag 
    1802      
     1802 
    18031803    def _check_input_helper(self, list): 
    18041804        """ 
     
    18201820    GEN SAS main window 
    18211821    """ 
    1822     def __init__(self, parent=None, manager= None, title="Generic Scattering Calculator", 
     1822    def __init__(self, parent=None, manager=None, title="Generic Scattering Calculator", 
    18231823                size=(PANEL_WIDTH * 1.4, PANEL_HEIGHT * 1.65), *args, **kwds): 
    18241824        """ 
     
    18351835        self.omfdata = sas_gen.OMFData() 
    18361836        self.sld_data = None 
    1837         self._default_save_location = os.getcwd()  
    1838          
     1837        self._default_save_location = os.getcwd() 
     1838 
    18391839        self._mgr = aui.AuiManager(self) 
    18401840        self._mgr.SetDockSizeConstraint(0.5, 0.5) 
     
    18421842        self.scale2d = 'log_{10}' 
    18431843        self.Bind(wx.EVT_CLOSE, self.on_close) 
    1844          
    1845          
     1844 
     1845 
    18461846        self.build_panels() 
    18471847        self.SetPosition((20, 5)) 
    18481848        self.Show(True) 
    1849          
     1849 
    18501850    def build_panels(self): 
    18511851        """ 
    18521852        """ 
    1853          
     1853 
    18541854        self.set_sld_data(self.sld_data) 
    18551855        self._mgr.AddPane(self.panel, aui.AuiPaneInfo(). 
     
    18581858                              # This is where we set the size of 
    18591859                              # the application window 
    1860                               BestSize(wx.Size(PANEL_WIDTH,  
     1860                              BestSize(wx.Size(PANEL_WIDTH, 
    18611861                                               PANEL_HEIGHT)). 
    1862                               Show())  
     1862                              Show()) 
    18631863        self._mgr.AddPane(self.omfpanel, aui.AuiPaneInfo(). 
    18641864                              Name(self.omfpanel.window_name). 
     
    18671867                              Right(). 
    18681868                              Floatable(False). 
    1869                               BestSize(wx.Size(PANEL_WIDTH/2.5, PANEL_HEIGHT)). 
    1870                               Show())   
     1869                              BestSize(wx.Size(PANEL_WIDTH / 2.5, PANEL_HEIGHT)). 
     1870                              Show()) 
    18711871        self._mgr.Update() 
    18721872 
     
    18761876        """ 
    18771877        return self.sld_data 
    1878      
     1878 
    18791879    def get_sld_from_omf(self): 
    18801880        """ 
     
    18821882        self.sld_data = self.omfpanel.get_sld_val() 
    18831883        return self.sld_data 
    1884      
     1884 
    18851885    def set_sld_n(self, sld): 
    18861886        """ 
     
    18881888        self.panel.sld_data = sld 
    18891889        self.panel.model.set_sld_data(sld) 
    1890          
     1890 
    18911891    def set_sld_data(self, data): 
    18921892        """ 
     
    18961896            return 
    18971897        self.sld_data = data 
    1898         enable = (not data==None) 
     1898        enable = (not data == None) 
    18991899        self._set_omfpanel_sld_data(self.sld_data) 
    19001900        self.omfpanel.bt_save.Enable(enable) 
    19011901        self.set_etime() 
    1902      
     1902 
    19031903    def set_omfpanel_npts(self): 
    19041904        """ 
     
    19071907        nop = self.omfpanel.set_npts_from_slddata() 
    19081908        self.omfpanel.display_npts(nop) 
    1909          
     1909 
    19101910    def _set_omfpanel_sld_data(self, data): 
    19111911        """ 
    19121912        Set sld_data in omf panel 
    19131913        """ 
    1914         self.omfpanel.set_slddata(data)  
     1914        self.omfpanel.set_slddata(data) 
    19151915        self.omfpanel.set_sld_ctr(data) 
    1916      
     1916 
    19171917    def check_omfpanel_inputs(self): 
    19181918        """ 
    19191919        Check OMF panel inputs 
    19201920        """ 
    1921         return self.omfpanel.check_inputs()   
    1922         
     1921        return self.omfpanel.check_inputs() 
     1922 
    19231923    def set_main_panel_sld_data(self, sld_data): 
    19241924        """ 
    19251925        """ 
    19261926        self.sld_data = sld_data 
    1927          
     1927 
    19281928    def set_file_location(self, path): 
    19291929        """ 
     
    19311931        """ 
    19321932        self._default_save_location = path 
    1933      
     1933 
    19341934    def get_path(self): 
    19351935        """ 
     
    19371937        """ 
    19381938        return self._default_save_location 
    1939      
     1939 
    19401940    def draw_graph(self, plot, title=''): 
    19411941        """ 
    19421942        """ 
    1943         try:  
     1943        try: 
    19441944            wx.PostEvent(self.parent, NewPlotEvent(plot=plot, title=title)) 
    19451945        except: 
     
    19521952            frame.SetFocus() 
    19531953 
    1954     def set_schedule_full_draw(self, panel=None, func='del'):   
     1954    def set_schedule_full_draw(self, panel=None, func='del'): 
    19551955        """ 
    19561956        Send full draw to gui frame 
     
    19581958        if self.parent != None: 
    19591959            self.parent.set_schedule_full_draw(panel, func) 
    1960          
     1960 
    19611961    def get_npix(self): 
    19621962        """ 
     
    19651965        n_pix = self.omfpanel.npix_ctl.GetValue() 
    19661966        return n_pix 
    1967      
     1967 
    19681968    def get_pix_volumes(self): 
    19691969        """ 
     
    19721972        vol = self.omfpanel.get_pix_volumes() 
    19731973        return vol 
    1974      
     1974 
    19751975    def set_volume_ctr_val(self, val): 
    19761976        """ 
     
    19811981        except: 
    19821982            print "self.panel is not initialized yet" 
    1983              
     1983 
    19841984    def set_omfpanel_default_shap(self, shape): 
    19851985        """ 
     
    19871987        """ 
    19881988        self.omfpanel.default_shape = shape 
    1989      
     1989 
    19901990    def set_etime(self): 
    19911991        """ 
     
    19931993        """ 
    19941994        self.panel.set_est_time() 
    1995      
     1995 
    19961996    def get_sld_data_from_omf(self): 
    19971997        """ 
    19981998        """ 
    1999         data = self.omfpanel.get_sld_val()  
     1999        data = self.omfpanel.get_sld_val() 
    20002000        return data 
    2001         
     2001 
    20022002    def set_scale2d(self, scale): 
    20032003        """ 
    20042004        """ 
    20052005        self.scale2d = scale 
    2006              
     2006 
    20072007    def on_panel_close(self, event): 
    20082008        """ 
    20092009        """ 
    20102010        #Not implemented 
    2011            
     2011 
    20122012    def on_open_file(self, event): 
    20132013        """ 
     
    20152015        """ 
    20162016        self.panel.on_load_data(event) 
    2017      
     2017 
    20182018    def sld_draw(self): 
    20192019        """ 
     
    20212021        """ 
    20222022        self.panel.sld_draw(event=None, has_arrow=False) 
    2023          
     2023 
    20242024    def on_save_file(self, event): 
    20252025        """ 
     
    20272027        """ 
    20282028        self.omfpanel.on_save(event) 
    2029          
     2029 
    20302030    def on_close(self, event): 
    20312031        """ 
     
    20352035            self.base.gen_frame = None 
    20362036        self.Destroy() 
    2037          
     2037 
    20382038#    def on_help(self, event):     
    20392039#        """ 
     
    20612061#            info = "Info" 
    20622062#            wx.MessageBox(msg, info) 
    2063             
    2064 if __name__ == "__main__":  
     2063 
     2064if __name__ == "__main__": 
    20652065    app = wx.PySimpleApp() 
    20662066    widget.CHILD_FRAME = wx.Frame 
    2067     SGframe = SasGenWindow()     
     2067    SGframe = SasGenWindow() 
    20682068    SGframe.Show(True) 
    2069     app.MainLoop()      
     2069    app.MainLoop() 
Note: See TracChangeset for help on using the changeset viewer.