Changeset 1128bd31 in sasview


Ignore:
Timestamp:
Mar 4, 2015 10:19:27 AM (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:
091e71a2
Parents:
e46cbc5
Message:

pylint fixes

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • build_tools/pylint.rc

    re46cbc5 r1128bd31  
    4343# either give multiple identifier separated by comma (,) or put this option 
    4444# multiple time. See also the "--disable" option for examples. 
    45 #enable= 
     45enable=W0704 
    4646 
    4747# Disable the message, report, category or checker with the given id(s). You 
     
    5454# no Warning level messages displayed, use"--disable=all --enable=classes 
    5555# --disable=W" 
    56 #disable=W0702,E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,W1624,W1609,W1626,W1607,W1606,W1605,W1604,W1603,W1602,W1601,I0021,I0020,W1618,W1619,W1630,W1631,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1632,W1633,W0704,W1628,W1629,W1608 
     56# disable=W0702,E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,W1624,W1609,W1626,W1607,W1606,W1605,W1604,W1603,W1602,W1601,I0021,I0020,W1618,W1619,W1630,W1631,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1632,W1633,W0704,W1628,W1629,W1608 
    5757 
    5858# Disable the message(s) with the given id(s). 
    59 disable=W0702,W0613,W0703 
     59disable=W0702,W0613,W0703,W0142 
    6060 
    6161[REPORTS] 
     
    9898 
    9999# Good variable names which should always be accepted, separated by a comma 
    100 good-names=i,j,k,ex,Run,_,x,y,z,qx,qy,qz,n,q,dx,dy,dz,id 
     100good-names=i,j,k,ex,Run,_,x,y,z,qx,qy,qz,n,q,dx,dy,dz,id,Iq,dIq,Qx,Qy,Qz,ix,iy,iz 
    101101 
    102102# Bad variable names which should always be refused, separated by a comma 
  • src/sas/perspectives/invariant/invariant_panel.py

    rd838715 r1128bd31  
    88import os 
    99import wx 
     10import logging 
    1011from wx.lib.scrolledpanel import ScrolledPanel 
    1112from sas.invariant import invariant 
     
    2122from sas.guiframe.panel_base import PanelBase 
    2223# The minimum q-value to be used when extrapolating 
    23 Q_MINIMUM  = 1e-5 
     24Q_MINIMUM = 1e-5 
    2425# The maximum q-value to be used when extrapolating 
    25 Q_MAXIMUM  = 10 
     26Q_MAXIMUM = 10 
    2627# the ratio of maximum q value/(qmax of data) to plot the theory data 
    2728Q_MAXIMUM_PLOT = 3 
     
    3637#default value of the power used for power law 
    3738POWER = 4.0 
    38 #Invariant panel size  
     39#Invariant panel size 
    3940_BOX_WIDTH = 76 
    4041 
     
    4243if sys.platform.count("win32") > 0: 
    4344    _STATICBOX_WIDTH = 450 
    44     PANEL_WIDTH = 500  
     45    PANEL_WIDTH = 500 
    4546    PANEL_HEIGHT = 700 
    4647    FONT_VARIANT = 0 
     
    6869        PanelBase.__init__(self, parent) 
    6970        self.SetupScrolling() 
    70         #Font size  
     71        #Font size 
    7172        self.SetWindowVariant(variant=FONT_VARIANT) 
    7273        #Object that receive status event 
    7374        self.parent = parent.parent 
    7475        #plug-in using this panel 
    75         self._manager = manager  
     76        self._manager = manager 
    7677        #Data uses for computation 
    7778        self._data = data 
    78         self._scale = SCALE  
     79        self._scale = SCALE 
    7980        self._background = BACKGROUND 
    8081        self._bmark = None 
     
    121122        self._reset_state_list() 
    122123        ## Default file location for save 
    123         self._default_save_location = os.getcwd()         
     124        self._default_save_location = os.getcwd() 
    124125        if self.parent is not None: 
    125126            msg = "" 
     
    127128            self._default_save_location = \ 
    128129                        self.parent.get_save_location() 
    129          
     130 
    130131        self._set_bookmark_flag(False) 
    131      
     132 
    132133    def get_data(self): 
    133134        """ 
    134135        """ 
    135136        return self._manager.get_data() 
    136      
     137 
    137138    def get_state(self): 
    138139        """ 
    139140        """ 
    140141        return self.state 
    141      
     142 
    142143    def set_data(self, data): 
    143144        """ 
     
    150151            self.get_state_by_num(0) 
    151152            data_name = self._data.name 
    152             data_qmin = min (self._data.x) 
    153             data_qmax = max (self._data.x) 
     153            data_qmin = min(self._data.x) 
     154            data_qmax = max(self._data.x) 
    154155            self.data_name_tcl.SetValue(str(data_name)) 
    155156            self.data_min_tcl.SetValue(str(data_qmin)) 
     
    164165            self._reset_state_list() 
    165166            self._set_bookmark_flag(True) 
    166         return True   
    167      
     167        return True 
     168 
    168169    def _delete_bookmark_items(self): 
    169170        """ 
     
    180181                continue 
    181182            self.popUpMenu.DestroyItem(item) 
    182                  
     183 
    183184    def set_message(self): 
    184185        """ 
     
    190191                msg += "attention.\nPlease click on Details button." 
    191192                self.hint_msg_txt.SetForegroundColour("red") 
    192      
     193 
    193194                wx.PostEvent(self.parent, 
    194                              StatusEvent(status=msg,info="warning")) 
     195                             StatusEvent(status=msg, info="warning")) 
    195196            else: 
    196197                msg = "For more information, click on Details button." 
    197198                self.hint_msg_txt.SetForegroundColour("black") 
    198199                wx.PostEvent(self.parent, 
    199                              StatusEvent(status=msg,info="info")) 
     200                             StatusEvent(status=msg, info="info")) 
    200201            self.hint_msg_txt.SetLabel(msg) 
    201202        self.Layout() 
    202         
     203 
    203204    def set_manager(self, manager): 
    204205        """ 
    205206        set value for the manager 
    206207        """ 
    207         self._manager = manager  
    208          
     208        self._manager = manager 
     209 
    209210    def save_project(self, doc=None): 
    210211        """ 
     
    223224                else: 
    224225                    doc = new_doc 
    225         return doc    
     226        return doc 
    226227 
    227228    def set_state(self, state=None, data=None): 
     
    229230        set state when loading it from a .inv/.svs file 
    230231        """ 
    231          
     232 
    232233        if state == None and data == None: 
    233234            self.state = IState() 
    234         elif state == None or data == None:  
     235        elif state == None or data == None: 
    235236            return 
    236237        else: 
     
    240241                return 
    241242 
    242             self.state = new_state  
    243             self.state.file = data.name    
     243            self.state = new_state 
     244            self.state.file = data.name 
    244245 
    245246            num = self.state.saved_state['state_num'] 
    246             if num > 0 : 
     247            if num > 0: 
    247248                self._set_undo_flag(True) 
    248249            if num < len(state.state_list) - 1: 
    249250                self._set_redo_flag(True) 
    250                  
     251 
    251252            # get bookmarks 
    252253            self.bookmark_num = len(self.state.bookmark_list) 
     
    256257                #bookmark_num = ind 
    257258                value = self.state.bookmark_list[ind] 
    258                 name = "%d] bookmarked at %s on %s"% (ind, value[0], value[1]) 
     259                name = "%d] bookmarked at %s on %s" % (ind, value[0], value[1]) 
    259260                # append it to menu 
    260261                id = wx.NewId() 
    261262                self.popUpMenu.Append(id, name, str('')) 
    262                 wx.EVT_MENU(self, id, self._back_to_bookmark)  
    263                 wx.PostEvent(self.parent, AppendBookmarkEvent(title=name,  
    264                                           hint='',  
    265                                           handler=self._back_to_bookmark)) 
     263                wx.EVT_MENU(self, id, self._back_to_bookmark) 
     264                wx.PostEvent(self.parent, 
     265                             AppendBookmarkEvent(title=name, 
     266                                                 hint='', 
     267                                                 handler=self._back_to_bookmark)) 
    266268 
    267269            self.get_state_by_num(state_num=str(num)) 
    268              
    269             self._get_input_list()  
     270 
     271            self._get_input_list() 
    270272            #make sure that the data is reset (especially 
    271273            # when loaded from a inv file) 
    272274            self.state.data = self._data 
    273275            self._set_preview_flag(False) 
    274             self.new_state = False  
     276            self.new_state = False 
    275277            self.is_state_data = False 
    276278 
     
    279281        Clear panel to defaults, used by set_state of manager 
    280282        """ 
    281          
     283 
    282284        self._data = None 
    283285        # default data testctrl 
     
    312314            msg = "Receive invalid value for background : %s" % (background) 
    313315            raise ValueError, msg 
    314      
     316 
    315317    def get_scale(self): 
    316318        """ 
     
    329331        else: 
    330332            raise ValueError, "Receive invalid value for scale : %s" % (scale) 
    331          
     333 
    332334    def get_contrast(self): 
    333335        """ 
     
    336338        par_str = self.contrast_tcl.GetValue().strip() 
    337339        contrast = None 
    338         if par_str !=" " and check_float(self.contrast_tcl): 
     340        if par_str != " " and check_float(self.contrast_tcl): 
    339341            contrast = float(par_str) 
    340342        return contrast 
    341      
     343 
    342344    def get_extrapolation_type(self, low_q, high_q): 
    343345        """ 
     
    352354            extrapolation = "both" 
    353355        return extrapolation 
    354              
     356 
    355357    def get_porod_const(self): 
    356358        """ 
     
    362364            porod_const = float(par_str) 
    363365        return porod_const 
    364      
     366 
    365367    def get_volume(self, inv, contrast, extrapolation): 
    366368        """ 
     
    369371        if contrast is not None: 
    370372            try: 
    371                 v, dv = inv.get_volume_fraction_with_error(contrast=contrast,  
    372                                                 extrapolation=extrapolation) 
     373                v, dv = inv.get_volume_fraction_with_error(contrast=contrast, 
     374                                                           extrapolation=extrapolation) 
    373375                self.volume_tcl.SetValue(format_number(v)) 
    374376                self.volume_err_tcl.SetValue(format_number(dv)) 
     
    381383                                                      info="error", 
    382384                                                      type="stop")) 
    383                 
     385 
    384386    def get_surface(self, inv, contrast, porod_const, extrapolation): 
    385387        """ 
     
    389391            try: 
    390392                s, ds = inv.get_surface_with_error(contrast=contrast, 
    391                                         porod_const=porod_const, 
    392                                         extrapolation=extrapolation) 
     393                                                   porod_const=porod_const, 
     394                                                   extrapolation=extrapolation) 
    393395                self.surface_tcl.SetValue(format_number(s)) 
    394396                self.surface_err_tcl.SetValue(format_number(ds)) 
     
    399401                msg += "specific surface: %s" % sys.exc_value 
    400402                wx.PostEvent(self.parent, StatusEvent(status=msg, info="error", 
    401                                                        type="stop")) 
    402                  
     403                                                      type="stop")) 
     404 
    403405    def get_total_qstar(self, inv, extrapolation): 
    404406        """ 
     
    420422            msg = "Error occurred computing invariant using" 
    421423            msg += " extrapolation: %s" % sys.exc_value 
    422             wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop"))   
    423              
     424            wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 
     425 
    424426    def get_low_qstar(self, inv, npts_low, low_q=False): 
    425427        """ 
     
    427429        """ 
    428430        if low_q: 
    429             try:  
     431            try: 
    430432                qstar_low, qstar_low_err = inv.get_qstar_low() 
    431433                self.inv_container.qstar_low = qstar_low 
    432434                self.inv_container.qstar_low_err = qstar_low_err 
    433                 extrapolated_data = inv.get_extra_data_low(npts_in=npts_low)  
    434                 power_low = inv.get_extrapolation_power(range='low')   
     435                extrapolated_data = inv.get_extra_data_low(npts_in=npts_low) 
     436                power_low = inv.get_extrapolation_power(range='low') 
    435437                if self.power_law_low.GetValue(): 
    436438                    self.power_low_tcl.SetValue(format_number(power_low)) 
    437439                self._manager.plot_theory(data=extrapolated_data, 
    438                                            name="Low-Q extrapolation") 
     440                                          name="Low-Q extrapolation") 
    439441            except: 
    440442                self.inv_container.qstar_low = "ERROR" 
     
    449451            try: 
    450452                self._manager.plot_theory(name="Low-Q extrapolation") 
    451             except:  
    452                 pass 
    453              
     453            except: 
     454                logging.error(sys.exc_value) 
     455 
    454456    def get_high_qstar(self, inv, high_q=False): 
    455457        """ 
     
    457459        """ 
    458460        if high_q: 
    459             try:  
     461            try: 
    460462                qmax_plot = Q_MAXIMUM_PLOT * max(self._data.x) 
    461                 if qmax_plot > Q_MAXIMUM:  
     463                if qmax_plot > Q_MAXIMUM: 
    462464                    qmax_plot = Q_MAXIMUM 
    463465                qstar_high, qstar_high_err = inv.get_qstar_high() 
    464466                self.inv_container.qstar_high = qstar_high 
    465467                self.inv_container.qstar_high_err = qstar_high_err 
    466                 power_high = inv.get_extrapolation_power(range='high')  
     468                power_high = inv.get_extrapolation_power(range='high') 
    467469                self.power_high_tcl.SetValue(format_number(power_high)) 
    468470                high_out_data = inv.get_extra_data_high(q_end=qmax_plot, 
    469471                                                        npts=500) 
    470472                self._manager.plot_theory(data=high_out_data, 
    471                                            name="High-Q extrapolation") 
     473                                          name="High-Q extrapolation") 
    472474            except: 
    473475                #raise 
     
    483485            try: 
    484486                self._manager.plot_theory(name="High-Q extrapolation") 
    485             except:  
    486                 pass 
     487            except: 
     488                logging.error(sys.exc_value) 
    487489 
    488490    def get_qstar(self, inv): 
     
    493495        self.inv_container.qstar = qstar 
    494496        self.inv_container.qstar_err = qstar_err 
    495               
     497 
    496498    def set_extrapolation_low(self, inv, low_q=False): 
    497499        """ 
     
    513515                    power_low = float(power_low) 
    514516                else: 
    515                     if low_q : 
     517                    if low_q: 
    516518                        #Raise error only when qstar at low q is requested 
    517519                        msg = "Expect float for power at low q, " 
    518520                        msg += " got %s" % (power_low) 
    519                         wx.PostEvent(self.parent, StatusEvent(status=msg,  
    520                                                   info="error", 
    521                                                   type="stop")) 
    522         
     521                        wx.PostEvent(self.parent, 
     522                                     StatusEvent(status=msg, 
     523                                                 info="error", 
     524                                                 type="stop")) 
     525 
    523526        #Get the number of points to extrapolated 
    524         npts_low = self.npts_low_tcl.GetValue().lstrip().rstrip()    
     527        npts_low = self.npts_low_tcl.GetValue().lstrip().rstrip() 
    525528        if check_float(self.npts_low_tcl): 
    526529            npts_low = float(npts_low) 
     
    529532                msg = "Expect float for number of points at low q," 
    530533                msg += " got %s" % (npts_low) 
    531                 wx.PostEvent(self.parent, StatusEvent(status=msg,  
    532                                                   info="error", 
    533                                                   type="stop")) 
     534                wx.PostEvent(self.parent, 
     535                             StatusEvent(status=msg, 
     536                                         info="error", 
     537                                         type="stop")) 
    534538        #Set the invariant calculator 
    535539        inv.set_extrapolation(range="low", npts=npts_low, 
    536                                    function=function_low, power=power_low)     
    537         return inv, npts_low   
    538      
     540                              function=function_low, power=power_low) 
     541        return inv, npts_low 
     542 
    539543 
    540544    def set_extrapolation_high(self, inv, high_q=False): 
     
    557561                    msg = "Expect float for power at high q," 
    558562                    msg += " got %s" % (power_high) 
    559                     wx.PostEvent(self.parent, StatusEvent(status=msg,  
    560                                                   info="error", 
    561                                                   type="stop")) 
    562                            
    563         npts_high = self.npts_high_tcl.GetValue().lstrip().rstrip()    
     563                    wx.PostEvent(self.parent, 
     564                                 StatusEvent(status=msg, 
     565                                             info="error", 
     566                                             type="stop")) 
     567 
     568        npts_high = self.npts_high_tcl.GetValue().lstrip().rstrip() 
    564569        if check_float(self.npts_high_tcl): 
    565570            npts_high = float(npts_high) 
     
    568573                msg = "Expect float for number of points at high q," 
    569574                msg += " got %s" % (npts_high) 
    570                 wx.PostEvent(self.parent, StatusEvent(status=msg,  
    571                                                   info="error", 
    572                                                   type="stop")) 
     575                wx.PostEvent(self.parent, StatusEvent(status=msg, 
     576                                                      info="error", 
     577                                                      type="stop")) 
    573578        inv.set_extrapolation(range="high", npts=npts_high, 
    574                                    function=function_high, power=power_high) 
     579                              function=function_high, power=power_high) 
    575580        return inv, npts_high 
    576      
     581 
    577582    def display_details(self, event): 
    578583        """ 
    579584        open another panel for more details on invariant calculation 
    580585        """ 
    581         panel = InvariantDetailsPanel(parent=self,  
    582                                            qstar_container=self.inv_container) 
     586        panel = InvariantDetailsPanel(parent=self, 
     587                                      qstar_container=self.inv_container) 
    583588        panel.ShowModal() 
    584589        panel.Destroy() 
    585590        self.button_calculate.SetFocus() 
    586          
     591 
    587592    def compute_invariant(self, event=None): 
    588593        """ 
    589         compute invariant  
     594        compute invariant 
    590595        """ 
    591596        if self._data == None: 
     
    594599            wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    595600        # set a state for this computation for saving 
    596         elif event != None:  
     601        elif event != None: 
    597602            self._set_compute_state(state='compute') 
    598603            self._set_bookmark_flag(True) 
    599             msg = "\n\nStarting a new invariant computation..."             
     604            msg = "\n\nStarting a new invariant computation..." 
    600605            wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    601              
     606 
    602607 
    603608        if self._data is None: 
    604609            return 
    605610        self.button_details.Enable() 
    606         #clear outputs textctrl  
     611        #clear outputs textctrl 
    607612        self._reset_output() 
    608613        try: 
     
    613618            wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 
    614619            return 
    615          
     620 
    616621        low_q = self.enable_low_cbox.GetValue() 
    617         high_q = self.enable_high_cbox.GetValue()  
     622        high_q = self.enable_high_cbox.GetValue() 
    618623        temp_data = copy.deepcopy(self._data) 
    619          
    620         #set invariant calculator  
     624 
     625        #set invariant calculator 
    621626        inv = invariant.InvariantCalculator(data=temp_data, 
    622627                                            background=background, 
     
    628633            msg = "Error occurred computing invariant: %s" % sys.exc_value 
    629634            wx.PostEvent(self.parent, StatusEvent(status=msg, 
    630                                                  info="warning", type="stop")) 
     635                                                  info="warning", type="stop")) 
    631636            return 
    632637        #check the type of extrapolation 
    633638        extrapolation = self.get_extrapolation_type(low_q=low_q, high_q=high_q) 
    634         
     639 
    635640        #Compute invariant 
    636         bkg_changed = False 
    637         scale_changed = False 
    638641        try: 
    639642            self.get_qstar(inv=inv) 
    640             #if scale_changed or bkg_changed: 
    641             #self._manager.plot_data(data=inv.get_data()) 
    642              
    643643        except: 
    644             msg= "Error occurred computing invariant: %s" % sys.exc_value 
    645             wx.PostEvent(self.parent, StatusEvent(status=msg,  
     644            msg = "Error occurred computing invariant: %s" % sys.exc_value 
     645            wx.PostEvent(self.parent, StatusEvent(status=msg, 
    646646                                                  info="warning", 
    647647                                                  type="stop")) 
     
    651651        try: 
    652652            r_msg = 'Low Q: ' 
    653             #Compute qstar extrapolated to low q range  
     653            #Compute qstar extrapolated to low q range 
    654654            self.get_low_qstar(inv=inv, npts_low=npts_low, low_q=low_q) 
    655655            r_msg = 'High Q: ' 
    656             #Compute qstar extrapolated to high q range  
     656            #Compute qstar extrapolated to high q range 
    657657            self.get_high_qstar(inv=inv, high_q=high_q) 
    658658            r_msg = '' 
    659             #Compute qstar extrapolated to total q range  
     659            #Compute qstar extrapolated to total q range 
    660660            #and set value to txtcrtl 
    661661            self.get_total_qstar(inv=inv, extrapolation=extrapolation) 
    662662            # Parse additional parameters 
    663             porod_const = self.get_porod_const()         
     663            porod_const = self.get_porod_const() 
    664664            contrast = self.get_contrast() 
    665665        except: 
    666666            msg = r_msg + "Error occurred computing invariant: %s" % \ 
    667667                                                            sys.exc_value 
    668             wx.PostEvent(self.parent, StatusEvent(status=msg,  
     668            wx.PostEvent(self.parent, StatusEvent(status=msg, 
    669669                                                  info="error", 
    670670                                                  type="stop")) 
     
    681681        try: 
    682682            self.get_surface(inv=inv, contrast=contrast, 
    683                                     porod_const=porod_const,  
    684                                     extrapolation=extrapolation) 
    685              
     683                             porod_const=porod_const, 
     684                             extrapolation=extrapolation) 
     685 
    686686        except: 
    687687            msg = "Error occurred computing invariant: %s" % sys.exc_value 
     
    689689                                                  info="warning", 
    690690                                                  type="stop")) 
    691              
     691 
    692692        #compute percentage of each invariant 
    693693        self.inv_container.compute_percentage() 
    694          
     694 
    695695        #display a message 
    696696        self.set_message() 
     
    703703            self.state.set_report_string() 
    704704            self.is_power_out = False 
    705             wx.PostEvent(self.parent, StatusEvent(status = msg )) 
     705            wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    706706 
    707707        #enable the button_ok for more details 
    708708        self._set_preview_flag(True) 
    709          
    710         if event != None:  
     709 
     710        if event != None: 
    711711            self._set_preview_flag(True) 
    712712            self._set_save_flag(True) 
    713713            wx.PostEvent(self.parent, 
    714                 StatusEvent(status='\nFinished invariant computation...')) 
     714                         StatusEvent(status='\nFinished invariant computation...')) 
    715715        #self.Show(True) 
    716716        self.Refresh() 
    717              
     717 
    718718    def on_undo(self, event=None): 
    719719        """ 
    720720        Go back to the previous state 
    721          
     721 
    722722        : param event: undo button event 
    723723        """ 
     
    729729 
    730730        self.get_state_by_num(state_num=str(pre_state_num)) 
    731          
     731 
    732732        if float(pre_state_num) <= 0: 
    733733            self._set_undo_flag(False) 
     
    735735            self._set_undo_flag(True) 
    736736        self._set_redo_flag(True) 
    737         self.is_power_out = False   
     737        self.is_power_out = False 
    738738        self._info_state_num() 
    739739 
    740          
     740 
    741741    def on_redo(self, event=None): 
    742742        """ 
    743743        Go forward to the previous state 
    744          
     744 
    745745        : param event: redo button event 
    746746        """ 
     
    750750 
    751751        self.get_state_by_num(state_num=str(next_state_num)) 
    752          
    753         if float(next_state_num)+2 > len(self.state.state_list): 
     752 
     753        if float(next_state_num) + 2 > len(self.state.state_list): 
    754754            self._set_redo_flag(False) 
    755755        else: 
    756756            self._set_redo_flag(True) 
    757      
     757 
    758758        self._set_undo_flag(True) 
    759759        self.is_power_out = False 
    760760        self._info_state_num() 
    761          
     761 
    762762    def on_preview(self, event=None): 
    763763        """ 
    764764        Invoke report dialog panel 
    765          
     765 
    766766        : param event: report button event 
    767767        """ 
     
    775775        dialog = ReportDialog(report_list, None, -1, "") 
    776776        dialog.Show() 
    777          
     777 
    778778    def get_state_by_num(self, state_num=None): 
    779779        """ 
    780780        Get the state given by number 
    781          
     781 
    782782        : param state_num: the given state number 
    783         """      
     783        """ 
    784784        if state_num == None: 
    785785            return 
    786786 
    787787        backup_state_list = copy.deepcopy(self.state.state_list) 
    788          
     788 
    789789        # get the previous state 
    790790        try: 
    791791            current_state = copy.deepcopy(self.state.state_list[str(state_num)]) 
    792             # get the previously computed state number  
     792            # get the previously computed state number 
    793793            #(computation before the state changes happened) 
    794794            current_compute_num = str(current_state['compute_num']) 
    795         except : 
     795        except: 
    796796            raise 
    797             #raise ValueError,  "No such state exists in history" 
    798          
     797 
    799798        # get the state at pre_compute_num 
    800799        comp_state = copy.deepcopy(self.state.state_list[current_compute_num]) 
     
    808807                exec "self.%s.SetValue(%s)" % (key, value) 
    809808            except: 
    810                 pass 
    811          
     809                logging.error(sys.exc_value) 
     810 
    812811        self.compute_invariant(event=None) 
    813         
     812 
    814813        # set the input params at the state at pre_state_num 
    815814        for key in current_state: 
     
    821820                exec 'self.%s.SetValue(%s)' % (key, value) 
    822821            except: 
    823                 pass 
     822                logging.error(sys.exc_value) 
    824823 
    825824        self._enable_high_q_section(event=None) 
     
    829828        self.state.state_num = state_num 
    830829 
    831          
     830 
    832831    def get_bookmark_by_num(self, num=None): 
    833832        """ 
    834833        Get the bookmark state given by number 
    835          
     834 
    836835        : param num: the given bookmark number 
    837          
     836 
    838837        """ 
    839838        current_state = {} 
     
    843842        # get the previous state 
    844843        try: 
    845             _, _, current_state,comp_state = self.state.bookmark_list[int(num)]  
    846         except : 
    847             raise ValueError,  "No such bookmark exists" 
     844            _, _, current_state, comp_state = self.state.bookmark_list[int(num)] 
     845        except: 
     846            logging.error(sys.exc_value) 
     847            raise ValueError, "No such bookmark exists" 
    848848 
    849849        # set the parameters 
     
    855855                exec "self.%s.SetValue(%s)" % (key, value) 
    856856            except: 
    857                 pass 
     857                logging.error(sys.exc_value) 
    858858 
    859859        self.compute_invariant(event=None) 
     
    866866                exec 'self.%s.SetValue(%s)' % (key, value) 
    867867            except: 
    868                 pass 
     868                logging.error(sys.exc_value) 
    869869        self.state.saved_state = copy.deepcopy(current_state) 
    870         
     870 
    871871        self._enable_high_q_section(event=None) 
    872872        self._enable_low_q_section(event=None) 
     
    880880        """ 
    881881        self.background_tcl.SetValue(str(BACKGROUND)) 
    882         self.scale_tcl.SetValue(str(SCALE))  
     882        self.scale_tcl.SetValue(str(SCALE)) 
    883883        self.contrast_tcl.SetValue(str(CONTRAST)) 
    884         self.porod_constant_tcl.SetValue('')  
     884        self.porod_constant_tcl.SetValue('') 
    885885        self.npts_low_tcl.SetValue(str(NPTS)) 
    886886        self.enable_low_cbox.SetValue(False) 
     
    906906        self.button_calculate.SetFocus() 
    907907        #self.SetupScrolling() 
    908          
     908 
    909909    def _set_state(self, event): 
    910910        """ 
    911911        Set the state list 
    912          
     912 
    913913        :param event: rb/cb event 
    914914        """ 
     
    923923 
    924924        try: 
    925             if value == None or value.lstrip().rstrip() =='': 
     925            if value == None or value.lstrip().rstrip() == '': 
    926926                value = 'None' 
    927927            exec 'self.state.%s = %s' % (name, value) 
    928             exec "self.state.saved_state['%s'] = %s" %  (name, value) 
    929              
    930             # set the count part of radio button clicked  
     928            exec "self.state.saved_state['%s'] = %s" % (name, value) 
     929 
     930            # set the count part of radio button clicked 
    931931            #False for the saved_state 
    932932            for title, content in rb_list: 
    933                 if name ==  title: 
    934                     name = content  
    935                     value = False      
     933                if name == title: 
     934                    name = content 
     935                    value = False 
    936936                elif name == content: 
    937937                    name = title 
    938                     value = False  
    939             exec "self.state.saved_state['%s'] = %s" %  (name, value)      
    940              
     938                    value = False 
     939            exec "self.state.saved_state['%s'] = %s" % (name, value) 
     940 
    941941            # Instead of changing the future, create a new future. 
    942             max_state_num = len(self.state.state_list) - 1    
    943             self.state.saved_state['state_num'] = max_state_num    
    944              
     942            max_state_num = len(self.state.state_list) - 1 
     943            self.state.saved_state['state_num'] = max_state_num 
     944 
    945945            self.state.saved_state['state_num'] += 1 
    946946            self.state.state_num = self.state.saved_state['state_num'] 
    947947            self.state.state_list[str(self.state.state_num)] = \ 
    948948                    self.state.clone_state() 
    949         except:            
    950             pass 
    951          
     949        except: 
     950            logging.error(sys.exc_value) 
     951 
    952952        self._set_undo_flag(True) 
    953953        self._set_redo_flag(False) 
    954954        #event.Skip() 
    955                     
     955 
    956956    def _set_compute_state(self, state=None): 
    957957        """ 
    958958        Notify the compute_invariant state to self.state 
    959          
     959 
    960960        : param state: set 'compute' when the computation is 
    961961        activated by the 'compute' button, else None 
    962          
     962 
    963963        """ 
    964964        # reset the default 
     
    969969            self.is_power_out = True 
    970970        # Instead of changing the future, create a new future. 
    971         max_state_num = len(self.state.state_list) - 1    
    972         self.state.saved_state['state_num'] = max_state_num         
     971        max_state_num = len(self.state.state_list) - 1 
     972        self.state.saved_state['state_num'] = max_state_num 
    973973        # A new computation is also A state 
    974974        #copy.deepcopy(self.state.saved_state) 
     
    977977        self.state.state_num = temp_saved_states['state_num'] 
    978978 
    979                  
    980         # set the state number of the computation  
     979 
     980        # set the state number of the computation 
    981981        if state == 'compute': 
    982982            temp_saved_states['compute_num'] = self.state.state_num 
     
    985985        self.state.state_list[str(self.state.state_num)] = \ 
    986986                                        self.state.clone_state() 
    987          
     987 
    988988        # A computation is a new state, so delete the states with any higher 
    989989        # state numbers 
    990         for i in range(self.state.state_num+1, len(self.state.state_list)): 
     990        for i in range(self.state.state_num + 1, len(self.state.state_list)): 
    991991            try: 
    992                 del (self.state.state_list[str(i)]) 
    993             except:  
    994                 pass 
     992                del self.state.state_list[str(i)] 
     993            except: 
     994                logging.error(sys.exc_value) 
    995995        # Enable the undo button if it was not 
    996996        self._set_undo_flag(True) 
    997997        self._set_redo_flag(False) 
    998          
     998 
    999999    def _reset_state_list(self, data=None): 
    10001000        """ 
     
    10051005        #temp_state = self.state.clone_state() 
    10061006        #copy.deepcopy(self.state.saved_state) 
    1007         # Clear the list  
     1007        # Clear the list 
    10081008        self.state.state_list.clear() 
    10091009        self.state.bookmark_list.clear() 
     
    10301030        self._set_save_flag(False) 
    10311031 
    1032          
     1032 
    10331033    def _on_text(self, event): 
    10341034        """ 
    10351035        Catch text change event to add the state to the state_list 
    1036          
     1036 
    10371037        :param event: txtctr event ; assumes not None 
    1038          
    1039         """ 
    1040         if self._data == None:  
     1038 
     1039        """ 
     1040        if self._data == None: 
    10411041            return 
    10421042        # check if this event is from do/undo button 
     
    10441044            #event.Skip() 
    10451045            return 
    1046          
     1046 
    10471047        # get the object 
    10481048        obj = event.GetEventObject() 
     
    10531053        # text event is a new state, so delete the states with higher state_num 
    10541054        # i.e., change the future 
    1055         for i in range(int(state_num)+1, len(self.state.state_list)): 
     1055        for i in range(int(state_num) + 1, len(self.state.state_list)): 
    10561056            try: 
    1057                 del (self.state.state_list[str(i)]) 
    1058             except:  
    1059                 pass 
    1060          
     1057                del self.state.state_list[str(i)] 
     1058            except: 
     1059                logging.error(sys.exc_value) 
     1060 
    10611061        # Instead of changing the future, create a new future. 
    1062         #max_state_num = len(self.state.state_list)-1    
     1062        #max_state_num = len(self.state.state_list)-1 
    10631063        #self.state.saved_state['state_num'] = max_state_num 
    10641064 
    10651065        # try to add new state of the text changes in the state_list 
    10661066        try: 
    1067             if value.strip() == None:  
     1067            if value.strip() == None: 
    10681068                value = '' 
    10691069            exec "self.state.%s = '%s'" % (name, value) 
    1070             exec "self.state.saved_state['%s'] = '%s'" %  (name, value) 
     1070            exec "self.state.saved_state['%s'] = '%s'" % (name, value) 
    10711071            exec "self.state.input_list['%s'] = '%s'" % (name, value) 
    10721072            if not self.is_power_out: 
     
    10781078                                        self.state.clone_state() 
    10791079        except: 
    1080             pass 
     1080            logging.error(sys.exc_value) 
    10811081 
    10821082        #event.Skip() 
     
    10851085        self._set_bookmark_flag(True) 
    10861086        self._set_preview_flag(False) 
    1087         
    1088     def _on_out_text(self, event):      
    1089         """ 
    1090         Catch ouput text change to add the state  
    1091          
     1087 
     1088    def _on_out_text(self, event): 
     1089        """ 
     1090        Catch ouput text change to add the state 
     1091 
    10921092        :param event: txtctr event ; assumes not None 
    1093          
    1094         """     
     1093 
     1094        """ 
    10951095        # get the object 
    10961096        obj = event.GetEventObject() 
     
    10981098        value = str(obj.GetValue()) 
    10991099        try: 
    1100             exec "self.state.saved_state['%s'] = '%s'" %  (name, value) 
     1100            exec "self.state.saved_state['%s'] = '%s'" % (name, value) 
    11011101            self.state.state_list[str(self.state.state_num)] = \ 
    11021102                                self.state.clone_state() 
    11031103        except: 
    1104             pass 
     1104            logging.error(sys.exc_value) 
    11051105        #if event != None: event.Skip() 
    11061106 
    1107     def _get_input_list(self):      
     1107    def _get_input_list(self): 
    11081108        """ 
    11091109        get input_list; called by set_state 
    1110         """     
     1110        """ 
    11111111        # get state num of the last compute state 
    11121112        compute_num = self.state.saved_state['compute_num'] 
    11131113        # find values and put into the input list 
    1114         for key1, value1 in self.state.state_list[str(compute_num)].iteritems():  
    1115             for key, _ in self.state.input_list.iteritems():  
     1114        for key1, value1 in self.state.state_list[str(compute_num)].iteritems(): 
     1115            for key, _ in self.state.input_list.iteritems(): 
    11161116                if key == key1: 
    11171117                    self.state.input_list[key] = value1 
    11181118                    break 
    1119          
     1119 
    11201120    def _set_bookmark_menu(self): 
    11211121        """ 
     
    11321132        self.popUpMenu.AppendSeparator() 
    11331133        self.Bind(wx.EVT_CONTEXT_MENU, self._on_context_menu) 
    1134          
     1134 
    11351135    def on_bookmark(self, event): 
    11361136        """ 
    11371137        Save the panel state in memory and add the list on 
    11381138        the popup menu on bookmark context menu event 
    1139         """  
    1140         if self._data == None:  
     1139        """ 
     1140        if self._data == None: 
    11411141            return 
    1142         if event == None:  
     1142        if event == None: 
    11431143            return 
    11441144        self.bookmark_num += 1 
     
    11481148        compute_num = self.state.saved_state['compute_num'] 
    11491149        # name and message of the bookmark list 
    1150         msg =  "State saved at %s on %s"% (my_time, date) 
    1151          ## post help message for the selected model  
     1150        msg = "State saved at %s on %s" % (my_time, date) 
     1151        ## post help message for the selected model 
    11521152        msg += " Right click on the panel to retrieve this state" 
    11531153        #wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) 
    1154         name = "%d] bookmarked at %s on %s"% (self.bookmark_num, my_time, date) 
    1155          
     1154        name = "%d] bookmarked at %s on %s" % (self.bookmark_num, my_time, date) 
     1155 
    11561156        # append it to menu 
    11571157        id = wx.NewId() 
     
    11611161        comp_state = copy.deepcopy(self.state.state_list[str(compute_num)]) 
    11621162        self.state.bookmark_list[self.bookmark_num] = [my_time, date, 
    1163                                                        state,comp_state] 
     1163                                                       state, comp_state] 
    11641164        self.state.toXML(self, doc=None, entry_node=None) 
    1165          
     1165 
    11661166        wx.PostEvent(self.parent, StatusEvent(status=msg, info="info")) 
    1167         wx.PostEvent(self.parent,  
    1168                      AppendBookmarkEvent(title=name,  
     1167        wx.PostEvent(self.parent, 
     1168                     AppendBookmarkEvent(title=name, 
    11691169                                         hint=str(msg), 
    1170                                           handler=self._back_to_bookmark)) 
     1170                                         handler=self._back_to_bookmark)) 
    11711171 
    11721172    def _back_to_bookmark(self, event): 
     
    11781178        self._manager.on_perspective(event) 
    11791179        menu = event.GetEventObject() 
    1180         ## post help message for the selected model  
     1180        ## post help message for the selected model 
    11811181        msg = menu.GetHelpString(event.GetId()) 
    11821182        msg += " reloaded" 
    1183         wx.PostEvent(self.parent, StatusEvent(status = msg )) 
    1184          
     1183        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     1184 
    11851185        name = menu.GetLabel(event.GetId()) 
    1186          
    1187         num, time = name.split(']') 
    1188         current_state_num = self.state.state_num   
     1186 
     1187        num, _ = name.split(']') 
     1188        current_state_num = self.state.state_num 
    11891189        self.get_bookmark_by_num(num) 
    11901190        state_num = int(current_state_num) + 1 
    1191          
     1191 
    11921192        self.state.saved_state['state_num'] = state_num 
    11931193        #copy.deepcopy(self.state.saved_state) 
    11941194        self.state.state_list[str(state_num)] = self.state.clone_state() 
    11951195        self.state.state_num = state_num 
    1196         
     1196 
    11971197        self._set_undo_flag(True) 
    11981198        self._info_bookmark_num(event) 
    1199          
     1199 
    12001200    def _info_bookmark_num(self, event=None): 
    12011201        """ 
    12021202        print the bookmark number in info 
    1203          
     1203 
    12041204        : event: popUpMenu event 
    12051205        """ 
    1206         if event == None:  
     1206        if event == None: 
    12071207            return 
    12081208        # get the object 
     
    12111211        text = item.GetText() 
    12121212        num = text.split(']')[0] 
    1213         msg = "bookmark num = %s "% num 
    1214          
    1215         wx.PostEvent(self.parent, StatusEvent(status = msg )) 
    1216          
     1213        msg = "bookmark num = %s " % num 
     1214 
     1215        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     1216 
    12171217    def _info_state_num(self): 
    12181218        """ 
     
    12211221        msg = "state num = " 
    12221222        msg += self.state.state_num 
    1223          
    1224         wx.PostEvent(self.parent, StatusEvent(status = msg)) 
    1225                           
     1223 
     1224        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     1225 
    12261226    def _get_time_stamp(self): 
    12271227        """ 
    12281228        return time and date stings 
    12291229        """ 
    1230         # date and time  
     1230        # date and time 
    12311231        year, month, day, hour, minute, second, _, _, _ = \ 
    12321232                                    time.localtime() 
    12331233        my_time = str(hour) + ":" + str(minute) + ":" + str(second) 
    1234         date = str( month) + "/" + str(day) + "/" + str(year) 
     1234        date = str(month) + "/" + str(day) + "/" + str(year) 
    12351235        return my_time, date 
    1236     
    1237              
    1238     def on_save(self, evt=None):  
     1236 
     1237 
     1238    def on_save(self, evt=None): 
    12391239        """ 
    12401240        Save invariant state into a file 
     
    12571257        else: 
    12581258            return None 
    1259          
     1259 
    12601260        dlg.Destroy() 
    12611261        # MAC always needs the extension for saving 
     
    12641264        fName = os.path.splitext(path)[0] + extens 
    12651265        self._manager.save_file(filepath=fName, state=self.state) 
    1266          
     1266 
    12671267    def _show_message(self, mssg='', msg='Warning'): 
    12681268        """ 
     
    12711271        # no message for now 
    12721272        return True 
    1273          
     1273 
    12741274    def _reset_output(self): 
    12751275        """ 
     
    12851285        self.inv_container = InvariantContainer() 
    12861286 
    1287      
     1287 
    12881288    def _on_context_menu(self, event): 
    12891289        """ 
     
    12921292        pos = event.GetPosition() 
    12931293        pos = self.ScreenToClient(pos) 
    1294         
    1295         self.PopupMenu(self.popUpMenu, pos)  
    1296        
     1294 
     1295        self.PopupMenu(self.popUpMenu, pos) 
     1296 
    12971297    def _define_structure(self): 
    12981298        """ 
    12991299        Define main sizers needed for this panel 
    13001300        """ 
    1301         ## Box sizers must be defined first before  
     1301        ## Box sizers must be defined first before 
    13021302        #defining buttons/textctrls (MAC). 
    13031303        self.main_sizer = wx.BoxSizer(wx.VERTICAL) 
     
    13091309        data_name_box = wx.StaticBox(self, -1, "I(q) Data Source") 
    13101310        self.data_name_boxsizer = wx.StaticBoxSizer(data_name_box, wx.VERTICAL) 
    1311         self.data_name_boxsizer.SetMinSize((_STATICBOX_WIDTH,-1)) 
     1311        self.data_name_boxsizer.SetMinSize((_STATICBOX_WIDTH, -1)) 
    13121312        self.hint_msg_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    13131313        self.data_name_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    1314         
     1314 
    13151315        self.data_range_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    13161316        #Sizer related to inputs 
    1317         self.sizer_input =  wx.FlexGridSizer(2, 6, 0, 0) 
     1317        self.sizer_input = wx.FlexGridSizer(2, 6, 0, 0) 
    13181318        #Sizer related to inputs 
    13191319        inputs_box = wx.StaticBox(self, -1, "Customized Inputs") 
     
    13231323        extrapolation_box = wx.StaticBox(self, -1, "Extrapolation") 
    13241324        self.extrapolation_sizer = wx.StaticBoxSizer(extrapolation_box, 
    1325                                                         wx.VERTICAL) 
     1325                                                     wx.VERTICAL) 
    13261326        self.extrapolation_sizer.SetMinSize((_STATICBOX_WIDTH, -1)) 
    13271327        self.extrapolation_range_sizer = wx.BoxSizer(wx.HORIZONTAL) 
     
    13301330        low_q_box = wx.StaticBox(self, -1, "Low Q") 
    13311331        self.low_extrapolation_sizer = wx.StaticBoxSizer(low_q_box, wx.VERTICAL) 
    1332        
     1332 
    13331333        self.low_q_sizer = wx.GridBagSizer(5, 5) 
    13341334        #Sizer related to extrapolation at low q range 
     
    13461346        #Sizer related to save button 
    13471347        self.save_button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    1348          
     1348 
    13491349    def _layout_data_name(self): 
    13501350        """ 
    13511351        Draw widgets related to data's name 
    13521352        """ 
    1353         #Sizer hint  
     1353        #Sizer hint 
    13541354        hint_msg = "" 
    1355          
    1356         self.hint_msg_txt = wx.StaticText(self, -1, hint_msg)   
     1355 
     1356        self.hint_msg_txt = wx.StaticText(self, -1, hint_msg) 
    13571357        self.hint_msg_txt.SetForegroundColour("red") 
    13581358        msg = "Highlight = mouse the mouse's cursor on the data until" 
     
    13611361        self.hint_msg_sizer.Add(self.hint_msg_txt) 
    13621362        #Data name [string] 
    1363         data_name_txt = wx.StaticText(self, -1, 'Name:')   
    1364         
    1365         self.data_name_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH*4, 20), 
    1366                                             style=0)  
     1363        data_name_txt = wx.StaticText(self, -1, 'Name:') 
     1364 
     1365        self.data_name_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH * 4, 20), 
     1366                                            style=0) 
    13671367        self.data_name_tcl.SetToolTipString("Data's name.") 
    1368         self.data_name_sizer.AddMany([(data_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    1369                                        (self.data_name_tcl, 0, wx.EXPAND)]) 
     1368        self.data_name_sizer.AddMany([(data_name_txt, 0, wx.LEFT | wx.RIGHT, 10), 
     1369                                      (self.data_name_tcl, 0, wx.EXPAND)]) 
    13701370        #Data range [string] 
    1371         data_range_txt = wx.StaticText(self, -1, 'Total Q Range (1/A): ')  
    1372         data_min_txt = wx.StaticText(self, -1, 'Min : ')   
     1371        data_range_txt = wx.StaticText(self, -1, 'Total Q Range (1/A): ') 
     1372        data_min_txt = wx.StaticText(self, -1, 'Min : ') 
    13731373        self.data_min_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    13741374                                           style=0, name='data_min_tcl') 
    13751375        self.data_min_tcl.SetToolTipString("The minimum value of q range.") 
    1376         data_max_txt = wx.StaticText(self, -1, 'Max : ')  
     1376        data_max_txt = wx.StaticText(self, -1, 'Max : ') 
    13771377        self.data_max_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    1378                                            style=0, name='data_max_tcl')  
     1378                                           style=0, name='data_max_tcl') 
    13791379        self.data_max_tcl.SetToolTipString("The maximum value of q range.") 
    13801380        self.data_range_sizer.AddMany([(data_range_txt, 0, wx.RIGHT, 5), 
     
    13831383                                       (data_max_txt, 0, wx.RIGHT, 5), 
    13841384                                       (self.data_max_tcl, 0, wx.RIGHT, 10)]) 
    1385         self.data_name_boxsizer.AddMany([(self.hint_msg_sizer, 0 , wx.ALL, 5), 
    1386                             (self.data_name_sizer, 0 , wx.ALL, 10), 
    1387                                      (self.data_range_sizer, 0 , wx.ALL, 10)]) 
    1388      
     1385        self.data_name_boxsizer.AddMany([(self.hint_msg_sizer, 0, wx.ALL, 5), 
     1386                                         (self.data_name_sizer, 0, wx.ALL, 10), 
     1387                                         (self.data_range_sizer, 0, wx.ALL, 10)]) 
     1388 
    13891389    def _enable_fit_power_law_low(self, event=None): 
    13901390        """ 
    13911391        Enable and disable the power value editing 
    13921392        """ 
    1393         if event != None:  
     1393        if event != None: 
    13941394            self._set_bookmark_flag(True) 
    13951395            self._set_preview_flag(False) 
    1396      
     1396 
    13971397        if self.fix_enable_low.IsEnabled(): 
    1398              
     1398 
    13991399            if self.fix_enable_low.GetValue(): 
    14001400                self.fit_enable_low.SetValue(False) 
     
    14041404                self.power_low_tcl.Disable() 
    14051405        self._set_state(event=event) 
    1406             
     1406 
    14071407    def _enable_low_q_section(self, event=None): 
    14081408        """ 
    14091409        Disable or enable some button if the user enable low q extrapolation 
    14101410        """ 
    1411         if event != None:  
     1411        if event != None: 
    14121412            self._set_bookmark_flag(True) 
    14131413            self._set_preview_flag(False) 
    1414              
     1414 
    14151415        if self.enable_low_cbox.GetValue(): 
    14161416            self.npts_low_tcl.Enable() 
     
    14261426            self.guinier.Disable() 
    14271427            self.power_law_low.Disable() 
    1428          
     1428 
    14291429        self._enable_power_law_low() 
    14301430        self._enable_fit_power_law_low() 
    14311431        self._set_state(event=event) 
    14321432        self.button_calculate.SetFocus() 
    1433          
     1433 
    14341434    def _enable_power_law_low(self, event=None): 
    14351435        """ 
    14361436        Enable editing power law section at low q range 
    14371437        """ 
    1438         if event != None:  
     1438        if event != None: 
    14391439            self._set_bookmark_flag(True) 
    14401440            self._set_preview_flag(False) 
     
    14511451        self._enable_fit_power_law_low() 
    14521452        self._set_state(event=event) 
    1453              
     1453 
    14541454    def _layout_extrapolation_low(self): 
    14551455        """ 
     
    14601460                                           name='enable_low_cbox') 
    14611461        wx.EVT_CHECKBOX(self, self.enable_low_cbox.GetId(), 
    1462                                          self._enable_low_q_section) 
     1462                        self._enable_low_q_section) 
    14631463        self.fix_enable_low = wx.RadioButton(self, -1, 'Fix', 
    1464                                          (10, 10), style=wx.RB_GROUP, 
    1465                                          name='fix_enable_low') 
     1464                                             (10, 10), style=wx.RB_GROUP, 
     1465                                             name='fix_enable_low') 
    14661466        self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_low, 
    1467                                      id=self.fix_enable_low.GetId()) 
     1467                  id=self.fix_enable_low.GetId()) 
    14681468        self.fit_enable_low = wx.RadioButton(self, -1, 'Fit', (10, 10), 
    14691469                                             name='fit_enable_low') 
    1470         self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_low,  
    1471                                         id=self.fit_enable_low.GetId()) 
     1470        self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_low, 
     1471                  id=self.fit_enable_low.GetId()) 
    14721472        self.guinier = wx.RadioButton(self, -1, 'Guinier', 
    1473                                          (10, 10), style=wx.RB_GROUP, 
    1474                                          name='guinier') 
     1473                                      (10, 10), style=wx.RB_GROUP, 
     1474                                      name='guinier') 
    14751475        self.Bind(wx.EVT_RADIOBUTTON, self._enable_power_law_low, 
    1476                                      id=self.guinier.GetId())         
     1476                  id=self.guinier.GetId()) 
    14771477        self.power_law_low = wx.RadioButton(self, -1, 'Power Law', 
    14781478                                            (10, 10), name='power_law_low') 
    1479         self.Bind(wx.EVT_RADIOBUTTON, self._enable_power_law_low,  
    1480                                         id=self.power_law_low.GetId()) 
    1481          
     1479        self.Bind(wx.EVT_RADIOBUTTON, self._enable_power_law_low, 
     1480                  id=self.power_law_low.GetId()) 
     1481 
    14821482        npts_low_txt = wx.StaticText(self, -1, 'Npts') 
    14831483        self.npts_low_tcl = InvTextCtrl(self, -1, 
    1484                                         size=(_BOX_WIDTH*2/3, -1), 
     1484                                        size=(_BOX_WIDTH * 2 / 3, -1), 
    14851485                                        name='npts_low_tcl') 
    14861486        wx.EVT_TEXT(self, self.npts_low_tcl.GetId(), self._on_text) 
     
    14891489        self.npts_low_tcl.SetToolTipString(msg_hint) 
    14901490        power_txt = wx.StaticText(self, -1, 'Power') 
    1491         self.power_low_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1), 
     1491        self.power_low_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH * 2 / 3, -1), 
    14921492                                         name='power_low_tcl') 
    14931493        wx.EVT_TEXT(self, self.power_low_tcl.GetId(), self._on_text) 
    1494         
     1494 
    14951495        power_hint_txt = "Exponent to apply to the Power_law function." 
    14961496        self.power_low_tcl.SetToolTipString(power_hint_txt) 
     
    14981498        ix = 0 
    14991499        self.low_q_sizer.Add(self.enable_low_cbox, (iy, ix), (1, 5), 
    1500                             wx.TOP|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1500                             wx.TOP | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    15011501        iy += 1 
    15021502        ix = 0 
    15031503        self.low_q_sizer.Add(npts_low_txt, (iy, ix), (1, 1), 
    1504                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1504                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    15051505        ix += 1 
    1506         self.low_q_sizer.Add(self.npts_low_tcl, (iy, ix), (1,1), 
    1507                             wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     1506        self.low_q_sizer.Add(self.npts_low_tcl, (iy, ix), (1, 1), 
     1507                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    15081508        iy += 1 
    15091509        ix = 0 
    1510         self.low_q_sizer.Add(self.guinier, (iy, ix), (1,2), 
    1511                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1510        self.low_q_sizer.Add(self.guinier, (iy, ix), (1, 2), 
     1511                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    15121512        iy += 1 
    15131513        ix = 0 
    15141514        self.low_q_sizer.Add(self.power_law_low, (iy, ix), (1, 2), 
    1515                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1515                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    15161516        # Parameter controls for power law 
    15171517        ix = 1 
    15181518        iy += 1 
    15191519        self.low_q_sizer.Add(self.fix_enable_low, (iy, ix), (1, 1), 
    1520                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     1520                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    15211521        ix += 1 
    1522         self.low_q_sizer.Add(self.fit_enable_low, (iy, ix),(1,1), 
    1523                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     1522        self.low_q_sizer.Add(self.fit_enable_low, (iy, ix), (1, 1), 
     1523                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    15241524        ix = 1 
    15251525        iy += 1 
    15261526        self.low_q_sizer.Add(power_txt, (iy, ix), (1, 1), 
    1527                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     1527                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    15281528        ix += 1 
    15291529        self.low_q_sizer.Add(self.power_low_tcl, (iy, ix), (1, 1), 
    1530                             wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     1530                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    15311531        self.low_extrapolation_sizer.Add(self.low_q_sizer) 
    1532          
     1532 
    15331533    def _enable_fit_power_law_high(self, event=None): 
    15341534        """ 
    15351535        Enable and disable the power value editing 
    15361536        """ 
    1537         if event != None:  
     1537        if event != None: 
    15381538            self._set_bookmark_flag(True) 
    1539      
     1539 
    15401540            self._set_preview_flag(False) 
    15411541        if self.fix_enable_high.IsEnabled(): 
     
    15471547                self.power_high_tcl.Disable() 
    15481548        self._set_state(event=event) 
    1549          
     1549 
    15501550    def _enable_high_q_section(self, event=None): 
    15511551        """ 
    15521552        Disable or enable some button if the user enable high q extrapolation 
    15531553        """ 
    1554         if event != None:  
     1554        if event != None: 
    15551555            self._set_bookmark_flag(True) 
    15561556            self._set_preview_flag(False) 
     
    15701570        self._set_state(event=event) 
    15711571        self.button_calculate.SetFocus() 
    1572   
     1572 
    15731573    def _layout_extrapolation_high(self): 
    15741574        """ 
     
    15791579                                            name='enable_high_cbox') 
    15801580        wx.EVT_CHECKBOX(self, self.enable_high_cbox.GetId(), 
    1581                                          self._enable_high_q_section) 
     1581                        self._enable_high_q_section) 
    15821582        self.fix_enable_high = wx.RadioButton(self, -1, 'Fix', 
    1583                                          (10, 10), style=wx.RB_GROUP, 
    1584                                          name='fix_enable_high') 
     1583                                              (10, 10), style=wx.RB_GROUP, 
     1584                                              name='fix_enable_high') 
    15851585        self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_high, 
    1586                                      id=self.fix_enable_high.GetId()) 
     1586                  id=self.fix_enable_high.GetId()) 
    15871587        self.fit_enable_high = wx.RadioButton(self, -1, 'Fit', (10, 10), 
    1588                                               name='fit_enable_high')      
    1589         self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_high,  
    1590                                         id=self.fit_enable_high.GetId()) 
    1591          
     1588                                              name='fit_enable_high') 
     1589        self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_high, 
     1590                  id=self.fit_enable_high.GetId()) 
     1591 
    15921592        self.power_law_high = wx.StaticText(self, -1, 'Power Law') 
    15931593        msg_hint = "Check to extrapolate data at high-Q" 
    15941594        self.power_law_high.SetToolTipString(msg_hint) 
    15951595        npts_high_txt = wx.StaticText(self, -1, 'Npts') 
    1596         self.npts_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1), 
     1596        self.npts_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH * 2 / 3, -1), 
    15971597                                         name='npts_high_tcl') 
    15981598        wx.EVT_TEXT(self, self.npts_high_tcl.GetId(), self._on_text) 
     
    16011601        self.npts_high_tcl.SetToolTipString(msg_hint) 
    16021602        power_txt = wx.StaticText(self, -1, 'Power') 
    1603         self.power_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1), 
     1603        self.power_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH * 2 / 3, -1), 
    16041604                                          name='power_high_tcl') 
    16051605        wx.EVT_TEXT(self, self.power_high_tcl.GetId(), self._on_text) 
     
    16091609        ix = 0 
    16101610        self.high_q_sizer.Add(self.enable_high_cbox, (iy, ix), (1, 5), 
    1611                             wx.TOP|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1611                              wx.TOP | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    16121612        iy += 1 
    16131613        ix = 0 
    16141614        self.high_q_sizer.Add(npts_high_txt, (iy, ix), (1, 1), 
    1615                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1615                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    16161616        ix += 1 
    16171617        self.high_q_sizer.Add(self.npts_high_tcl, (iy, ix), (1, 1), 
    1618                             wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     1618                              wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    16191619        iy += 1 
    16201620        ix = 0 
    1621         self.high_q_sizer.Add(self.power_law_high, (iy, ix),(1, 2), 
    1622                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    1623         
     1621        self.high_q_sizer.Add(self.power_law_high, (iy, ix), (1, 2), 
     1622                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
     1623 
    16241624        # Parameter controls for power law 
    16251625        ix = 1 
    16261626        iy += 1 
    1627         self.high_q_sizer.Add(self.fix_enable_high,(iy, ix), (1, 1), 
    1628                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     1627        self.high_q_sizer.Add(self.fix_enable_high, (iy, ix), (1, 1), 
     1628                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    16291629        ix += 1 
    1630         self.high_q_sizer.Add(self.fit_enable_high,(iy, ix), (1, 1), 
    1631                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     1630        self.high_q_sizer.Add(self.fit_enable_high, (iy, ix), (1, 1), 
     1631                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    16321632        ix = 1 
    16331633        iy += 1 
    1634         self.high_q_sizer.Add(power_txt,(iy, ix), (1, 1), 
    1635                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1634        self.high_q_sizer.Add(power_txt, (iy, ix), (1, 1), 
     1635                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    16361636        ix += 1 
    1637         self.high_q_sizer.Add(self.power_high_tcl, (iy, ix),  (1, 1), 
    1638                             wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    1639         self.high_extrapolation_sizer.Add(self.high_q_sizer, 0,  
    1640                                                 wx.BOTTOM, 20) 
    1641          
     1637        self.high_q_sizer.Add(self.power_high_tcl, (iy, ix), (1, 1), 
     1638                              wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     1639        self.high_extrapolation_sizer.Add(self.high_q_sizer, 0, 
     1640                                          wx.BOTTOM, 20) 
     1641 
    16421642    def _layout_extrapolation(self): 
    16431643        """ 
     
    16471647        extra_hint_txt = wx.StaticText(self, -1, extra_hint) 
    16481648        #Extrapolation range [string] 
    1649         extrapolation_min_txt = wx.StaticText(self, -1, 'Min:')   
    1650         self.extrapolation_min_tcl = OutputTextCtrl(self, -1,  
    1651                                                 size=(_BOX_WIDTH, 20), style=0, 
    1652                                                 name='extrapolation_min_tcl') 
     1649        extrapolation_min_txt = wx.StaticText(self, -1, 'Min:') 
     1650        self.extrapolation_min_tcl = OutputTextCtrl(self, -1, 
     1651                                                    size=(_BOX_WIDTH, 20), style=0, 
     1652                                                    name='extrapolation_min_tcl') 
    16531653        self.extrapolation_min_tcl.SetValue(str(Q_MINIMUM)) 
    16541654        hint_msg = "The minimum extrapolated q value." 
    16551655        self.extrapolation_min_tcl.SetToolTipString(hint_msg) 
    1656         extrapolation_max_txt = wx.StaticText(self, -1, 'Max:')  
     1656        extrapolation_max_txt = wx.StaticText(self, -1, 'Max:') 
    16571657        self.extrapolation_max_tcl = OutputTextCtrl(self, -1, 
    1658                                                   size=(_BOX_WIDTH, 20), 
    1659                                                   style=0, 
    1660                                                   name='extrapolation_max_tcl')  
     1658                                                    size=(_BOX_WIDTH, 20), 
     1659                                                    style=0, 
     1660                                                    name='extrapolation_max_tcl') 
    16611661        self.extrapolation_max_tcl.SetValue(str(Q_MAXIMUM)) 
    16621662        hint_msg = "The maximum extrapolated q value." 
    16631663        self.extrapolation_max_tcl.SetToolTipString(hint_msg) 
    1664         self.extrapolation_range_sizer.AddMany([(extra_hint_txt, 0,  
     1664        self.extrapolation_range_sizer.AddMany([(extra_hint_txt, 0, 
    16651665                                                 wx.LEFT, 5), 
    16661666                                                (extrapolation_min_txt, 0, 
    16671667                                                 wx.LEFT, 10), 
    16681668                                                (self.extrapolation_min_tcl, 
    1669                                                             0, wx.LEFT, 5), 
     1669                                                 0, wx.LEFT, 5), 
    16701670                                                (extrapolation_max_txt, 0, 
    16711671                                                 wx.LEFT, 20), 
    16721672                                                (self.extrapolation_max_tcl, 
    1673                                                             0, wx.LEFT, 5)]) 
     1673                                                 0, wx.LEFT, 5)]) 
    16741674        self._layout_extrapolation_low() 
    16751675        self._layout_extrapolation_high() 
    1676         self.extrapolation_low_high_sizer.AddMany(\ 
    1677                                             [(self.low_extrapolation_sizer, 
    1678                                             0, wx.LEFT|wx.BOTTOM|wx.TOP, 5), 
    1679                                             (self.high_extrapolation_sizer, 
    1680                                              0, wx.LEFT|wx.BOTTOM|wx.TOP, 5)]) 
     1676        self.extrapolation_low_high_sizer.AddMany([(self.low_extrapolation_sizer, 
     1677                                                    0, wx.LEFT | wx.BOTTOM | wx.TOP, 5), 
     1678                                                   (self.high_extrapolation_sizer, 
     1679                                                    0, wx.LEFT | wx.BOTTOM | wx.TOP, 5)]) 
    16811680        self.extrapolation_sizer.AddMany([(self.extrapolation_range_sizer), 
    1682                                         (self.extrapolation_low_high_sizer)]) 
    1683          
     1681                                          (self.extrapolation_low_high_sizer)]) 
     1682 
    16841683    def _layout_volume_surface_sizer(self): 
    16851684        """ 
     
    16881687        unit_volume = '' 
    16891688        unit_surface = '[1/A]' 
    1690         uncertainty = "+/-"  
     1689        uncertainty = "+/-" 
    16911690        volume_txt = wx.StaticText(self, -1, 'Volume Fraction') 
    16921691        self.volume_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, -1), 
     
    17001699        self.volume_err_tcl.SetToolTipString(hint_msg) 
    17011700        volume_units_txt = wx.StaticText(self, -1, unit_volume) 
    1702          
     1701 
    17031702        surface_txt = wx.StaticText(self, -1, 'Specific Surface') 
    17041703        self.surface_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, -1), 
     
    17151714        ix = 0 
    17161715        self.volume_surface_sizer.Add(volume_txt, (iy, ix), (1, 1), 
    1717                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1716                                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    17181717        ix += 1 
    17191718        self.volume_surface_sizer.Add(self.volume_tcl, (iy, ix), (1, 1), 
    1720                             wx.EXPAND|wx.ADJUST_MINSIZE, 20) 
     1719                                      wx.EXPAND | wx.ADJUST_MINSIZE, 20) 
    17211720        ix += 1 
    17221721        self.volume_surface_sizer.Add(wx.StaticText(self, -1, uncertainty), 
    1723                          (iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 10)  
     1722                                      (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17241723        ix += 1 
    17251724        self.volume_surface_sizer.Add(self.volume_err_tcl, (iy, ix), (1, 1), 
    1726                             wx.EXPAND|wx.ADJUST_MINSIZE, 10)  
     1725                                      wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17271726        ix += 1 
    17281727        self.volume_surface_sizer.Add(volume_units_txt, (iy, ix), (1, 1), 
    1729                              wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
     1728                                      wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17301729        iy += 1 
    17311730        ix = 0 
    17321731        self.volume_surface_sizer.Add(surface_txt, (iy, ix), (1, 1), 
    1733                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1732                                      wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    17341733        ix += 1 
    17351734        self.volume_surface_sizer.Add(self.surface_tcl, (iy, ix), (1, 1), 
    1736                             wx.EXPAND|wx.ADJUST_MINSIZE, 20) 
     1735                                      wx.EXPAND | wx.ADJUST_MINSIZE, 20) 
    17371736        ix += 1 
    17381737        self.volume_surface_sizer.Add(wx.StaticText(self, -1, uncertainty), 
    1739                          (iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 10)  
     1738                                      (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17401739        ix += 1 
    17411740        self.volume_surface_sizer.Add(self.surface_err_tcl, (iy, ix), (1, 1), 
    1742                             wx.EXPAND|wx.ADJUST_MINSIZE, 10)  
     1741                                      wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17431742        ix += 1 
    17441743        self.volume_surface_sizer.Add(surface_units_txt, (iy, ix), (1, 1), 
    1745                             wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
     1744                                      wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17461745        static_line = wx.StaticLine(self, -1) 
    17471746        iy += 1 
    17481747        ix = 0 
    1749          
     1748 
    17501749    def _layout_invariant_sizer(self): 
    17511750        """ 
    17521751        Draw widgets related to invariant 
    17531752        """ 
    1754         uncertainty = "+/-"  
     1753        uncertainty = "+/-" 
    17551754        unit_invariant = '[1/(cm*A^3)]' 
    17561755        invariant_total_txt = wx.StaticText(self, -1, 'Invariant Total [Q*]') 
     
    17621761        self.invariant_total_err_tcl = OutputTextCtrl(self, -1, 
    17631762                                                      size=(_BOX_WIDTH, -1), 
    1764                                                 name='invariant_total_err_tcl') 
     1763                                                      name='invariant_total_err_tcl') 
    17651764        hint_msg = "Uncertainty on invariant." 
    17661765        self.invariant_total_err_tcl.SetToolTipString(hint_msg) 
    1767         invariant_total_units_txt = wx.StaticText(self, -1, unit_invariant,  
    1768                                                   size=(80,-1)) 
    1769      
     1766        invariant_total_units_txt = wx.StaticText(self, -1, unit_invariant, 
     1767                                                  size=(80, -1)) 
     1768 
    17701769        #Invariant total 
    17711770        iy = 0 
    17721771        ix = 0 
    17731772        self.invariant_sizer.Add(invariant_total_txt, (iy, ix), (1, 1), 
    1774                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     1773                                 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    17751774        ix += 1 
    17761775        self.invariant_sizer.Add(self.invariant_total_tcl, (iy, ix), (1, 1), 
    1777                           wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
     1776                                 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17781777        ix += 1 
    1779         self.invariant_sizer.Add( wx.StaticText(self, -1, uncertainty), 
    1780                          (iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 10)  
     1778        self.invariant_sizer.Add(wx.StaticText(self, -1, uncertainty), 
     1779                                 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17811780        ix += 1 
    17821781        self.invariant_sizer.Add(self.invariant_total_err_tcl, (iy, ix), (1, 1), 
    1783                              wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
     1782                                 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    17841783        ix += 1 
    1785         self.invariant_sizer.Add(invariant_total_units_txt,(iy, ix), (1, 1), 
    1786                           wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
    1787   
     1784        self.invariant_sizer.Add(invariant_total_units_txt, (iy, ix), (1, 1), 
     1785                                 wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
     1786 
    17881787    def _layout_inputs_sizer(self): 
    17891788        """ 
    17901789        Draw widgets related to inputs 
    17911790        """ 
    1792         contrast_txt = wx.StaticText(self, -1, 'Contrast:')   
     1791        contrast_txt = wx.StaticText(self, -1, 'Contrast:') 
    17931792        self.contrast_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    17941793                                        style=0, name='contrast_tcl') 
     
    17961795        contrast_hint_txt = "Contrast" 
    17971796        self.contrast_tcl.SetToolTipString(contrast_hint_txt) 
    1798         contrast_unit_txt = wx.StaticText(self, -1, '[1/A^2]', size=(40,-1))   
    1799         porod_const_txt = wx.StaticText(self, -1,  
    1800                                         'Porod\nConstant:\n(optional)\n')   
    1801         porod_unit_txt = wx.StaticText(self, -1, '[1/(cm*A^4)]', size=(80,-1))  
    1802         self.porod_constant_tcl = InvTextCtrl(self, -1,  
     1797        contrast_unit_txt = wx.StaticText(self, -1, '[1/A^2]', size=(40, -1)) 
     1798        porod_const_txt = wx.StaticText(self, -1, 
     1799                                        'Porod\nConstant:\n(optional)\n') 
     1800        porod_unit_txt = wx.StaticText(self, -1, '[1/(cm*A^4)]', size=(80, -1)) 
     1801        self.porod_constant_tcl = InvTextCtrl(self, -1, 
    18031802                                              size=(_BOX_WIDTH, 20), style=0, 
    1804                                               name='porod_constant_tcl')  
     1803                                              name='porod_constant_tcl') 
    18051804        wx.EVT_TEXT(self, self.porod_constant_tcl.GetId(), self._on_text) 
    18061805        porod_const_hint_txt = "Porod Constant" 
    18071806        self.porod_constant_tcl.SetToolTipString(porod_const_hint_txt) 
    1808          
    1809         background_txt = wx.StaticText(self, -1, 'Background:')   
     1807 
     1808        background_txt = wx.StaticText(self, -1, 'Background:') 
    18101809        self.background_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    1811                                           style=0, name='background_tcl')  
     1810                                          style=0, name='background_tcl') 
    18121811        wx.EVT_TEXT(self, self.background_tcl.GetId(), self._on_text) 
    18131812        background_hint_txt = "Background" 
    18141813        self.background_tcl.SetToolTipString(background_hint_txt) 
    1815         background_unit_txt = wx.StaticText(self, -1, '[1/cm]')   
    1816         scale_txt = wx.StaticText(self, -1, 'Scale:')   
     1814        background_unit_txt = wx.StaticText(self, -1, '[1/cm]') 
     1815        scale_txt = wx.StaticText(self, -1, 'Scale:') 
    18171816        self.scale_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0, 
    18181817                                     name='scale_tcl') 
     
    18201819        scale_hint_txt = "Scale" 
    18211820        self.scale_tcl.SetToolTipString(scale_hint_txt) 
    1822         self.sizer_input.AddMany([(background_txt, 0, wx.LEFT|wx.BOTTOM, 5), 
    1823                             (self.background_tcl, 0, wx.LEFT|wx.BOTTOM, 5), 
    1824                             (background_unit_txt, 0, wx.LEFT|wx.BOTTOM, 5), 
    1825                             (scale_txt, 0, wx.LEFT|wx.BOTTOM, 10), 
    1826                             (self.scale_tcl, 0, wx.LEFT|wx.BOTTOM|wx.RIGHT, 5), 
    1827                             (10, 10), 
    1828                             (contrast_txt, 0, wx.LEFT|wx.BOTTOM, 5), 
    1829                             (self.contrast_tcl, 0, wx.LEFT|wx.BOTTOM, 5), 
    1830                             (contrast_unit_txt, 0, wx.LEFT|wx.BOTTOM, 5), 
    1831                             (porod_const_txt, 0, wx.LEFT, 10), 
    1832                 (self.porod_constant_tcl, 0, wx.LEFT|wx.BOTTOM|wx.RIGHT, 5), 
    1833                 (porod_unit_txt, 0, wx.LEFT|wx.BOTTOM, 5)]) 
     1821        self.sizer_input.AddMany([(background_txt, 0, wx.LEFT | wx.BOTTOM, 5), 
     1822                                  (self.background_tcl, 0, wx.LEFT | wx.BOTTOM, 5), 
     1823                                  (background_unit_txt, 0, wx.LEFT | wx.BOTTOM, 5), 
     1824                                  (scale_txt, 0, wx.LEFT | wx.BOTTOM, 10), 
     1825                                  (self.scale_tcl, 0, wx.LEFT | wx.BOTTOM | wx.RIGHT, 5), 
     1826                                  (10, 10), 
     1827                                  (contrast_txt, 0, wx.LEFT | wx.BOTTOM, 5), 
     1828                                  (self.contrast_tcl, 0, wx.LEFT | wx.BOTTOM, 5), 
     1829                                  (contrast_unit_txt, 0, wx.LEFT | wx.BOTTOM, 5), 
     1830                                  (porod_const_txt, 0, wx.LEFT, 10), 
     1831                                  (self.porod_constant_tcl, 0, wx.LEFT | wx.BOTTOM | wx.RIGHT, 5), 
     1832                                  (porod_unit_txt, 0, wx.LEFT | wx.BOTTOM, 5)]) 
    18341833        self.inputs_sizer.Add(self.sizer_input) 
    1835         
     1834 
    18361835    def _layout_outputs_sizer(self): 
    18371836        """ 
     
    18421841        static_line = wx.StaticLine(self, -1) 
    18431842        self.outputs_sizer.AddMany([(self.volume_surface_sizer, 
    1844                                       0, wx.TOP|wx.BOTTOM, 10), 
     1843                                     0, wx.TOP | wx.BOTTOM, 10), 
    18451844                                    (static_line, 0, wx.EXPAND, 0), 
    1846                          (self.invariant_sizer, 0, wx.TOP|wx.BOTTOM, 10)]) 
    1847     def _layout_button(self):   
     1845                                    (self.invariant_sizer, 0, wx.TOP | wx.BOTTOM, 10)]) 
     1846    def _layout_button(self): 
    18481847        """ 
    18491848        Do the layout for the button widgets 
    1850         """  
     1849        """ 
    18511850        #compute button 
    18521851        id = wx.NewId() 
     
    18541853                                          name='compute_invariant') 
    18551854        self.button_calculate.SetToolTipString("Compute invariant") 
    1856         self.Bind(wx.EVT_BUTTON, self.compute_invariant, id=id)    
     1855        self.Bind(wx.EVT_BUTTON, self.compute_invariant, id=id) 
    18571856        #detail button 
    18581857        id = wx.NewId() 
     
    18631862        details = "Details on Invariant Total Calculations" 
    18641863        details_txt = wx.StaticText(self, -1, details) 
    1865         self.button_sizer.AddMany([(details_txt, 0 ,  
    1866                                     wx.RIGHT|wx.BOTTOM|wx.TOP, 10), 
    1867                                    (self.button_details, 0 , wx.ALL, 10), 
    1868                         (self.button_calculate, 0 , 
    1869                          wx.RIGHT|wx.TOP|wx.BOTTOM, 10)]) 
     1864        self.button_sizer.AddMany([(details_txt, 0, 
     1865                                    wx.RIGHT | wx.BOTTOM | wx.TOP, 10), 
     1866                                   (self.button_details, 0, wx.ALL, 10), 
     1867                                   (self.button_calculate, 0, 
     1868                                    wx.RIGHT | wx.TOP | wx.BOTTOM, 10)]) 
    18701869    def _do_layout(self): 
    18711870        """ 
     
    18791878        self._layout_button() 
    18801879        self.main_sizer.AddMany([(self.data_name_boxsizer, 0, wx.ALL, 10), 
    1881                                   (self.outputs_sizer, 0, 
    1882                                   wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 
    1883                                   (self.button_sizer, 0, wx.LEFT|wx.RIGHT, 15), 
     1880                                 (self.outputs_sizer, 0, 
     1881                                  wx.LEFT | wx.RIGHT | wx.BOTTOM, 10), 
     1882                                 (self.button_sizer, 0, wx.LEFT | wx.RIGHT, 15), 
    18841883                                 (self.inputs_sizer, 0, 
    1885                                   wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 
    1886                                   (self.extrapolation_sizer, 0, 
    1887                                   wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)]) 
     1884                                  wx.LEFT | wx.RIGHT | wx.BOTTOM, 10), 
     1885                                 (self.extrapolation_sizer, 0, 
     1886                                  wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)]) 
    18881887        self.SetSizer(self.main_sizer) 
    18891888        self.SetAutoLayout(True) 
    1890          
    1891          
     1889 
     1890 
    18921891class InvariantDialog(wx.Dialog): 
    18931892    """ 
     
    18971896                 data=None, title="Invariant", base=None): 
    18981897        wx.Dialog.__init__(self, parent, id, title, size=(PANEL_WIDTH, 
    1899                                                              PANEL_HEIGHT)) 
     1898                                                          PANEL_HEIGHT)) 
    19001899        self.panel = InvariantPanel(self) 
    19011900        self.Centre() 
    19021901        self.Show(True) 
    1903          
     1902 
    19041903class InvariantWindow(wx.Frame): 
    19051904    """ 
    19061905    Invariant Window 
    19071906    """ 
    1908     def __init__(self, parent=None, id=1, graph=None,  
     1907    def __init__(self, parent=None, id=1, graph=None, 
    19091908                 data=None, title="Invariant", base=None): 
    1910          
    1911         wx.Frame.__init__(self, parent, id, title, size=(PANEL_WIDTH +100, 
    1912                                                              PANEL_HEIGHT+100)) 
     1909 
     1910        wx.Frame.__init__(self, parent, id, title, size=(PANEL_WIDTH + 100, 
     1911                                                         PANEL_HEIGHT + 100)) 
    19131912        from sas.dataloader.loader import  Loader 
    19141913        self.loader = Loader() 
    1915         import invariant 
    19161914        path = "C:/ECLPS/workspace/trunk/sasdataloader/test/ascii_test_3.txt" 
    19171915        data = self.loader.load(path) 
     
    19221920        self.Centre() 
    19231921        self.Show(True) 
    1924          
     1922 
    19251923class MyApp(wx.App): 
    19261924    """ 
     
    19351933        frame.Show(True) 
    19361934        self.SetTopWindow(frame) 
    1937          
     1935 
    19381936        return True 
    1939        
     1937 
    19401938# end of class MyApp 
    19411939 
Note: See TracChangeset for help on using the changeset viewer.