Ignore:
Timestamp:
Oct 27, 2010 2:41:30 PM (14 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
6cda91f
Parents:
c4d6900
Message:

working with pylint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/perspectives/calculator/sld_panel.py

    r855546d rb0ab6cb  
    11""" 
    2     This module provide GUI for the neutron scattering length density calculator 
    3     @author: Gervaise B. Alina 
     2This module provide GUI for the neutron scattering length density calculator 
     3 
    44""" 
    55 
     
    88import sys 
    99 
    10 from sans.guiframe.utils import format_number, check_float 
     10from sans.guiframe.utils import format_number 
     11from sans.guiframe.utils import check_float 
    1112from sans.guicomm.events import StatusEvent   
    1213 
    1314# the calculator default value for wavelength is 6 
    14 import periodictable 
     15#import periodictable 
    1516from periodictable import formula 
    16 from periodictable.xsf import xray_energy, xray_sld_from_atoms 
    17 from periodictable.constants import avogadro_number 
    18 from  periodictable.nsf import neutron_scattering 
     17from periodictable.xsf import xray_energy 
     18from periodictable.xsf import xray_sld_from_atoms 
     19#rom periodictable.constants import avogadro_number 
     20from periodictable.nsf import neutron_scattering 
    1921        
    2022WAVELENGTH = 6.0 
     
    2426 
    2527#SLD panel size  
    26 if sys.platform.count("win32")>0: 
     28if sys.platform.count("win32") > 0: 
    2729    _STATICBOX_WIDTH = 350 
    2830    PANEL_SIZE = 400 
     
    3537class SldPanel(wx.Panel): 
    3638    """ 
    37         Provides the SLD calculator GUI. 
     39    Provides the SLD calculator GUI. 
    3840    """ 
    3941    ## Internal nickname for the window, used by the AUI manager 
     
    4345    ## Flag to tell the AUI manager to put this panel in the center pane 
    4446    CENTER_PANE = True 
    45     def __init__(self, parent, base=None, id=-1): 
    46         wx.Panel.__init__(self, parent, id = id) 
     47     
     48    def __init__(self, parent, base=None): 
     49        """ 
     50        """ 
     51        wx.Panel.__init__(self, parent) 
    4752        #Font size  
    4853        self.SetWindowVariant(variant=FONT_VARIANT) 
     
    5055        self.base = base 
    5156        self.wavelength = WAVELENGTH 
     57        #layout attribute 
     58        self.compound_ctl = None 
     59        self.density_ctl = None 
     60        self.wavelength_ctl = None 
     61        self.neutron_sld_reel_ctl = None 
     62        self.neutron_sld_im_ctl = None 
     63        self.mo_ka_sld_reel_ctl = None 
     64        self.mo_ka_sld_im_ctl = None 
     65        self.cu_ka_sld_reel_ctl = None 
     66        self.cu_ka_sld_im_ctl = None 
     67        self.neutron_abs_ctl = None 
     68        self.neutron_inc_ctl = None 
     69        self.neutron_length_ctl = None 
    5270        #Draw the panel 
    5371        self._do_layout() 
     
    5775    def _do_layout(self): 
    5876        """ 
    59             Draw window content 
     77        Draw window content 
    6078        """ 
    6179        unit_a = '[A]' 
    6280        unit_density = '[g/cm^(3)]' 
    6381        unit_sld = '[1/A^(2)]' 
    64         unit_cm1 ='[1/cm]' 
    65         unit_cm ='[cm]' 
    66         sizer_input = wx.GridBagSizer(5,5) 
    67         sizer_output = wx.GridBagSizer(5,5) 
     82        unit_cm1 = '[1/cm]' 
     83        unit_cm = '[cm]' 
     84        sizer_input = wx.GridBagSizer(5, 5) 
     85        sizer_output = wx.GridBagSizer(5, 5) 
    6886        sizer_button = wx.BoxSizer(wx.HORIZONTAL) 
    6987        sizer1 = wx.BoxSizer(wx.HORIZONTAL) 
     
    7391        inputbox = wx.StaticBox(self, -1, "Input") 
    7492        boxsizer1 = wx.StaticBoxSizer(inputbox, wx.VERTICAL) 
    75         boxsizer1.SetMinSize((_STATICBOX_WIDTH,-1)) 
     93        boxsizer1.SetMinSize((_STATICBOX_WIDTH, -1)) 
    7694         
    7795        compound_txt = wx.StaticText(self, -1, 'Compound ') 
    78         self.compound_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     96        self.compound_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 
    7997        density_txt = wx.StaticText(self, -1, 'Density ') 
    80         self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     98        self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 
    8199        unit_density_txt = wx.StaticText(self, -1, unit_density) 
    82100        wavelength_txt = wx.StaticText(self, -1, 'Wavelength ') 
    83         self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     101        self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 
    84102        self.wavelength_ctl.SetValue(str(self.wavelength)) 
    85103        unit_a_txt = wx.StaticText(self, -1, unit_a) 
    86104        iy = 0 
    87105        ix = 0 
    88         sizer_input.Add(compound_txt,(iy, ix),(1,1),\ 
    89                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     106        sizer_input.Add(compound_txt, (iy, ix), (1, 1), 
     107                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     108        ix += 1 
     109        sizer_input.Add(self.compound_ctl, (iy, ix), (1, 1), 
     110                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     111        iy += 1 
     112        ix = 0 
     113        sizer_input.Add(density_txt, (iy, ix), (1, 1), 
     114                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     115        ix += 1 
     116        sizer_input.Add(self.density_ctl, (iy, ix), (1, 1), 
     117                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    90118        ix +=1 
    91         sizer_input.Add(self.compound_ctl,(iy, ix),(1,1),\ 
    92                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    93         iy += 1 
    94         ix = 0 
    95         sizer_input.Add(density_txt,(iy, ix),(1,1),\ 
    96                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    97         ix += 1 
    98         sizer_input.Add(self.density_ctl, (iy, ix), (1,1),\ 
    99                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    100         ix +=1 
    101         sizer_input.Add(unit_density_txt,(iy, ix),(1,1),\ 
    102                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    103         iy += 1 
    104         ix = 0 
    105         sizer_input.Add(wavelength_txt, (iy, ix),(1,1),\ 
    106                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    107         ix += 1 
    108         sizer_input.Add(self.wavelength_ctl,(iy, ix),(1,1),\ 
    109                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    110         ix += 1 
    111         sizer_input.Add(unit_a_txt,(iy, ix),(1,1),\ 
    112                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    113         boxsizer1.Add( sizer_input ) 
    114         sizer1.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 
     119        sizer_input.Add(unit_density_txt,(iy, ix), (1, 1), 
     120                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     121        iy += 1 
     122        ix = 0 
     123        sizer_input.Add(wavelength_txt, (iy, ix), (1, 1), 
     124                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     125        ix += 1 
     126        sizer_input.Add(self.wavelength_ctl, (iy, ix), (1, 1), 
     127                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     128        ix += 1 
     129        sizer_input.Add(unit_a_txt, (iy, ix), (1, 1), 
     130                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     131        boxsizer1.Add(sizer_input) 
     132        sizer1.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 
    115133        #---------Outputs sizer-------- 
    116134        outputbox = wx.StaticBox(self, -1, "Output") 
    117135        boxsizer2 = wx.StaticBoxSizer(outputbox, wx.VERTICAL) 
    118         boxsizer2.SetMinSize((_STATICBOX_WIDTH,-1)) 
     136        boxsizer2.SetMinSize((_STATICBOX_WIDTH, -1)) 
    119137         
    120138        i_complex = '- i' 
    121139        neutron_sld_txt = wx.StaticText(self, -1, 'Neutron SLD') 
    122         self.neutron_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     140        self.neutron_sld_reel_ctl = wx.TextCtrl(self, -1, 
     141                                                 size=(_BOX_WIDTH, -1)) 
    123142        self.neutron_sld_reel_ctl.SetEditable(False) 
    124143        self.neutron_sld_reel_ctl.SetToolTipString("Neutron SLD real.") 
    125         self.neutron_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     144        self.neutron_sld_im_ctl = wx.TextCtrl(self, -1,  
     145                                              size=(_BOX_WIDTH, -1)) 
    126146        self.neutron_sld_im_ctl.SetEditable(False) 
    127147        self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary.") 
     
    129149         
    130150        cu_ka_sld_txt = wx.StaticText(self, -1, 'Cu Ka SLD') 
    131         self.cu_ka_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     151        self.cu_ka_sld_reel_ctl = wx.TextCtrl(self, -1, 
     152                                               size=(_BOX_WIDTH, -1)) 
    132153        self.cu_ka_sld_reel_ctl.SetEditable(False) 
    133154        self.cu_ka_sld_reel_ctl.SetToolTipString("Cu Ka SLD real.") 
    134         self.cu_ka_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     155        self.cu_ka_sld_im_ctl = wx.TextCtrl(self, -1,  
     156                                            size=(_BOX_WIDTH, -1)) 
    135157        self.cu_ka_sld_im_ctl.SetEditable(False) 
    136158        self.cu_ka_sld_im_ctl.SetToolTipString("Cu Ka SLD imaginary.") 
     
    138160         
    139161        mo_ka_sld_txt = wx.StaticText(self, -1, 'Mo Ka SLD') 
    140         self.mo_ka_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     162        self.mo_ka_sld_reel_ctl = wx.TextCtrl(self, -1, 
     163                                               size=(_BOX_WIDTH, -1)) 
    141164        self.mo_ka_sld_reel_ctl.SetEditable(False) 
    142165        self.mo_ka_sld_reel_ctl.SetToolTipString("Mo Ka SLD real.") 
    143         self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     166        self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, 
     167                                             size=(_BOX_WIDTH, -1)) 
    144168        self.mo_ka_sld_im_ctl.SetEditable(False) 
    145169        self.mo_ka_sld_im_ctl.SetToolTipString("Mo Ka SLD imaginary.") 
     
    147171         
    148172        neutron_inc_txt = wx.StaticText(self, -1, 'Neutron Inc. Xs') 
    149         self.neutron_inc_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     173        self.neutron_inc_ctl = wx.TextCtrl(self, -1, 
     174                                            size=(_BOX_WIDTH, -1)) 
    150175        self.neutron_inc_ctl.SetEditable(False) 
    151176        self.neutron_inc_ctl.SetToolTipString("Neutron Inc. Xs") 
     
    153178        
    154179        neutron_abs_txt = wx.StaticText(self, -1, 'Neutron Abs. Xs')      
    155         self.neutron_abs_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     180        self.neutron_abs_ctl = wx.TextCtrl(self, -1,  
     181                                           size=(_BOX_WIDTH, -1)) 
    156182        self.neutron_abs_ctl.SetEditable(False) 
    157183        self.neutron_abs_ctl.SetToolTipString("Neutron Abs. Xs") 
     
    159185       
    160186        neutron_length_txt = wx.StaticText(self, -1, 'Neutron 1/e length') 
    161         self.neutron_length_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     187        self.neutron_length_ctl = wx.TextCtrl(self, -1, 
     188                                               size=(_BOX_WIDTH, -1)) 
    162189        self.neutron_length_ctl.SetEditable(False) 
    163190        self.neutron_length_ctl.SetToolTipString("Neutron 1/e length") 
     
    166193        iy = 0 
    167194        ix = 0 
    168         sizer_output.Add(neutron_sld_txt,(iy, ix),(1,1), 
    169                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    170         ix += 1 
    171         sizer_output.Add(self.neutron_sld_reel_ctl,(iy, ix),(1,1), 
    172                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    173         ix += 1 
    174         sizer_output.Add(wx.StaticText(self, -1, i_complex) 
    175                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    176         ix +=1 
    177         sizer_output.Add(self.neutron_sld_im_ctl 
    178                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    179         ix +=1 
    180         sizer_output.Add(neutron_sld_units_txt 
    181                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    182         iy += 1 
    183         ix = 0 
    184         sizer_output.Add(cu_ka_sld_txt,(iy, ix),(1,1), 
    185                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    186         ix +=1 
    187         sizer_output.Add(self.cu_ka_sld_reel_ctl,(iy, ix),(1,1), 
    188                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    189         ix +=1 
    190         sizer_output.Add(wx.StaticText(self, -1, i_complex) 
    191                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    192         ix += 1 
    193         sizer_output.Add(self.cu_ka_sld_im_ctl 
    194                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)   
    195         ix += 1 
    196         sizer_output.Add(cu_ka_sld_units_txt 
    197                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    198         iy += 1 
    199         ix = 0 
    200         sizer_output.Add(mo_ka_sld_txt,(iy, ix),(1,1), 
    201                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    202         ix +=1 
    203         sizer_output.Add(self.mo_ka_sld_reel_ctl,(iy, ix),(1,1), 
    204                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    205         ix +=1 
    206         sizer_output.Add(wx.StaticText(self, -1, i_complex) 
    207                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    208         ix += 1 
    209         sizer_output.Add(self.mo_ka_sld_im_ctl 
    210                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)   
    211         ix +=1 
    212         sizer_output.Add(mo_ka_sld_units_txt 
    213                          ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    214         iy += 1 
    215         ix = 0 
    216         sizer_output.Add(neutron_inc_txt,(iy, ix),(1,1), 
    217                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    218         ix += 1 
    219         sizer_output.Add(self.neutron_inc_ctl,(iy, ix),(1,1), 
     195        sizer_output.Add(neutron_sld_txt, (iy, ix), (1, 1), 
     196                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     197        ix += 1 
     198        sizer_output.Add(self.neutron_sld_reel_ctl, (iy, ix), (1, 1), 
     199                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     200        ix += 1 
     201        sizer_output.Add(wx.StaticText(self, -1, i_complex), 
     202                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     203        ix += 1 
     204        sizer_output.Add(self.neutron_sld_im_ctl, 
     205                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     206        ix += 1 
     207        sizer_output.Add(neutron_sld_units_txt, 
     208                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     209        iy += 1 
     210        ix = 0 
     211        sizer_output.Add(cu_ka_sld_txt, (iy, ix), (1, 1), 
     212                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     213        ix += 1 
     214        sizer_output.Add(self.cu_ka_sld_reel_ctl, (iy, ix), (1, 1), 
     215                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     216        ix += 1 
     217        sizer_output.Add(wx.StaticText(self, -1, i_complex), 
     218                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     219        ix += 1 
     220        sizer_output.Add(self.cu_ka_sld_im_ctl, 
     221                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)   
     222        ix += 1 
     223        sizer_output.Add(cu_ka_sld_units_txt, 
     224                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     225        iy += 1 
     226        ix = 0 
     227        sizer_output.Add(mo_ka_sld_txt,(iy, ix), (1, 1), 
     228                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     229        ix += 1 
     230        sizer_output.Add(self.mo_ka_sld_reel_ctl,(iy, ix), (1, 1), 
     231                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     232        ix += 1 
     233        sizer_output.Add(wx.StaticText(self, -1, i_complex), 
     234                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     235        ix += 1 
     236        sizer_output.Add(self.mo_ka_sld_im_ctl, 
     237                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)   
     238        ix += 1 
     239        sizer_output.Add(mo_ka_sld_units_txt, 
     240                         (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     241        iy += 1 
     242        ix = 0 
     243        sizer_output.Add(neutron_inc_txt, (iy, ix), (1, 1), 
     244                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     245        ix += 1 
     246        sizer_output.Add(self.neutron_inc_ctl, (iy, ix), (1, 1), 
    220247                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    221248        ix += 2 
    222         sizer_output.Add(neutron_inc_units_txt,(iy, ix),(1,1), 
    223                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    224         iy += 1 
    225         ix = 0 
    226         sizer_output.Add(neutron_abs_txt, (iy, ix), (1,1), 
    227                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    228         ix += 1 
    229         sizer_output.Add(self.neutron_abs_ctl, (iy, ix), (1,1), 
    230                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    231         ix +=2 
    232         sizer_output.Add(neutron_abs_units_txt, (iy, ix), (1,1), 
    233                             wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    234         iy += 1 
    235         ix = 0 
    236         sizer_output.Add(neutron_length_txt, (iy, ix), (1,1), 
    237                              wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    238         ix +=1 
    239         sizer_output.Add(self.neutron_length_ctl, (iy, ix), (1,1), 
     249        sizer_output.Add(neutron_inc_units_txt,(iy, ix), (1, 1), 
     250                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     251        iy += 1 
     252        ix = 0 
     253        sizer_output.Add(neutron_abs_txt, (iy, ix), (1, 1), 
     254                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     255        ix += 1 
     256        sizer_output.Add(self.neutron_abs_ctl, (iy, ix), (1, 1), 
     257                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     258        ix += 2 
     259        sizer_output.Add(neutron_abs_units_txt, (iy, ix), (1, 1), 
     260                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
     261        iy += 1 
     262        ix = 0 
     263        sizer_output.Add(neutron_length_txt, (iy, ix), (1, 1), 
     264                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     265        ix += 1 
     266        sizer_output.Add(self.neutron_length_ctl, (iy, ix), (1, 1), 
    240267                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    241268        ix += 2 
    242         sizer_output.Add(neutron_length_units_txt, (iy, ix), (1,1), 
     269        sizer_output.Add(neutron_length_units_txt, (iy, ix), (1, 1), 
    243270                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)   
    244         boxsizer2.Add( sizer_output ) 
    245         sizer2.Add(boxsizer2,0, wx.EXPAND|wx.ALL, 10) 
     271        boxsizer2.Add(sizer_output) 
     272        sizer2.Add(boxsizer2, 0, wx.EXPAND|wx.ALL, 10) 
    246273        #-----Button  sizer------------ 
    247274     
     
    249276        button_calculate = wx.Button(self, id, "Calculate") 
    250277        button_calculate.SetToolTipString("Calculate SLD.") 
    251         self.Bind(wx.EVT_BUTTON, self.calculateSld, id = id)    
     278        self.Bind(wx.EVT_BUTTON, self.calculateSld, id=id)    
    252279         
    253280        sizer_button.Add((250, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    254         sizer_button.Add(button_calculate, 0, wx.RIGHT|wx.ADJUST_MINSIZE,20) 
     281        sizer_button.Add(button_calculate, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20) 
    255282        sizer3.Add(sizer_button) 
    256283        #---------layout---------------- 
     
    297324            else: 
    298325                flag = False 
    299                 raise ValueError,"Error for wavelength value :expect float" 
     326                raise ValueError, "Error for wavelength value :expect float" 
    300327                 
    301328        self.compound = self.compound_ctl.GetValue().lstrip().rstrip() 
     
    335362                #get ready to compute 
    336363                try: 
    337                     self.sld_formula = formula(self.compound, density=self.density) 
     364                    self.sld_formula = formula(self.compound, 
     365                                                density=self.density) 
    338366                except: 
    339367                    if self.base is not None: 
    340                         msg = "SLD Calculator: %s" %(sys.exc_value) 
     368                        msg = "SLD Calculator: %s"  % (sys.exc_value) 
    341369                        wx.PostEvent(self.base, StatusEvent(status=msg)) 
    342370                    else: 
     
    345373                 
    346374                 
    347                 (sld_real, sld_im, sld_inc), (coh,absorp,incoh), \ 
     375                (sld_real, sld_im, _), (_, absorp, incoh), \ 
    348376                            length = neutron_scattering(self.compound, 
    349377                                       self.density, self.wavelength)  
     
    355383                                         molecule_formula=self.sld_formula) 
    356384                # set neutron sld values 
    357                 self.neutron_sld_reel_ctl.SetValue(format_number(sld_real * _SCALE)) 
    358                 self.neutron_sld_im_ctl.SetValue(format_number(math.fabs(sld_im) * _SCALE)) 
     385                val = format_number(sld_real * _SCALE) 
     386                self.neutron_sld_reel_ctl.SetValue(val) 
     387                val = format_number(math.fabs(sld_im) * _SCALE) 
     388                self.neutron_sld_im_ctl.SetValue(val) 
    359389                # Compute the Cu SLD 
    360390                self.cu_ka_sld_reel_ctl.SetValue(format_number(cu_real *_SCALE)) 
    361                 self.cu_ka_sld_im_ctl.SetValue(format_number(math.fabs(cu_im )* _SCALE)) 
     391                val = format_number(math.fabs(cu_im )* _SCALE) 
     392                self.cu_ka_sld_im_ctl.SetValue(val) 
    362393                # Compute the Mo SLD 
    363394                self.mo_ka_sld_reel_ctl.SetValue(format_number(mo_real *_SCALE)) 
    364                 self.mo_ka_sld_im_ctl.SetValue(format_number(math.fabs(mo_im)* _SCALE)) 
     395                val = format_number(math.fabs(mo_im)* _SCALE) 
     396                self.mo_ka_sld_im_ctl.SetValue(val) 
    365397                # set incoherence and absorption 
    366398                self.neutron_inc_ctl.SetValue(format_number(incoh)) 
     
    372404        except: 
    373405            if self.base is not None: 
    374                   msg = "SLD Calculator: %s"%(sys.exc_value) 
    375                   wx.PostEvent(self.base, StatusEvent(status=msg)) 
     406                msg = "SLD Calculator: %s"%(sys.exc_value) 
     407                wx.PostEvent(self.base, StatusEvent(status=msg)) 
    376408            else: 
    377409                raise 
    378410            return    
    379  
     411        if event is not None: 
     412            event.Skip() 
    380413    
    381414class SldWindow(wx.Frame): 
    382     def __init__(self, parent=None, id=1, title="SLD Calculator",base=None): 
    383         wx.Frame.__init__(self, parent, id, title, size=( PANEL_SIZE,  PANEL_SIZE)) 
    384          
     415    """ 
     416    """ 
     417    def __init__(self, parent=None, title="SLD Calculator", base=None): 
     418        """ 
     419        """ 
     420        wx.Frame.__init__(self, parent, title, 
     421                           size=(PANEL_SIZE, PANEL_SIZE)) 
     422        """ 
     423        """ 
    385424        self.panel = SldPanel(self, base=base) 
    386425        self.Centre() 
     
    388427         
    389428class ViewApp(wx.App): 
     429    """ 
     430    """ 
    390431    def OnInit(self): 
     432        """ 
     433        """ 
    391434        frame = SldWindow(None, -1, 'SLD Calculator')     
    392435        frame.Show(True) 
    393436        self.SetTopWindow(frame) 
    394          
    395437        return True 
    396438         
Note: See TracChangeset for help on using the changeset viewer.