Changeset b0ab6cb in sasview for calculatorview/perspectives


Ignore:
Timestamp:
Oct 27, 2010 4: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

Location:
calculatorview/perspectives/calculator
Files:
13 edited

Legend:

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

    r6d48919 rb0ab6cb  
    3131        self._reset_aperture = deepcopy(aperture) 
    3232        self._notes = "" 
    33         self_description = "Edit aperture" 
     33        #self_description = "Edit aperture" 
     34         
     35        #Attributes for panel 
     36        self.aperture_name_tcl = None 
     37        self.main_sizer = None 
     38        self.box_aperture = None 
     39        self.boxsizer_aperture = None 
     40        self.name_sizer = None 
     41        self.name_sizer = None 
     42        self.size_name_tcl  = None 
     43        self.type_sizer = None 
     44        self.distance_sizer = None 
     45        self.size_name_sizer = None 
     46        self.aperture_size_unit_tcl = None 
     47        self.aperture_size_sizer = None 
     48        self.button_sizer = None 
     49        self.aperture_name_tcl = None 
     50        self.type_tcl = None 
     51        self.distance_tcl = None 
     52        self.distance_unit_tcl = None 
     53        self.x_aperture_size_tcl = None 
     54        self.y_aperture_size_tcl = None 
     55        self.z_aperture_size_tcl = None 
     56        self.bt_apply = None 
     57        self.bt_cancel = None 
     58        self.bt_close = None 
     59         
    3460        self._do_layout() 
    3561        self.set_values() 
  • calculatorview/perspectives/calculator/calculator.py

    r74b1770 rb0ab6cb  
    1  
     1""" 
     2Calculator Module 
     3""" 
    24################################################################################ 
    35#This software was developed by the University of Tennessee as part of the 
     
    1012################################################################################ 
    1113 
    12 import wx 
     14#import wx 
    1315import logging 
    1416 
     
    1820    for calculator perspective 
    1921    """ 
    20      
    2122    def __init__(self, standalone=True): 
    2223        """ 
     
    2526        ## Plug-in name. It will appear on the application menu. 
    2627        self.sub_menu = "Calculator"         
    27          
     28        #standalone flag 
     29        self.standalone = standalone 
    2830        ## Reference to the parent window. Filled by get_panels() below. 
    2931        self.parent = None 
     
    7880        frame = HelpWindow(None, -1)     
    7981        frame.Show(True) 
    80        
     82        evt.Skip() 
     83         
    8184    def get_context_menu(self, graph=None): 
    8285        """ 
     
    117120        sld_help = "Provides computation related to Scattering Length Density" 
    118121        slit_length_help = "Provides computation related to Slit Length Density" 
    119         data_editor_help = "Meta Data Editor" 
     122        #data_editor_help = "Meta Data Editor" 
    120123        return [("SLD Calculator", sld_help, self.on_calculate_sld), 
    121124                ("Slit Size Calculator", slit_length_help, 
     
    130133        """ 
    131134        from data_editor import DataEditorWindow 
    132         frame = DataEditorWindow(parent=self.parent, data=[], title="Data Editor") 
     135        frame = DataEditorWindow(parent=self.parent, data=[], 
     136                                  title="Data Editor") 
    133137        frame.Show(True) 
     138        event.Skip() 
    134139 
    135140    def on_calculate_kiessig(self, event): 
     
    140145        frame = KiessigWindow() 
    141146        frame.Show(True)  
    142      
     147        event.Skip() 
    143148        
    144149    def on_calculate_sld(self, event): 
     
    149154        frame = SldWindow(base=self.parent) 
    150155        frame.Show(True)  
    151      
     156        event.Skip() 
     157         
    152158    def on_calculate_slit_size(self, event): 
    153159        """ 
     
    157163        frame = SlitLengthCalculatorWindow(parent=self.parent)     
    158164        frame.Show(True) 
     165        event.Skip() 
    159166         
    160167    def on_perspective(self, event): 
     
    168175        """ 
    169176        self.parent.set_perspective(self.perspective) 
    170         
    171      
     177        event.Skip() 
     178         
    172179    def post_init(self): 
    173180        """ 
  • calculatorview/perspectives/calculator/calculator_widgets.py

    rb7e0fff rb0ab6cb  
    99""" 
    1010import wx 
    11 import os 
     11#import os 
    1212 
    1313class InputTextCtrl(wx.TextCtrl): 
     
    2020        wx.TextCtrl.__init__(self, *args, **kwds) 
    2121         
    22         ## Set to True when the mouse is clicked while the whole string is selected 
    23         full_selection = False 
     22        ## Set to True when the mouse is clicked while the whole  
     23        #string is selected 
     24        self.full_selection = False 
    2425        ## Call back for EVT_SET_FOCUS events 
    2526        _on_set_focus_callback = None 
     
    5253                # if not, select the whole string 
    5354                (start, end) = control.GetSelection() 
    54                 if start==end: 
    55                     control.SetSelection(-1,-1) 
     55                if start == end: 
     56                    control.SetSelection(-1, -1) 
    5657 
    5758     
  • calculatorview/perspectives/calculator/collimation_editor.py

    r6137b150 rb0ab6cb  
    1  
     1""" 
     2""" 
    23import wx 
    34import sys 
     
    2829        """ 
    2930        """ 
    30         kwds['size'] =(PANEL_WIDTH, PANEL_HEIGHT) 
     31        kwds['size'] = (PANEL_WIDTH, PANEL_HEIGHT) 
    3132        kwds['title'] = "Collimation Editor" 
    3233        wx.Dialog.__init__(self, parent=parent, *args, **kwds) 
     
    3738        self._notes = "" 
    3839        self._description = "Edit collimation" 
     40        #layout attributes 
     41        self.main_sizer = None 
     42        self.box_collimation = None 
     43        self.boxsizer_collimation = None 
     44         
     45         
    3946        self._do_layout() 
    4047        self.set_values() 
     
    4552        """ 
    4653        self.main_sizer = wx.BoxSizer(wx.VERTICAL) 
    47         self.box_collimation = wx.StaticBox(self, -1,str("Edit Selected Collimation")) 
    48         self.boxsizer_collimation = wx.StaticBoxSizer(self.box_collimation, wx.VERTICAL) 
     54        self.box_collimation = wx.StaticBox(self, -1, 
     55                                            str("Edit Selected Collimation")) 
     56        self.boxsizer_collimation = wx.StaticBoxSizer(self.box_collimation, 
     57                                                       wx.VERTICAL) 
    4958         
    5059        collimation_box = wx.StaticBox(self, -1, "Edit Number of Collimations") 
     
    8089         
    8190        self.bt_remove_collimation = wx.Button(self, -1, "Remove") 
    82         self.bt_remove_collimation.SetToolTipString("Remove data's collimation.") 
     91        hint = "Remove data's collimation." 
     92        self.bt_remove_collimation.SetToolTipString(hint) 
    8393        self.bt_remove_collimation.Bind(wx.EVT_BUTTON, self.remove_collimation) 
    8494       
    85         self.collimation_button_sizer.AddMany([(collimation_name_txt, 0, wx.LEFT, 15), 
     95        self.collimation_button_sizer.AddMany([(collimation_name_txt, 0, 
     96                                                 wx.LEFT, 15), 
    8697                                     (self.collimation_cbox, 0, wx.LEFT, 5), 
    8798                                     (self.bt_add_collimation, 0, wx.LEFT, 10), 
    88                                      (self.bt_remove_collimation, 0, wx.LEFT, 5)]) 
     99                                     (self.bt_remove_collimation, 
     100                                       0, wx.LEFT, 5)]) 
    89101        collimation_hint_txt = 'No collimation is available for this data.' 
    90102        self.collimation_txt = wx.StaticText(self, -1, collimation_hint_txt)  
    91103        self.collimation_hint_sizer.Add(self.collimation_txt, 0, wx.LEFT, 10) 
    92         self.collimation_sizer.AddMany([(self.collimation_button_sizer, 0, wx.ALL, 10), 
    93                                      (self.collimation_hint_sizer, 0, wx.ALL, 10)]) 
     104        self.collimation_sizer.AddMany([(self.collimation_button_sizer, 
     105                                          0, wx.ALL, 10), 
     106                                     (self.collimation_hint_sizer, 
     107                                       0, wx.ALL, 10)]) 
    94108      
    95109        self.fill_collimation_combox() 
     
    115129        self.length_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)    
    116130        length_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    117         self.length_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0)   
     131        self.length_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
     132                                           style=0)   
    118133        self.length_sizer.AddMany([(length_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    119134                                     (self.length_tcl, 0, wx.LEFT, 12), 
     
    165180        self.aperture_txt = wx.StaticText(self, -1, aperture_hint_txt)  
    166181        self.aperture_hint_sizer.Add(self.aperture_txt, 0, wx.LEFT, 10) 
    167         self.aperture_sizer.AddMany([(self.aperture_button_sizer, 0, wx.ALL, 10), 
     182        self.aperture_sizer.AddMany([(self.aperture_button_sizer, 
     183                                       0, wx.ALL, 10), 
    168184                                     (self.aperture_hint_sizer, 0, wx.ALL, 10)]) 
    169185        self.fill_aperture_combox() 
    170186        self.enable_aperture() 
    171187     
    172     def _do_layout(self, data=None): 
     188    def _do_layout(self): 
    173189        """ 
    174190        Draw the current panel 
     
    265281    def on_select_collimation(self, event): 
    266282        """ 
    267         fill the control on the panel according to the current  selected collimation  
     283        fill the control on the panel according to  
     284        the current  selected collimation  
    268285        """ 
    269286        self.set_values() 
     
    275292        Enable /disable widgets related to collimation 
    276293        """ 
    277         if self._collimation is not None and self.collimation_cbox.GetCount() > 0: 
     294        if self._collimation is not None and \ 
     295            self.collimation_cbox.GetCount() > 0: 
    278296            self.collimation_cbox.Enable() 
    279297            self.bt_remove_collimation.Enable() 
    280298            n_collimation = self.collimation_cbox.GetCount() 
    281             collimation_hint_txt = 'collimations available: %s '%str(n_collimation) 
     299            collimation_hint_txt = "collimations" 
     300            collimation_hint_txt += " available: %s "% str(n_collimation) 
    282301            if len(self._collimation) > 0: 
    283302                self.bt_remove_collimation.Enable() 
     
    491510                    collimation.length  = float(length) 
    492511            else: 
    493                 self._notes += "Error: Expected a float for collimation length " 
    494                 self._notes += "won't changes length from " 
     512                self._notes += "Error: Expected a float for collimation length" 
     513                self._notes += " won't changes length from " 
    495514                self._notes += "%s to %s"%(collimation.length, length) 
    496515        #change length  unit 
     
    518537        self.set_values() 
    519538        if self.manager is not None: 
    520              self.manager.set_collimation(self._collimation) 
     539            self.manager.set_collimation(self._collimation) 
    521540        
    522541  
    523 if __name__ =="__main__": 
     542if __name__ == "__main__": 
    524543 
    525544    app  = wx.App() 
  • calculatorview/perspectives/calculator/console.py

    r91f151a rb0ab6cb  
    1 import wx 
    2 CONSOLE_WIDTH = 340 
    3 CONSOLE_HEIGHT = 240 
    4  
     1""" 
     2Console Module display message of a dialog 
     3""" 
    54import wx 
    65import sys 
     
    87 
    98_BOX_WIDTH = 60 
    10  
     9CONSOLE_WIDTH = 340 
     10CONSOLE_HEIGHT = 240 
    1111if sys.platform.count("win32")>0: 
    1212    _STATICBOX_WIDTH = 450 
     
    2222 
    2323class ConsoleDialog(wx.Dialog): 
    24     def __init__(self, parent=None, id=-1, manager=None, data=None, 
    25                         title="Data Summary",size=(PANEL_WIDTH, PANEL_HEIGHT)): 
    26         wx.Dialog.__init__(self, parent=parent, id=id, title=title, size=size) 
     24    def __init__(self, parent=None, manager=None, data=None, 
     25                    title="Data Summary", size=(PANEL_WIDTH, PANEL_HEIGHT)): 
     26        wx.Dialog.__init__(self, parent=parent, title=title, size=size) 
    2727    
    2828        self.parent = parent 
     
    4343    def set_manager(self, manager): 
    4444        """ 
     45        Set the manager of this window 
    4546        """ 
    4647        self._manager = manager 
     
    4849    def set_message(self, msg=""):   
    4950        """ 
     51        Display the message received  
    5052        """ 
    5153        self.msg_txt.SetValue(str(msg)) 
    5254  
    53 if __name__ =="__main__": 
     55if __name__ == "__main__": 
    5456    
    5557    app  = wx.App() 
     
    5759    loader = Loader() 
    5860    # Load data  
    59     data = loader.load("MAR07232_rest.ASC") 
    60     dlg = ConsoleDialog(data=data) 
     61    test_data = loader.load("MAR07232_rest.ASC") 
     62    dlg = ConsoleDialog(data=test_data) 
    6163    dlg.ShowModal() 
    6264    app.MainLoop() 
  • calculatorview/perspectives/calculator/data_editor.py

    rc5dca87 rb0ab6cb  
    66 
    77from DataLoader.loader import Loader 
    8 from DataLoader.data_info import DataInfo, Detector, Collimation, Data2D 
     8#from DataLoader.data_info import DataInfo 
     9#from DataLoader.data_info import  Detector 
     10#from DataLoader.data_info import Collimation 
     11from DataLoader.data_info import Data2D 
    912from detector_editor import DetectorDialog 
    1013from collimation_editor import CollimationDialog 
    1114from console import ConsoleDialog 
    1215 
    13 from sans.guiframe.utils import check_float 
     16#from sans.guiframe.utils import check_float 
    1417from sans.guicomm.events import StatusEvent 
    1518 
     
    1922_NPTS_DEFAULT = 50 
    2023#Control panel width  
    21 if sys.platform.count("darwin")==0: 
     24if sys.platform.count("darwin") == 0: 
    2225    PANEL_WIDTH = 500 
    2326    PANEL_HEIGTH = 350 
     
    4346     
    4447    if error is not None: 
    45         message += "When contacting the DANSE team, mention the following:\n%s" % str(error) 
    46      
    47     dial = wx.MessageDialog(None, message, 'Error Loading File', wx.OK | wx.ICON_EXCLAMATION) 
     48        message += "When contacting the DANSE team," 
     49        message += " mention the following:\n%s" % str(error) 
     50     
     51    dial = wx.MessageDialog(None, message,  
     52                            'Error Loading File', wx.OK | wx.ICON_EXCLAMATION) 
    4853    dial.ShowModal()  
    4954     
     
    5156class DataEditorPanel(wx.ScrolledWindow): 
    5257    """ 
    53         @param data: when not empty the class can same information into a dat object 
     58    :param data: when not empty the class can  
     59                same information into a dat object 
    5460        and post event containing the changed data object to some other frame 
    5561    """ 
    5662    def __init__(self, parent, data=[], *args, **kwds): 
    57          kwds['name'] = "Data Editor" 
    58          kwds["size"]= (PANEL_WIDTH, PANEL_HEIGTH) 
    59          wx.ScrolledWindow.__init__(self, parent, *args, **kwds) 
    60          self.parent = parent 
    61          self._data = data 
    62          self._reset_data = deepcopy(data) 
    63          self.reader = None 
    64          self._notes = "" 
    65          self_description = "Edit Data" 
    66          self._default_save_location = os.getcwd() 
    67          self._do_layout() 
    68          self.reset_panel() 
    69          self.bt_apply.Disable() 
    70          if data: 
    71              self.complete_loading(data=data) 
    72              self.bt_apply.Enable() 
     63        kwds['name'] = "Data Editor" 
     64        kwds["size"] = (PANEL_WIDTH, PANEL_HEIGTH) 
     65        wx.ScrolledWindow.__init__(self, parent, *args, **kwds) 
     66        self.parent = parent 
     67        self._data = data 
     68        self._reset_data = deepcopy(data) 
     69        self.reader = None 
     70        self._notes = "" 
     71        self._description = "Edit Data" 
     72        self._default_save_location = os.getcwd() 
     73        self._do_layout() 
     74        self.reset_panel() 
     75        self.bt_apply.Disable() 
     76        if data: 
     77            self.complete_loading(data=data) 
     78            self.bt_apply.Enable() 
    7379              
    7480    def _define_structure(self): 
    7581        """ 
    76             define initial sizer  
     82        define initial sizer  
    7783        """ 
    7884        self.main_sizer = wx.BoxSizer(wx.VERTICAL) 
     
    9197    def _layout_name(self): 
    9298        """ 
    93             Do the layout for data name related widgets 
     99        Do the layout for data name related widgets 
    94100        """ 
    95101        #data name [string] 
     
    110116    def _layout_title(self): 
    111117        """ 
    112             Do the layout for data title related widgets 
     118        Do the layout for data title related widgets 
    113119        """ 
    114120        #title name [string] 
     
    123129    def _layout_run(self): 
    124130        """ 
    125             Do the layout for data run related widgets 
     131        Do the layout for data run related widgets 
    126132        """ 
    127133        data_run_txt = wx.StaticText(self, -1, 'Run : ')  
    128134        data_run_txt.SetToolTipString('')  
    129         self.data_run_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1), style=wx.TE_MULTILINE) 
     135        self.data_run_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1), 
     136                                         style=wx.TE_MULTILINE) 
    130137        hint_run = "Data's run." 
    131138        self.data_run_tcl.SetToolTipString(hint_run) 
     
    135142    def _layout_instrument(self): 
    136143        """ 
    137             Do the layout for instrument related widgets 
     144        Do the layout for instrument related widgets 
    138145        """ 
    139146        instrument_txt = wx.StaticText(self, -1, 'Instrument : ')  
     
    148155    def _layout_editor(self): 
    149156        """ 
    150             Do the layout for sample related widgets 
     157        Do the layout for sample related widgets 
    151158        """ 
    152159        self.detector_rb = wx.RadioButton(self, -1, "Detector", 
     
    186193            Layout widgets related to data's summary 
    187194        """ 
    188         self.data_summary = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE|wx.HSCROLL, 
     195        self.data_summary = wx.TextCtrl(self, -1, 
     196                                         style=wx.TE_MULTILINE|wx.HSCROLL, 
    189197                                        size=(-1, 200)) 
    190198        summary = 'No data info available...' 
     
    196204            Do the layout for the button widgets 
    197205        """  
    198         self.bt_summary = wx.Button(self, -1, "View", size=(_BOX_WIDTH,-1)) 
     206        self.bt_summary = wx.Button(self, -1, "View", size=(_BOX_WIDTH, -1)) 
    199207        self.bt_summary.SetToolTipString("View final changes on data.") 
    200208        self.bt_summary.Bind(wx.EVT_BUTTON, self.on_click_view) 
    201209         
    202         self.bt_save = wx.Button(self, -1, "Save As", size=(_BOX_WIDTH,-1)) 
     210        self.bt_save = wx.Button(self, -1, "Save As", size=(_BOX_WIDTH, -1)) 
    203211        self.bt_save.SetToolTipString("Save changes in a file.") 
    204212        self.bt_save.Bind(wx.EVT_BUTTON, self.on_click_save) 
    205213         
    206         self.bt_apply = wx.Button(self, -1, "Apply", size=(_BOX_WIDTH,-1)) 
     214        self.bt_apply = wx.Button(self, -1, "Apply", size=(_BOX_WIDTH, -1)) 
    207215        self.bt_apply.SetToolTipString("Save changes into the imported data.") 
    208216        self.bt_apply.Bind(wx.EVT_BUTTON, self.on_click_apply) 
    209217       
    210         self.bt_reset = wx.Button(self, -1,'Reset', size=(_BOX_WIDTH,-1)) 
     218        self.bt_reset = wx.Button(self, -1, 'Reset', size=(_BOX_WIDTH, -1)) 
    211219        self.bt_reset.Bind(wx.EVT_BUTTON, self.on_click_reset) 
    212220        self.bt_reset.SetToolTipString("Reset data to its initial state.") 
    213221         
    214         self.bt_close = wx.Button(self, -1,'Close', size=(_BOX_WIDTH,-1)) 
     222        self.bt_close = wx.Button(self, -1, 'Close', size=(_BOX_WIDTH, -1)) 
    215223        self.bt_close.Bind(wx.EVT_BUTTON, self.on_close) 
    216224        self.bt_close.SetToolTipString("Close this panel.") 
     
    222230                                   (self.bt_close, 0, wx.RIGHT, 10)]) 
    223231         
    224     def _do_layout(self, data=None): 
    225         """ 
    226             Draw the current panel 
     232    def _do_layout(self): 
     233        """ 
     234        Draw the current panel 
    227235        """ 
    228236        self._define_structure() 
     
    244252                                          wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 
    245253        self.SetSizer(self.main_sizer) 
    246         self.SetScrollbars(20,20,25,65) 
     254        self.SetScrollbars(20, 20, 25, 65) 
    247255        self.SetAutoLayout(True) 
    248256         
    249257    def fill_data_combox(self): 
    250258        """ 
    251             fill the current combobox with the available data 
     259        fill the current combobox with the available data 
    252260        """ 
    253261        if not self._data: 
     
    275283        """ 
    276284        """ 
    277         data, data_name, position = self.get_current_data() 
     285        data, _, _ = self.get_current_data() 
    278286        self.reset_panel() 
    279287        if data is None: 
     
    322330    def set_sample(self, sample, notes=None): 
    323331        """ 
    324             set sample for data 
    325         """ 
    326         data, data_name, position = self.get_current_data() 
     332        set sample for data 
     333        """ 
     334        data, _, _ = self.get_current_data() 
    327335        if data is None: 
    328336            return  
     
    333341    def set_source(self, source, notes=None): 
    334342        """ 
    335             set source for data 
     343        set source for data 
    336344        """ 
    337345        data, data_name, position = self.get_current_data() 
     
    344352    def set_detector(self, detector, notes=None): 
    345353        """ 
    346             set detector for data 
     354        set detector for data 
    347355        """ 
    348356        data, data_name, position = self.get_current_data() 
     
    355363    def set_collimation(self, collimation, notes=None): 
    356364        """ 
    357             set collimation for data 
     365        set collimation for data 
    358366        """ 
    359367        data, data_name, position = self.get_current_data() 
     
    366374    def edit_collimation(self): 
    367375        """ 
    368             Edit the selected collimation 
     376        Edit the selected collimation 
    369377        """ 
    370378        data, data_name, position = self.get_current_data() 
     
    377385    def edit_detector(self): 
    378386        """ 
    379             Edit the selected detector 
     387        Edit the selected detector 
    380388        """ 
    381389        data, data_name, position = self.get_current_data() 
     
    388396    def edit_sample(self): 
    389397        """ 
    390             Open the dialog to edit the sample of the current data 
    391         """ 
    392         data, data_name, position = self.get_current_data() 
     398        Open the dialog to edit the sample of the current data 
     399        """ 
     400        data, _, _ = self.get_current_data() 
    393401        if data is None: 
    394402            return 
     
    400408    def edit_source(self): 
    401409        """ 
    402             Open the dialog to edit the saource of the current data 
     410        Open the dialog to edit the saource of the current data 
    403411        """ 
    404412        data, data_name, position = self.get_current_data() 
     
    412420    def choose_data_file(self, location=None): 
    413421        """ 
    414             Open a file dialog to allow loading a file 
     422        Open a file dialog to allow loading a file 
    415423        """ 
    416424        path = None 
     
    432440    def complete_loading(self, data=None, filename=''): 
    433441        """ 
    434             Complete the loading and compute the slit size 
     442        Complete the loading and compute the slit size 
    435443        """ 
    436444        self.done = True 
     
    438446        if data is None: 
    439447            msg = "Couldn't load data" 
    440             wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="warning",type='stop')) 
     448            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 
     449                                             info="warning",type='stop')) 
    441450            return  
    442451        if not  data.__class__.__name__ == "list": 
     
    450459            return  
    451460        msg = "Load Complete" 
    452         wx.PostEvent(self.parent.parent, StatusEvent(status=msg,info="info",type='stop')) 
     461        wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 
     462                                                info="info",type='stop')) 
    453463   
    454464    def set_values(self): 
    455465        """ 
    456             take the aperture values of the current data and display them 
    457             through the panel 
     466        take the aperture values of the current data and display them 
     467        through the panel 
    458468        """ 
    459469        if self._data: 
     
    463473    def get_data(self): 
    464474        """ 
    465             return the current data 
     475        return the current data 
    466476        """ 
    467477        return self._data 
     
    469479    def get_notes(self): 
    470480        """ 
    471             return notes 
     481        return notes 
    472482        """ 
    473483        return self._notes 
     
    475485    def on_change_run(self, event=None): 
    476486        """ 
    477             Change run 
     487        Change run 
    478488        """ 
    479489        run = [] 
    480         data, data_name, position = self.get_current_data() 
     490        data, _, _ = self.get_current_data() 
    481491        for i in range(self.data_run_tcl.GetNumberOfLines()): 
    482492            text = self.data_run_tcl.GetLineText(i).lstrip().rstrip() 
     
    485495        if data.run != run: 
    486496            self._notes += "Change data 's " 
    487             self._notes += "run from %s to %s \n"%(data.run, str(run)) 
     497            self._notes += "run from %s to %s \n" % (data.run, str(run)) 
    488498            data.run = run 
    489              
     499        if event is not None: 
     500            event.Skip() 
     501                  
    490502    def on_change_title(self, event=None): 
    491503        """ 
    492             Change title 
    493         """ 
    494         data, data_name, position = self.get_current_data() 
     504        Change title 
     505        """ 
     506        data, _, _ = self.get_current_data() 
    495507        #Change data's name 
    496508        title = self.data_title_tcl.GetValue().lstrip().rstrip() 
     
    498510        if data.title != title: 
    499511            self._notes += "Change data 's " 
    500             self._notes += "title from %s to %s \n"%(data.title, str(title)) 
     512            self._notes += "title from %s to %s \n" % (data.title, str(title)) 
    501513            data.title = title 
    502             
     514        if event is not None: 
     515            event.Skip() 
     516             
    503517    def on_click_browse(self, event): 
    504518        """ 
    505             Open a file dialog to allow the user to select a given file. 
    506             Display the loaded data if available. 
     519        Open a file dialog to allow the user to select a given file. 
     520        Display the loaded data if available. 
    507521        """ 
    508522        path = self.choose_data_file(location=self._default_save_location) 
     
    510524            return  
    511525        if self.parent.parent is not None: 
    512             wx.PostEvent(self.parent.parent, StatusEvent(status="Loading...",info="info", 
    513                                 type="progress")) 
     526            wx.PostEvent(self.parent.parent, StatusEvent(status="Loading...", 
     527                                        info="info", type="progress")) 
    514528         
    515529        self.done = False 
     
    526540            self.reader.queue() 
    527541        except: 
    528             msg = "Data Editor: %s"%(sys.exc_value) 
     542            msg = "Data Editor: %s" % (sys.exc_value) 
    529543            load_error(msg) 
    530544            return  
     545        event.Skip() 
    531546          
    532547    def on_edit(self, event): 
     
    541556        if self.collimation_rb.GetValue(): 
    542557            self.edit_collimation() 
     558        event.Skip() 
    543559             
    544560    def on_click_apply(self, event): 
    545561        """    
    546             changes are saved in data object imported to edit 
    547         """ 
    548         data, data_name, position = self.get_current_data() 
     562        changes are saved in data object imported to edit 
     563        """ 
     564        data, _, _ = self.get_current_data() 
    549565        if data is None: 
    550566            return 
     
    552568        self.on_change_title(event=None) 
    553569        #must post event here 
     570        event.Skip() 
    554571         
    555572    def on_click_save(self, event): 
    556573        """ 
    557             Save change into a file 
     574        Save change into a file 
    558575        """ 
    559576        if not self._data: 
     
    579596                    loader = Loader()  
    580597                    format = ".xml" 
    581                     if os.path.splitext(mypath)[1].lower() ==format: 
     598                    if os.path.splitext(mypath)[1].lower() == format: 
    582599                        loader.save( path, data, format) 
    583600                    try: 
     
    586603                        pass     
    587604                    dlg.Destroy() 
     605        event.Skip() 
    588606         
    589607    def on_click_view(self, event): 
    590608        """ 
    591             Display data info  
     609        Display data info  
    592610        """ 
    593611        data, data_name, position = self.get_current_data() 
     
    598616        dlg = ConsoleDialog(data=data) 
    599617        dlg.ShowModal() 
     618        event.Skip() 
    600619     
    601620    def on_click_reset(self, event): 
     
    605624        if data is None: 
    606625            return 
    607         self._data[position]= deepcopy(self._reset_data[position]) 
     626        self._data[position] = deepcopy(self._reset_data[position]) 
    608627        self.set_values() 
     628        event.Skip() 
    609629         
    610630    def on_close(self, event): 
    611631        """ 
    612             leave data as it is and close 
     632        leave data as it is and close 
    613633        """ 
    614634        self.parent.Close() 
     635        event.Skip() 
    615636         
    616637class DataEditorWindow(wx.Frame): 
    617638    def __init__(self, parent, data=None, *args, **kwds): 
    618         kwds["size"]= (PANEL_WIDTH, PANEL_HEIGTH) 
     639        kwds["size"] = (PANEL_WIDTH, PANEL_HEIGTH) 
    619640        wx.Frame.__init__(self, parent, *args, **kwds) 
    620641        self.parent = parent 
     
    628649        return self.panel.get_data() 
    629650     
    630 if __name__ =="__main__": 
     651if __name__ == "__main__": 
    631652    
    632653    app  = wx.App() 
  • calculatorview/perspectives/calculator/detector_editor.py

    rad6f597 rb0ab6cb  
    55from DataLoader.data_info import Detector 
    66from sans.guiframe.utils import check_float 
     7 
    78_BOX_WIDTH = 60 
    8  
    9 if sys.platform.count("win32")>0: 
     9if sys.platform.count("win32") > 0: 
    1010    _STATICBOX_WIDTH = 465 
    1111    PANEL_WIDTH = 500 
     
    1919     
    2020class DetectorDialog(wx.Dialog): 
    21     def __init__(self, parent=None, id=-1, manager=None, detector=None, 
    22                         title="Detector Editor",size=(PANEL_WIDTH, PANEL_HEIGHT)): 
     21    def __init__(self, parent=None, manager=None, detector=None, 
     22                        title="Detector Editor", 
     23                        size=(PANEL_WIDTH, PANEL_HEIGHT)): 
    2324        wx.Dialog.__init__(self, parent=parent, id=id, title=title, size=size) 
    2425        try: 
     
    8687        self.detector_txt = wx.StaticText(self, -1, detector_hint_txt)  
    8788        self.detector_hint_sizer.Add(self.detector_txt, 0, wx.LEFT, 10) 
    88         self.detector_sizer.AddMany([(self.detector_button_sizer, 0, wx.ALL, 10), 
     89        self.detector_sizer.AddMany([(self.detector_button_sizer, 0, 
     90                                       wx.ALL, 10), 
    8991                                     (self.detector_hint_sizer, 0, wx.ALL, 10)]) 
    9092      
     
    98100        #Instrument 
    99101        instrument_name_txt = wx.StaticText(self, -1, 'Instrument Name : ')   
    100         self.instrument_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0)  
    101         self.instrument_sizer.AddMany([(instrument_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    102                                        (self.instrument_name_tcl, 0, wx.EXPAND)]) 
     102        self.instrument_name_tcl = wx.TextCtrl(self, -1, 
     103                                             size=(_BOX_WIDTH*5, 20), style=0)  
     104        self.instrument_sizer.AddMany([(instrument_name_txt, 0,  
     105                                        wx.LEFT|wx.RIGHT, 10), 
     106                                    (self.instrument_name_tcl, 0, wx.EXPAND)]) 
    103107    def _layout_distance(self): 
    104108        """ 
     
    106110        """ 
    107111        distance_txt = wx.StaticText(self, -1, 'Sample to Detector Distance : ')   
    108         self.distance_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 
     112        self.distance_tcl = wx.TextCtrl(self, -1, 
     113                                         size=(_BOX_WIDTH, 20), style=0) 
    109114        distance_unit_txt = wx.StaticText(self, -1, 'Unit: ')   
    110         self.distance_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)   
     115        self.distance_unit_tcl = wx.TextCtrl(self, -1, 
     116                                              size=(_BOX_WIDTH, 20), style=0)   
    111117        self.distance_sizer.AddMany([(distance_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    112118                                     (self.distance_tcl, 0, wx.RIGHT, 10), 
     
    121127        offset_txt = wx.StaticText(self, -1, 'Offset:')  
    122128        x_offset_txt = wx.StaticText(self, -1, 'x = ')   
    123         self.x_offset_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)  
     129        self.x_offset_tcl = wx.TextCtrl(self, -1,  
     130                                        size=(_BOX_WIDTH, 20), style=0)  
    124131        y_offset_txt = wx.StaticText(self, -1, 'y = ')   
    125         self.y_offset_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)  
     132        self.y_offset_tcl = wx.TextCtrl(self, -1, 
     133                                         size=(_BOX_WIDTH, 20), style=0)  
    126134        z_offset_txt = wx.StaticText(self, -1, 'z = ')   
    127         self.z_offset_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)   
     135        self.z_offset_tcl = wx.TextCtrl(self, -1, 
     136                                         size=(_BOX_WIDTH, 20), style=0)   
    128137        offset_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    129         self.offset_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 
     138        self.offset_unit_tcl = wx.TextCtrl(self, -1,  
     139                                           size=(_BOX_WIDTH, 20), style=0) 
    130140        self.offset_sizer.AddMany([(offset_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    131141                                     (x_offset_txt, 0, wx.LEFT, 30), 
     
    145155        orientation_txt = wx.StaticText(self, -1, 'Orientation:')  
    146156        x_orientation_txt = wx.StaticText(self, -1, 'x = ')   
    147         self.x_orientation_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)  
     157        self.x_orientation_tcl = wx.TextCtrl(self, -1, 
     158                                              size=(_BOX_WIDTH, 20), style=0)  
    148159        y_orientation_txt = wx.StaticText(self, -1, 'y = ')   
    149         self.y_orientation_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)  
     160        self.y_orientation_tcl = wx.TextCtrl(self, -1,  
     161                                             size=(_BOX_WIDTH, 20), style=0)  
    150162        z_orientation_txt = wx.StaticText(self, -1, 'z = ')   
    151         self.z_orientation_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)   
     163        self.z_orientation_tcl = wx.TextCtrl(self, -1, 
     164                                              size=(_BOX_WIDTH, 20), style=0)   
    152165        orientation_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    153         self.orientation_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0)   
    154         self.orientation_sizer.AddMany([(orientation_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     166        self.orientation_unit_tcl = wx.TextCtrl(self, -1, 
     167                                             size=(_BOX_WIDTH, 20), style=0)   
     168        self.orientation_sizer.AddMany([(orientation_txt, 0, 
     169                                          wx.LEFT|wx.RIGHT, 10), 
    155170                                     (x_orientation_txt, 0, wx.LEFT, 7), 
    156171                                     (self.x_orientation_tcl, 0, wx.RIGHT, 10), 
     
    160175                                     (self.z_orientation_tcl, 0, wx.RIGHT, 10), 
    161176                                     (orientation_unit_txt, 0, wx.EXPAND), 
    162                                      (self.orientation_unit_tcl, 0, wx.RIGHT, 10)])  
     177                            (self.orientation_unit_tcl, 0, wx.RIGHT, 10)])  
    163178         
    164179    def _layout_beam_center(self): 
     
    169184        beam_center_txt = wx.StaticText(self, -1, 'Beam Center:')  
    170185        x_beam_center_txt = wx.StaticText(self, -1, 'x = ')   
    171         self.x_beam_center_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)  
     186        self.x_beam_center_tcl = wx.TextCtrl(self, -1, 
     187                                              size=(_BOX_WIDTH, 20), style=0)  
    172188        y_beam_center_txt = wx.StaticText(self, -1, 'y = ')   
    173         self.y_beam_center_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)  
     189        self.y_beam_center_tcl = wx.TextCtrl(self, -1, 
     190                                              size=(_BOX_WIDTH, 20), style=0)  
    174191        z_beam_center_txt = wx.StaticText(self, -1, 'z = ')   
    175         self.z_beam_center_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)   
     192        self.z_beam_center_tcl = wx.TextCtrl(self, -1, 
     193                                              size=(_BOX_WIDTH, 20), style=0)   
    176194        beam_center_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    177         self.beam_center_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 
     195        self.beam_center_unit_tcl = wx.TextCtrl(self, -1, 
     196                                                 size=(_BOX_WIDTH, 20), style=0) 
    178197        self.beam_sizer.AddMany([(beam_center_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    179198                                     (x_beam_center_txt, 0, wx.EXPAND), 
     
    184203                                     (self.z_beam_center_tcl, 0, wx.RIGHT, 10), 
    185204                                     (beam_center_unit_txt, 0, wx.EXPAND), 
    186                                      (self.beam_center_unit_tcl, 0,wx.RIGHT, 10)])    
     205                                (self.beam_center_unit_tcl, 0,wx.RIGHT, 10)])    
    187206     
    188207    def _layout_pixel_size(self): 
     
    193212        pixel_size_txt = wx.StaticText(self, -1, 'Pixel Size:')  
    194213        x_pixel_size_txt = wx.StaticText(self, -1, 'x = ')   
    195         self.x_pixel_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)  
     214        self.x_pixel_size_tcl = wx.TextCtrl(self, -1, 
     215                                             size=(_BOX_WIDTH,20), style=0)  
    196216        y_pixel_size_txt = wx.StaticText(self, -1, 'y = ')   
    197         self.y_pixel_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)  
     217        self.y_pixel_size_tcl = wx.TextCtrl(self, -1,  
     218                                            size=(_BOX_WIDTH,20), style=0)  
    198219        z_pixel_size_txt = wx.StaticText(self, -1, 'z = ')   
    199         self.z_pixel_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)   
     220        self.z_pixel_size_tcl = wx.TextCtrl(self, -1, 
     221                                             size=(_BOX_WIDTH,20), style=0)   
    200222        pixel_size_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    201         self.pixel_size_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)   
     223        self.pixel_size_unit_tcl = wx.TextCtrl(self, -1, 
     224                                             size=(_BOX_WIDTH,20), style=0)   
    202225        self.pixel_sizer.AddMany([(pixel_size_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    203226                                     (x_pixel_size_txt, 0, wx.LEFT, 17), 
     
    208231                                     (self.z_pixel_size_tcl, 0, wx.RIGHT, 10), 
    209232                                     (pixel_size_unit_txt, 0, wx.EXPAND), 
    210                                      (self.pixel_size_unit_tcl, 0, wx.RIGHT, 10)]) 
     233                                (self.pixel_size_unit_tcl, 0, wx.RIGHT, 10)]) 
    211234     
    212235    def _layout_slit_length(self): 
     
    216239        #slit length 
    217240        slit_length_txt = wx.StaticText(self, -1, 'Slit Length: ')   
    218         self.slit_length_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0) 
     241        self.slit_length_tcl = wx.TextCtrl(self, -1, 
     242                                            size=(_BOX_WIDTH,20), style=0) 
    219243        slit_length_unit_txt = wx.StaticText(self, -1, 'Unit: ')   
    220         self.slit_length_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)    
     244        self.slit_length_unit_tcl = wx.TextCtrl(self, -1, 
     245                                                 size=(_BOX_WIDTH,20), style=0)    
    221246        self.slit_sizer.AddMany([(slit_length_txt, 0, wx.LEFT, 10), 
    222247                                     (self.slit_length_tcl, 0, wx.RIGHT, 10), 
    223248                                     (slit_length_unit_txt, 0, wx.EXPAND), 
    224                                      (self.slit_length_unit_tcl, 0,wx.RIGHT, 10)]) 
     249                            (self.slit_length_unit_tcl, 0,wx.RIGHT, 10)]) 
    225250         
    226251    def _layout_button(self):   
     
    413438        self.offset_unit_tcl.SetValue(str(detector.offset_unit)) 
    414439        #Orientation 
    415         x, y, z = detector.orientation.x, detector.orientation.y, detector.orientation.z 
     440        x, y = detector.orientation.x, detector.orientation.y 
     441        z = detector.orientation.z 
    416442        self.x_orientation_tcl.SetValue(str(x))   
    417443        self.y_orientation_tcl.SetValue(str(y))  
     
    419445        self.orientation_unit_tcl.SetValue(str(detector.orientation_unit)) 
    420446        #Beam center 
    421         x, y, z = detector.beam_center.x, detector.beam_center.y, detector.beam_center.z 
     447        x, y = detector.beam_center.x, detector.beam_center.y 
     448        z  =   detector.beam_center.z 
    422449        self.x_beam_center_tcl.SetValue(str(x))   
    423450        self.y_beam_center_tcl.SetValue(str(y))  
     
    425452        self.beam_center_unit_tcl.SetValue(str(detector.beam_center_unit)) 
    426453        #Pixel size  
    427         x, y, z = detector.pixel_size.x, detector.pixel_size.y, detector.pixel_size.z 
     454        x, y = detector.pixel_size.x, detector.pixel_size.y 
     455        z = detector.pixel_size.z 
    428456        self.x_pixel_size_tcl.SetValue(str(x))   
    429457        self.y_pixel_size_tcl.SetValue(str(y))  
     
    485513                    detector.distance = float(distance) 
    486514            else: 
    487                 self._notes += "Error: Expected a float for the distance won't changes " 
     515                self._notes += "Error: Expected a float for " 
     516                self._notes += " the distance won't changes " 
    488517                self._notes += "%s to %s"%(detector.distance, distance) 
    489518        #change the distance unit 
     
    513542                if detector.offset.x != float(x_offset): 
    514543                    self._notes += "Change x of offset from" 
    515                     self._notes += " %s to %s \n"%(detector.offset.x, x_offset) 
     544                    self._notes += " %s to %s \n" % (detector.offset.x, 
     545                                                      x_offset) 
    516546                    detector.offset.x = float(x_offset) 
    517547            else: 
    518548                self._notes += "Error: Expected a float for the offset 's x " 
    519549                self._notes += "won't changes x offset" 
    520                 self._notes += " from %s to %s"%(detector.offset.x, x_offset) 
     550                self._notes += " from %s to %s" % (detector.offset.x, x_offset) 
    521551        #Change y coordinate 
    522552        y_offset = self.y_offset_tcl.GetValue().lstrip().rstrip() 
     
    533563                self._notes += "Error: Expected a float for the offset 's y " 
    534564                self._notes += "won't changes y " 
    535                 self._notes += "offset from %s to %s"%(detector.offset.y\ 
    536                                                          ,y_offset) 
     565                self._notes += "offset from %s to %s"%(detector.offset.y, 
     566                                                         y_offset) 
    537567        #Change z coordinate 
    538568        z_offset = self.z_offset_tcl.GetValue().lstrip().rstrip() 
     
    543573            if check_float(self.z_offset_tcl): 
    544574                if detector.offset.z != float(z_offset): 
    545                     self._notes += "Change z of" 
    546                     self._notes += "offset from %s to %s \n"%(detector.offset.z,\ 
     575                    self._notes += "Change z of offset from" 
     576                    self._notes += " %s to %s \n" % (detector.offset.z, 
    547577                                                              z_offset) 
    548578                    detector.offset.z  = float(z_offset) 
     
    550580                self._notes += "Error: Expected a float for the offset 's x " 
    551581                self._notes += "won't changes z" 
    552                 self._notes += "offset from %s to %s"%(detector.offset.z, z_offset) 
     582                self._notes += "offset from %s to %s" % (detector.offset.z,  
     583                                                       z_offset) 
    553584        #change the offset unit 
    554585        unit = self.offset_unit_tcl.GetValue().lstrip().rstrip() 
    555586        if detector.offset_unit != unit: 
    556587            self._notes += " Change Offset's" 
    557             self._notes += "unit from %s to %s"%(detector.offset_unit, unit) 
     588            self._notes += "unit from %s to %s" % (detector.offset_unit, unit) 
    558589             
    559590        self.detector_cbox.SetString(position, str(detector.name))  
     
    577608                if detector.orientation.x != float(x_orientation): 
    578609                    self._notes += "Change x of orientation from " 
    579                     self._notes += "%s to %s \n"%(detector.orientation.x, x_orientation) 
     610                    self._notes += "%s to %s \n" % (detector.orientation.x, 
     611                                                   x_orientation) 
    580612                    detector.orientation.x  = float(x_orientation) 
    581613            else: 
    582                 self._notes += "Error: Expected a float for the orientation 's x " 
    583                 self._notes += "won't changes x orientation from " 
    584                 self._notes += "%s to %s"%(detector.orientation.x, x_orientation) 
     614                self._notes += "Error: Expected a float for the orientation " 
     615                self._notes += "'s x  won't changes x orientation from " 
     616                self._notes += "%s to %s" % (detector.orientation.x, 
     617                                              x_orientation) 
    585618        #Change y coordinate 
    586619        y_orientation = self.y_orientation_tcl.GetValue().lstrip().rstrip() 
     
    592625                if detector.orientation.y != float(y_orientation): 
    593626                    self._notes += "Change y of orientation from " 
    594                     self._notes += "%s to %s \n"%(detector.orientation.y, y_orientation) 
     627                    self._notes += "%s to %s \n" % (detector.orientation.y, 
     628                                                     y_orientation) 
    595629                    detector.orientation.y  = float(y_orientation) 
    596630            else: 
    597                 self._notes += "Error: Expected a float for the orientation's y " 
    598                 self._notes += "won't changes y orientation from " 
    599                 self._notes += "%s to %s"%(detector.orientation.y, y_orientation) 
     631                self._notes += "Error: Expected a float for the orientation's " 
     632                self._notes += " y won't changes y orientation from " 
     633                self._notes += "%s to %s" % (detector.orientation.y, 
     634                                            y_orientation) 
    600635        #Change z coordinate 
    601636        z_orientation = self.z_orientation_tcl.GetValue().lstrip().rstrip() 
     
    607642                if detector.orientation.z != float(z_orientation): 
    608643                    self._notes += "Change z of offset from " 
    609                     self._notes += "%s to %s \n"%(detector.orientation.z, z_orientation) 
     644                    self._notes += "%s to %s \n"%(detector.orientation.z, 
     645                                                   z_orientation) 
    610646                    detector.orientation.z  = float(z_orientation) 
    611647            else: 
    612                 self._notes += "Error: Expected a float for the orientation 's x " 
    613                 self._notes += "won't changes z orientation from " 
    614                 self._notes += "%s to %s"%(detector.orientation.z, z_orientation) 
     648                self._notes += "Error: Expected a float for the orientation 's" 
     649                self._notes += " x won't changes z orientation from " 
     650                self._notes += "%s to %s" % (detector.orientation.z, 
     651                                              z_orientation) 
    615652        #change the orientation unit 
    616653        unit = self.orientation_unit_tcl.GetValue().lstrip().rstrip() 
     
    640677                if detector.beam_center.x != float(x_beam_center): 
    641678                    self._notes += "Change x of offset from " 
    642                     self._notes += "%s to %s \n"%(detector.beam_center.x, x_beam_center) 
     679                    self._notes += "%s to %s \n" % (detector.beam_center.x, 
     680                                                     x_beam_center) 
    643681                    detector.beam_center.x  = float(x_beam_center) 
    644682            else: 
    645                 self._notes += "Error: Expected a float for the beam center 's x " 
    646                 self._notes += "won't changes x beam center from " 
    647                 self._notes += "%s to %s"%(detector.beam_center.x, x_beam_center) 
     683                self._notes += "Error: Expected a float for the beam " 
     684                self._notes += "center 's x won't changes x beam center from " 
     685                self._notes += "%s to %s" % (detector.beam_center.x, 
     686                                            x_beam_center) 
    648687        #Change y coordinate 
    649688        y_beam_center = self.y_beam_center_tcl.GetValue().lstrip().rstrip() 
     
    655694                if detector.beam_center.y != float(y_beam_center): 
    656695                    self._notes += "Change y of beam center from " 
    657                     self._notes += "%s to %s \n"%(detector.beam_center.y, y_beam_center) 
     696                    self._notes += "%s to %s \n" % (detector.beam_center.y, 
     697                                                     y_beam_center) 
    658698                    detector.beam_center.y  = float(y_beam_center) 
    659699            else: 
    660                 self._notes += "Error: Expected a float for the beam center 's y " 
    661                 self._notes += "won't changes y beam center from " 
    662                 self._notes += "%s to %s"%(detector.beam_center.y, y_beam_center) 
     700                self._notes += "Error: Expected a float for the beam " 
     701                self._notes += "center 's y won't changes y beam center from " 
     702                self._notes += "%s to %s" % (detector.beam_center.y, 
     703                                              y_beam_center) 
    663704        #Change z coordinate 
    664705        z_beam_center = self.z_beam_center_tcl.GetValue().lstrip().rstrip() 
     
    670711                if detector.beam_center.z != float(z_beam_center): 
    671712                    self._notes += "Change z of beam center from " 
    672                     self._notes += "%s to %s \n"%(detector.beam_center.z, z_beam_center) 
     713                    self._notes += "%s to %s \n" % (detector.beam_center.z, 
     714                                                     z_beam_center) 
    673715                    detector.beam_center.z  = float(z_beam_center) 
    674716            else: 
    675717                self._notes += "Error: Expected a float for the offset 's x " 
    676718                self._notes += "won't changes z beam center from " 
    677                 self._notes += "%s to %s"%(detector.beam_center.z, z_beam_center) 
     719                self._notes += "%s to %s"%(detector.beam_center.z, 
     720                                            z_beam_center) 
    678721        #change the beam center unit 
    679722        unit = self.beam_center_unit_tcl.GetValue().lstrip().rstrip() 
     
    701744                if detector.pixel_size.x != float(x_pixel_size) : 
    702745                    self._notes += "Change x of pixel size from " 
    703                     self._notes += "%s to %s \n"%(detector.pixel_size.x, x_pixel_size) 
     746                    self._notes += "%s to %s \n"%(detector.pixel_size.x, 
     747                                                   x_pixel_size) 
    704748                    detector.pixel_size.x  = float(x_pixel_size) 
    705749            else: 
    706                 self._notes += "Error: Expected a float for the pixel size 's x " 
    707                 self._notes += "won't changes x pixel size from " 
    708                 self._notes += "%s to %s"%(detector.pixel_size.x, x_pixel_size) 
     750                self._notes += "Error: Expected a float for the pixel" 
     751                self._notes += " size 's x  won't changes x pixel size from " 
     752                self._notes += "%s to %s" % (detector.pixel_size.x,  
     753                                             x_pixel_size) 
    709754        #Change y coordinate 
    710755        y_pixel_size = self.y_pixel_size_tcl.GetValue().lstrip().rstrip() 
     
    716761                if detector.pixel_size.y != float(y_pixel_size): 
    717762                    self._notes += "Change y of pixel size from " 
    718                     self._notes += "%s to %s \n"%(detector.pixel_size.y, y_pixel_size) 
     763                    self._notes += "%s to %s \n"%(detector.pixel_size.y, 
     764                                                   y_pixel_size) 
    719765                    detector.pixel_size.y  = float(y_pixel_size) 
    720766            else: 
    721                 self._notes += "Error: Expected a float for the pixel size's y " 
    722                 self._notes += "won't changes y pixel size from " 
    723                 self._notes += "%s to %s"%(detector.pixel_size.y, y_pixel_size) 
     767                self._notes += "Error: Expected a float for the pixel " 
     768                self._notes += "size's y  won't changes y pixel size from " 
     769                self._notes += "%s to %s" % (detector.pixel_size.y, 
     770                                              y_pixel_size) 
    724771        #Change z coordinate 
    725772        z_pixel_size = self.z_pixel_size_tcl.GetValue().lstrip().rstrip() 
     
    731778                if detector.pixel_size.z != float(z_pixel_size): 
    732779                    self._notes += "Change z of pixel size from " 
    733                     self._notes += "%s to %s \n"%(detector.pixel_size.z, z_pixel_size) 
     780                    self._notes += "%s to %s \n"%(detector.pixel_size.z, 
     781                                                   z_pixel_size) 
    734782                    detector.pixel_size.z  = float(z_pixel_size) 
    735783            else: 
     
    763811                if detector.slit_length != float(slit_length): 
    764812                    self._notes += " Change slit length from" 
    765                     self._notes += " %s to %s \n"%(detector.slit_length, slit_length) 
     813                    self._notes += " %s to %s \n"%(detector.slit_length, 
     814                                                    slit_length) 
    766815                    detector.slit_length = float(slit_length) 
    767816            else: 
    768                 self._notes += "Error: Expected a float for the slit length won't changes " 
    769                 self._notes += "%s to %s"%(detector.slit_length, slit_length) 
     817                self._notes += "Error: Expected a float" 
     818                self._notes += " for the slit length won't changes " 
     819                self._notes += "%s to %s" % (detector.slit_length, slit_length) 
    770820        #change the distance unit 
    771821        unit = self.slit_length_unit_tcl.GetValue().lstrip().rstrip() 
     
    804854if __name__ == "__main__": 
    805855    app = wx.App() 
    806     detector = Detector() 
    807     dlg = DetectorDialog(detector=[detector]) 
     856    test_detector = Detector() 
     857    dlg = DetectorDialog(detector=[test_detector]) 
    808858    dlg.ShowModal() 
    809859    app.MainLoop() 
  • calculatorview/perspectives/calculator/help_panel.py

    r74b1770 rb0ab6cb  
    11#!/usr/bin/python 
     2""" 
     3Help panel for calculator 
     4""" 
     5import os 
    26import wx 
    37import wx.html as html 
    48from wx.lib.splitter import MultiSplitterWindow 
    59import sans.perspectives.calculator as calculator 
    6 import os 
    7 def help(): 
    8     """ 
    9         Provide general online help text 
    10         Future work: extend this function to allow topic selection 
    11     """ 
    12     info_txt  = "The inversion approach is based on Moore, J. Appl. Cryst. (1980) 13, 168-175.\n\n" 
    13     info_txt += "P(r) is set to be equal to an expansion of base functions of the type " 
    14     info_txt += "phi_n(r) = 2*r*sin(pi*n*r/D_max). The coefficient of each base functions " 
    15     info_txt += "in the expansion is found by performing a least square fit with the " 
    16     info_txt += "following fit function:\n\n" 
    17     info_txt += "chi**2 = sum_i[ I_meas(q_i) - I_th(q_i) ]**2/error**2 + Reg_term\n\n" 
    18     info_txt += "where I_meas(q) is the measured scattering intensity and I_th(q) is " 
    19     info_txt += "the prediction from the Fourier transform of the P(r) expansion. " 
    20     info_txt += "The Reg_term term is a regularization term set to the second derivative " 
    21     info_txt += "d**2P(r)/dr**2 integrated over r. It is used to produce a smooth P(r) output.\n\n" 
    22     info_txt += "The following are user inputs:\n\n" 
    23     info_txt += "   - Number of terms: the number of base functions in the P(r) expansion.\n\n" 
    24     info_txt += "   - Regularization constant: a multiplicative constant to set the size of " 
    25     info_txt += "the regularization term.\n\n" 
    26     info_txt += "   - Maximum distance: the maximum distance between any two points in the system.\n" 
    27       
    28     return info_txt 
    29      
    30 class HelpDialog(wx.Dialog): 
    31     def __init__(self, parent, id): 
    32        
    33         wx.Dialog.__init__(self, parent, id, size=(400, 420)) 
    34         self.SetTitle("Calculator help")  
    35          
    36  
    37         vbox = wx.BoxSizer(wx.VERTICAL) 
    38  
    39         explanation = help() 
    40             
    41         label_explain = wx.StaticText(self, -1, explanation, size=(350,320)) 
    42              
    43         vbox.Add(label_explain, 0, wx.ALL|wx.EXPAND, 15) 
    4410 
    4511 
    46         static_line = wx.StaticLine(self, -1) 
    47         vbox.Add(static_line, 0, wx.EXPAND, 0) 
    48          
    49         button_OK = wx.Button(self, wx.ID_OK, "OK") 
    50  
    51         sizer_button = wx.BoxSizer(wx.HORIZONTAL) 
    52         sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    53         sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)        
    54         vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 
    55  
    56         self.SetSizer(vbox) 
    57         self.SetAutoLayout(True) 
    58          
    59         self.Layout() 
    60         self.Centre() 
    61  
    6212class HelpWindow(wx.Frame): 
    63     def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None): 
    64         wx.Frame.__init__(self, parent, id, title, size=(700, 450)) 
     13    """ 
     14    """ 
     15    def __init__(self, parent, title='HelpWindow', pageToOpen=None): 
     16        wx.Frame.__init__(self, parent, title, size=(700, 450)) 
    6517        """ 
    6618             contains help info 
    6719        """ 
    68        
    6920        splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) 
    7021        rpanel = wx.Panel(splitter, -1) 
    71         lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN) 
     22        lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) 
    7223         
    7324        vbox = wx.BoxSizer(wx.VERTICAL) 
     
    8435        vbox.Add(header, 0, wx.EXPAND) 
    8536        
    86         vboxl= wx.BoxSizer(wx.VERTICAL) 
     37        vboxl = wx.BoxSizer(wx.VERTICAL) 
    8738        headerl = wx.Panel(lpanel, -1, size=(-1, 20)) 
    8839        
     
    10354        self.path = calculator.get_data_path(media='media') 
    10455        
    105         
    106         page1="""<html> 
     56        page1 = """<html> 
    10757            <body> 
    10858             <p>Select topic on Menu</p> 
     
    11060            </html>""" 
    11161        self.rhelp.SetPage(page1) 
    112         page="""<html> 
     62        page = """<html> 
    11363            <body> 
    11464            <ul> 
    115             <li><a href ="sld_calculator_help.html" target ="showframe">SLD Calculator</a><br></li> 
    116             <li><a href ="slit_calculator_help.html" target ="showframe">Slit Size Calculator</a><br></li> 
    117             <li><a href ="kiessig_calculator_help.html" target ="showframe">Kiessig Thickness Calculator</a><br></li> 
     65            <li><a href ="sld_calculator_help.html"  
     66            target ="showframe">SLD Calculator</a><br></li> 
     67            <li><a href ="slit_calculator_help.html"  
     68            target ="showframe">Slit Size Calculator</a><br></li> 
     69            <li><a href ="kiessig_calculator_help.html"  
     70            target ="showframe">Kiessig Thickness Calculator</a><br></li> 
    11871            </ul> 
    11972            </body> 
     
    12174 
    12275        self.lhelp.SetPage(page) 
    123         self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked ) 
     76        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) 
    12477         
    125         vbox.Add(self.rhelp,1, wx.EXPAND) 
     78        vbox.Add(self.rhelp, 1, wx.EXPAND) 
    12679        vboxl.Add(self.lhelp, 1, wx.EXPAND) 
    12780        rpanel.SetSizer(vbox) 
     
    13083         
    13184        vbox1 = wx.BoxSizer(wx.HORIZONTAL) 
    132         vbox1.Add(splitter,1,wx.EXPAND) 
     85        vbox1.Add(splitter, 1, wx.EXPAND) 
    13386        splitter.AppendWindow(lpanel, 200) 
    13487        splitter.AppendWindow(rpanel) 
     
    13891        self.Show(True) 
    13992         
    140          
    14193    def OnLinkClicked(self, event): 
    14294        """ 
    14395            Function to diplay html page related to the hyperlinktext selected 
    14496        """ 
    145         
    146         link= event.GetLinkInfo().GetHref() 
    147         link = os.path.join(self.path,link) 
     97        link = event.GetLinkInfo().GetHref() 
     98        link = os.path.join(self.path, link) 
    14899        self.rhelp.LoadPage(link) 
     100         
    149101         
    150102class ViewApp(wx.App): 
     
    153105        frame.Show(True) 
    154106        self.SetTopWindow(frame) 
    155          
    156107        return True 
    157108         
    158  
    159109if __name__ == "__main__":  
    160110    app = ViewApp(0) 
  • calculatorview/perspectives/calculator/kiessig_calculator_panel.py

    r74b1770 rb0ab6cb  
    1111import wx 
    1212import sys 
    13 import os 
     13#import os 
    1414 
    15 from sans.guicomm.events import StatusEvent   
     15#from sans.guicomm.events import StatusEvent   
    1616from sans.calculator.kiessig_calculator import KiessigThicknessCalculator  
    17 from calculator_widgets import OutputTextCtrl, InputTextCtrl 
     17from calculator_widgets import OutputTextCtrl 
     18from calculator_widgets import InputTextCtrl 
    1819 
    1920_BOX_WIDTH = 77 
     
    3940    CENTER_PANE = True 
    4041     
    41     def __init__(self, parent, id=-1, *args, **kwds): 
    42         wx.Panel.__init__(self, parent, id=id, *args, **kwds) 
     42    def __init__(self, parent, *args, **kwds): 
     43        wx.Panel.__init__(self, parent, *args, **kwds) 
    4344        #Font size  
    4445        self.SetWindowVariant(variant=FONT_VARIANT)   
     
    4647        self.parent = parent 
    4748        self.kiessig = KiessigThicknessCalculator() 
     49        #layout attribute 
     50        self.hint_sizer = None 
    4851        self._do_layout() 
    4952        
     
    9194        """ 
    9295        thick_unit = '['+self.kiessig.get_thickness_unit() +']' 
    93         thickness_size_txt = wx.StaticText(self, -1, 'Thickness (or Diameter): ') 
     96        thickness_size_txt = wx.StaticText(self, -1,  
     97                                           'Thickness (or Diameter): ') 
    9498        self.thickness_size_tcl = OutputTextCtrl(self, -1,  
    9599                                                 size=(_BOX_WIDTH,-1)) 
     
    106110        Fill the sizer containing hint  
    107111        """ 
    108         hint_msg = "This tool is to approximately estimate the thickness of a layer" 
     112        hint_msg = "This tool is to approximately estimate " 
     113        hint_msg += "the thickness of a layer" 
    109114        hint_msg += " or the diameter of particles\n " 
    110115        hint_msg += "from the Kiessig fringe width in SANS/NR data." 
     
    148153        """ 
    149154        self.parent.Close() 
     155        if event is not None: 
     156            event.Skip() 
    150157         
    151158    def on_compute(self, event): 
     
    164171        self.thickness_size_tcl.SetValue(str(thickness)) 
    165172         
    166     def format_number(self,value=None): 
     173    def format_number(self, value=None): 
    167174        """ 
    168175        Return a float in a standardized, human-readable formatted string  
     
    174181            return output 
    175182 
    176         output= "%-7.4g" % value 
     183        output = "%-7.4g" % value 
    177184        return output.lstrip().rstrip()    
    178185      
    179186class KiessigWindow(wx.Frame): 
    180     def __init__(self, parent=None, id=1, title="Kiessig Thickness Calculator"): 
    181         wx.Frame.__init__(self, parent, id, title, size=(PANEL_WIDTH,PANEL_HEIGHT)) 
     187    def __init__(self, parent=None, title="Kiessig Thickness Calculator"): 
     188        wx.Frame.__init__(self, parent, title, 
     189                           size=(PANEL_WIDTH,PANEL_HEIGHT)) 
    182190        self.parent = parent 
    183191        self.panel = KiessigThicknessCalculatorPanel(parent=self) 
  • calculatorview/perspectives/calculator/sample_editor.py

    rad6f597 rb0ab6cb  
    66 
    77_BOX_WIDTH = 60 
    8 if sys.platform.count("win32")>0: 
     8if sys.platform.count("win32") > 0: 
    99    _STATICBOX_WIDTH = 450 
    1010    PANEL_WIDTH = 500 
     
    5555        ## Short name for sample [string] 
    5656        sample_name_txt = wx.StaticText(self, -1, 'Sample Name : ')   
    57         self.sample_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0)  
     57        self.sample_name_tcl = wx.TextCtrl(self, -1, 
     58                                            size=(_BOX_WIDTH*5, 20), style=0)  
    5859        self.name_sizer.AddMany([(sample_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    5960                                       (self.sample_name_tcl, 0, wx.EXPAND)]) 
     
    7475        ## Thickness [float] [mm] 
    7576        thickness_txt = wx.StaticText(self, -1, 'Thickness:')  
    76         self.thickness_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0)   
     77        self.thickness_tcl = wx.TextCtrl(self, -1, 
     78                                          size=(_BOX_WIDTH, 20),style=0)   
    7779        thickness_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    7880        self.thickness_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
     
    8082        self.thickness_sizer.AddMany([(thickness_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    8183                                     (self.thickness_tcl, 0, wx.LEFT, 25), 
    82                                      (thickness_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     84                            (thickness_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    8385                                     (self.thickness_unit_tcl, 0, wx.EXPAND)])  
    8486    def _layout_transmission(self): 
     
    8991        transmission = None 
    9092        transmission_txt = wx.StaticText(self, -1, 'Transmission:')  
    91         self.transmission_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0)    
    92         self.transmission_sizer.AddMany([(transmission_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     93        self.transmission_tcl = wx.TextCtrl(self, -1, 
     94                                             size=(_BOX_WIDTH, 20),style=0)    
     95        self.transmission_sizer.AddMany([(transmission_txt, 
     96                                         0, wx.LEFT|wx.RIGHT, 10), 
    9397                                     (self.transmission_tcl, 0, wx.LEFT, 12)])  
    9498         
     
    99103        ## Temperature [float] [C] 
    100104        temperature_txt = wx.StaticText(self, -1, 'Temperature:')  
    101         self.temperature_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)    
     105        self.temperature_tcl = wx.TextCtrl(self, -1,  
     106                                           size=(_BOX_WIDTH, 20), style=0)    
    102107        temperature_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    103108        self.temperature_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    104109                                                            style=0)   
    105         self.temperature_sizer.AddMany([(temperature_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     110        self.temperature_sizer.AddMany([(temperature_txt, 0, 
     111                                          wx.LEFT|wx.RIGHT, 10), 
    106112                                     (self.temperature_tcl, 0, wx.LEFT, 10), 
    107                                      (temperature_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     113                                (temperature_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    108114                                     (self.temperature_unit_tcl, 0, wx.EXPAND)])   
    109115     
     
    115121        position_txt = wx.StaticText(self, -1, 'Position:')  
    116122        x_position_txt = wx.StaticText(self, -1, 'x = ')   
    117         self.x_position_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)  
     123        self.x_position_tcl = wx.TextCtrl(self, -1, 
     124                                           size=(_BOX_WIDTH,20), style=0)  
    118125        y_position_txt = wx.StaticText(self, -1, 'y = ')   
    119         self.y_position_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)  
     126        self.y_position_tcl = wx.TextCtrl(self, -1, 
     127                                           size=(_BOX_WIDTH,20), style=0)  
    120128        z_position_txt = wx.StaticText(self, -1, 'z = ')   
    121         self.z_position_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)   
     129        self.z_position_tcl = wx.TextCtrl(self, -1, 
     130                                           size=(_BOX_WIDTH,20), style=0)   
    122131        position_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    123         self.position_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)   
     132        self.position_unit_tcl = wx.TextCtrl(self, -1,  
     133                                             size=(_BOX_WIDTH,20), style=0)   
    124134        self.position_sizer.AddMany([(position_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    125135                                     (x_position_txt, 0, wx.LEFT, 14), 
     
    138148        orientation_txt = wx.StaticText(self, -1, 'Orientation:')  
    139149        x_orientation_txt = wx.StaticText(self, -1, 'x = ')   
    140         self.x_orientation_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)  
     150        self.x_orientation_tcl = wx.TextCtrl(self, -1, 
     151                                              size=(_BOX_WIDTH,20), style=0)  
    141152        y_orientation_txt = wx.StaticText(self, -1, 'y = ')   
    142         self.y_orientation_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)  
     153        self.y_orientation_tcl = wx.TextCtrl(self, -1, 
     154                                              size=(_BOX_WIDTH,20), style=0)  
    143155        z_orientation_txt = wx.StaticText(self, -1, 'z = ')   
    144         self.z_orientation_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)   
     156        self.z_orientation_tcl = wx.TextCtrl(self, -1, 
     157                                              size=(_BOX_WIDTH,20), style=0)   
    145158        orientation_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    146         self.orientation_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)   
    147         self.orientation_sizer.AddMany([(orientation_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     159        self.orientation_unit_tcl = wx.TextCtrl(self, -1, 
     160                                                 size=(_BOX_WIDTH,20), style=0)   
     161        self.orientation_sizer.AddMany([(orientation_txt, 0, 
     162                                          wx.LEFT|wx.RIGHT, 10), 
    148163                                     (x_orientation_txt, 0, wx.LEFT, 0), 
    149164                                     (self.x_orientation_tcl, 0, wx.RIGHT, 10), 
     
    153168                                     (self.z_orientation_tcl, 0, wx.RIGHT, 10), 
    154169                                     (orientation_unit_txt, 0, wx.EXPAND), 
    155                                      (self.orientation_unit_tcl, 0, wx.RIGHT, 10)]) 
     170                            (self.orientation_unit_tcl, 0, wx.RIGHT, 10)]) 
    156171         
    157172    def _layout_details(self): 
     
    275290        self.position_unit_tcl.SetValue(str(sample.position_unit)) 
    276291        #orientation 
    277         x, y, z = sample.orientation.x, sample.orientation.y , sample.orientation.z 
     292        x, y = sample.orientation.x, sample.orientation.y  
     293        z = sample.orientation.z 
    278294        self.x_orientation_tcl.SetValue(str(x))   
    279295        self.y_orientation_tcl.SetValue(str(y))  
     
    347363        if self._sample.transmission != transmission: 
    348364            self._notes += " Change transmission from" 
    349             self._notes += " %s to %s \n"%(self._sample.transmission, transmission) 
     365            self._notes += " %s to %s \n" % (self._sample.transmission, 
     366                                              transmission) 
    350367            self._sample.transmission = transmission 
    351368             
     
    378395                if self._sample.position.x != float(x_position) : 
    379396                    self._notes += "Change x of position from " 
    380                     self._notes += "%s to %s \n"%(self._sample.position.x, x_position) 
     397                    self._notes += "%s to %s \n" % (self._sample.position.x, 
     398                                                     x_position) 
    381399                    self._sample.position.x  = float(x_position) 
    382400            else: 
     
    393411                if self._sample.position.y != float(y_position): 
    394412                    self._notes += "Change y of position from " 
    395                     self._notes += "%s to %s \n"%(self._sample.position.y, y_position) 
     413                    self._notes += "%s to %s \n" % (self._sample.position.y,  
     414                                                    y_position) 
    396415                    self._sample.position.y  = float(y_position) 
    397416            else: 
     
    408427                if self._sample.position.z != float(z_position): 
    409428                    self._notes += "Change z of position from " 
    410                     self._notes += "%s to %s \n"%(self._sample.position.z, z_position) 
     429                    self._notes += "%s to %s \n" % (self._sample.position.z, 
     430                                                    z_position) 
    411431                    self._sample.position.z  = float(z_position) 
    412432            else: 
     
    438458                self._notes += "Error: Expected a float for orientation 's x " 
    439459                self._notes += "won't changes x orientation from " 
    440                 self._notes += "%s to %s"%(self._sample.orientation.x, x_orientation) 
     460                self._notes += "%s to %s" % (self._sample.orientation.x, 
     461                                              x_orientation) 
    441462        #Change y coordinate 
    442463        y_orientation = self.y_orientation_tcl.GetValue().lstrip().rstrip() 
     
    448469                if self._sample.orientation.y != float(y_orientation): 
    449470                    self._notes += "Change y of orientation from " 
    450                     self._notes += "%s to %s \n"%(self._sample.orientation.y, y_orientation) 
     471                    self._notes += "%s to %s \n" % (self._sample.orientation.y, 
     472                                                     y_orientation) 
    451473                    self._sample.orientation.y  = float(y_orientation) 
    452474            else: 
    453475                self._notes += "Error: Expected a float for orientation's y " 
    454476                self._notes += "won't changes y orientation from " 
    455                 self._notes += "%s to %s"%(self._sample.orientation.y, y_orientation) 
     477                self._notes += "%s to %s" % (self._sample.orientation.y, 
     478                                            y_orientation) 
    456479        #Change z coordinate 
    457480        z_orientation = self.z_orientation_tcl.GetValue().lstrip().rstrip() 
     
    463486                if self._sample.orientation.z != float(z_orientation): 
    464487                    self._notes += "Change z of orientation from " 
    465                     self._notes += "%s to %s \n"%(self._sample.orientation.z, z_orientation) 
    466                     self._sample.orientation.z  = float(z_orientation) 
     488                    self._notes += "%s to %s \n" % (self._sample.orientation.z, 
     489                                                     z_orientation) 
     490                    self._sample.orientation.z = float(z_orientation) 
    467491            else: 
    468492                self._notes += "Error: Expected a float for orientation 's x " 
    469493                self._notes += "won't changes z orientation from " 
    470                 self._notes += "%s to %s"%(self._sample.orientation.z, z_orientation) 
     494                self._notes += "%s to %s" % (self._sample.orientation.z, 
     495                                              z_orientation) 
    471496        #change the beam center unit 
    472497        unit = self.orientation_unit_tcl.GetValue().lstrip().rstrip() 
     
    505530        if self.manager is not None: 
    506531            self.manager.set_sample(self._sample) 
    507         
     532        if event is not None: 
     533            event.Skip() 
     534             
    508535    def on_click_cancel(self, event): 
    509536        """ 
     
    514541        if self.manager is not None: 
    515542             self.manager.set_sample(self._sample, self._notes) 
     543        if event is not None: 
     544            event.Skip() 
    516545 
    517 if __name__ =="__main__": 
    518      
    519     app  = wx.App() 
     546if __name__ == "__main__": 
     547    app = wx.App() 
    520548    from DataLoader.data_info import Sample 
    521549    sample = Sample() 
  • 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         
  • calculatorview/perspectives/calculator/slit_length_calculator_panel.py

    r74b1770 rb0ab6cb  
    1313import os 
    1414 
    15 from DataLoader.readers.ascii_reader import Reader 
     15#from DataLoader.readers.ascii_reader import Reader 
    1616from sans.guicomm.events import StatusEvent   
    1717from sans.calculator.slit_length_calculator import SlitlengthCalculator   
    18 from calculator_widgets import OutputTextCtrl, InterActiveOutputTextCtrl 
     18from calculator_widgets import OutputTextCtrl 
     19from calculator_widgets import InterActiveOutputTextCtrl 
    1920 
    2021_BOX_WIDTH = 76 
     
    4041    CENTER_PANE = True 
    4142     
    42     def __init__(self, parent, id=-1, *args, **kwds): 
    43         wx.Panel.__init__(self, parent, id=id, *args, **kwds) 
     43    def __init__(self, parent, *args, **kwds): 
     44        wx.Panel.__init__(self, parent, *args, **kwds) 
    4445        #Font size  
    4546        self.SetWindowVariant(variant=FONT_VARIANT) 
     
    7071        """ 
    7172        data_name_txt = wx.StaticText(self, -1, 'Data: ') 
    72         self.data_name_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH*4,-1)) 
     73        self.data_name_tcl = OutputTextCtrl(self, -1,  
     74                                            size=(_BOX_WIDTH*4, -1)) 
    7375        data_hint = "Loaded data" 
    7476        self.data_name_tcl.SetToolTipString(data_hint) 
     
    8789        """ 
    8890        slit_size_txt = wx.StaticText(self, -1, 'Slit Size (FWHM/2): ') 
    89         self.slit_size_tcl = InterActiveOutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 
     91        self.slit_size_tcl = InterActiveOutputTextCtrl(self, -1, 
     92                                                       size=(_BOX_WIDTH, -1)) 
    9093        slit_size_hint = " Estimated full slit size" 
    9194        self.slit_size_tcl.SetToolTipString(slit_size_hint) 
    9295        slit_size_unit_txt = wx.StaticText(self, -1, 'Unit: ') 
    93         self.slit_size_unit_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH,-1))  
     96        self.slit_size_unit_tcl = OutputTextCtrl(self, -1,  
     97                                                 size=(_BOX_WIDTH, -1))  
    9498        slit_size_unit_hint = "Full slit size's unit" 
    9599        self.slit_size_unit_tcl.SetToolTipString(slit_size_unit_hint) 
     
    97101                                      (self.slit_size_tcl, 0, wx.LEFT, 10), 
    98102                                      (slit_size_unit_txt, 0, wx.LEFT, 10), 
    99                                       (self.slit_size_unit_tcl, 0, wx.LEFT, 10)]) 
     103                                    (self.slit_size_unit_tcl, 0, wx.LEFT, 10)]) 
    100104     
    101105    def _layout_hint(self): 
     
    145149        wildcard = "SAXSess Data 1D (*.DAT, *.dat)|*.DAT"  
    146150         
    147         dlg = wx.FileDialog(self, "Choose a file", location,"", wildcard, wx.OPEN) 
     151        dlg = wx.FileDialog(self, "Choose a file", location, 
     152                            "", wildcard, wx.OPEN) 
    148153        if dlg.ShowModal() == wx.ID_OK: 
    149154            path = dlg.GetPath() 
     
    177182                self.reader.stop() 
    178183            if self.parent.parent is not None: 
    179                 wx.PostEvent(self.parent.parent, StatusEvent(status="Loading...", 
     184                wx.PostEvent(self.parent.parent,  
     185                                StatusEvent(status="Loading...", 
    180186                                type="progress")) 
    181187            self.reader = DataReader(path=path, 
     
    186192            if self.parent.parent is None: 
    187193                return  
    188             msg = "Slit Length Calculator: %s"%(sys.exc_value) 
    189             wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 
     194            msg = "Slit Length Calculator: %s" % (sys.exc_value) 
     195            wx.PostEvent(self.parent.parent, 
     196                          StatusEvent(status=msg, type='stop')) 
    190197            return  
    191198             
     
    198205                return  
    199206            msg = "Slit Length cannot be computed for 2D Data" 
    200             wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 
     207            wx.PostEvent(self.parent.parent,  
     208                         StatusEvent(status=msg, type='stop')) 
    201209            return  
    202210        self.data_name_tcl.SetValue(str(data.filename)) 
     
    206214            y = data.y 
    207215            if x == [] or  x is None or y == [] or y is None: 
    208                  msg = "The current data is empty please check x and y" 
    209                  raise ValueError, msg 
     216                msg = "The current data is empty please check x and y" 
     217                raise ValueError, msg 
    210218            slit_length_calculator = SlitlengthCalculator() 
    211219            slit_length_calculator.set_data(x=x, y=y) 
     
    214222            if self.parent.parent is None: 
    215223                return  
    216             msg = "Slit Size Calculator: %s"%(sys.exc_value) 
    217             wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 
     224            msg = "Slit Size Calculator: %s" % (sys.exc_value) 
     225            wx.PostEvent(self.parent.parent, 
     226                          StatusEvent(status=msg, type='stop')) 
    218227            return  
    219228        self.slit_size_tcl.SetValue(str(slit_length)) 
     
    225234        wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 
    226235     
     236     
    227237class SlitLengthCalculatorWindow(wx.Frame): 
    228     def __init__(self, parent=None, id=1, title="Slit Size Calculator"): 
    229         wx.Frame.__init__(self, parent, id, title, size=(PANEL_WIDTH,PANEL_HEIGHT)) 
     238    """ 
     239    """ 
     240    def __init__(self, parent=None, title="Slit Size Calculator"): 
     241        """ 
     242        """ 
     243        wx.Frame.__init__(self, parent, title, 
     244                           size=(PANEL_WIDTH,PANEL_HEIGHT)) 
    230245        self.parent = parent 
    231246        self.panel = SlitLengthCalculatorPanel(parent=self) 
  • calculatorview/perspectives/calculator/source_editor.py

    rad6f597 rb0ab6cb  
    1  
     1""" 
     2""" 
    23import wx 
    34import sys 
    45from copy import deepcopy 
    56from sans.guiframe.utils import check_float 
     7 
    68_BOX_WIDTH = 60 
    7  
    8 if sys.platform.count("win32")>0: 
     9if sys.platform.count("win32") > 0: 
    910    _STATICBOX_WIDTH = 450 
    1011    PANEL_WIDTH = 500 
     
    3738        """ 
    3839        self.main_sizer = wx.BoxSizer(wx.VERTICAL) 
    39         self.box_source = wx.StaticBox(self, -1,str("source")) 
     40        self.box_source = wx.StaticBox(self, -1, str("source")) 
    4041        self.boxsizer_source = wx.StaticBoxSizer(self.box_source, 
    4142                                                    wx.VERTICAL) 
     
    5758        # Sample name [string] 
    5859        sample_name_txt = wx.StaticText(self, -1, 'Sample Name : ')   
    59         self.sample_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0)  
     60        self.sample_name_tcl = wx.TextCtrl(self, -1, 
     61                                            size=(_BOX_WIDTH*5, 20), style=0)  
    6062        self.name_sizer.AddMany([(sample_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    6163                                       (self.sample_name_tcl, 0, wx.EXPAND)]) 
     
    6668        #Radiation type [string] 
    6769        radiation_txt = wx.StaticText(self, -1, 'Radiation: ')   
    68         self.radiation_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 
     70        self.radiation_tcl = wx.TextCtrl(self, -1,  
     71                                         size=(_BOX_WIDTH, 20), style=0) 
    6972        self.radiation_sizer.AddMany([(radiation_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    7073                                     (self.radiation_tcl, 0, wx.LEFT, 20)]) 
     
    7679        #Beam shape [string] 
    7780        beam_shape_txt = wx.StaticText(self, -1, 'Beam shape:')  
    78         self.beam_shape_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)   
    79         self.beam_shape_sizer.AddMany([(beam_shape_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     81        self.beam_shape_tcl = wx.TextCtrl(self, -1, 
     82                                           size=(_BOX_WIDTH, 20), style=0)   
     83        self.beam_shape_sizer.AddMany([(beam_shape_txt, 0, 
     84                                         wx.LEFT|wx.RIGHT, 10), 
    8085                                     (self.beam_shape_tcl, 0, wx.LEFT, 10)]) 
    8186         
     
    8691        #Wavelength [float] [Angstrom] 
    8792        wavelength_txt = wx.StaticText(self, -1, 'wavelength:')  
    88         self.wavelength_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)    
     93        self.wavelength_tcl = wx.TextCtrl(self, -1, 
     94                                           size=(_BOX_WIDTH, 20), style=0)    
    8995        wavelength_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    90         self.wavelength_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0)   
    91         self.wavelength_sizer.AddMany([(wavelength_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     96        self.wavelength_unit_tcl = wx.TextCtrl(self, -1, 
     97                                                size=(_BOX_WIDTH, 20),style=0)   
     98        self.wavelength_sizer.AddMany([(wavelength_txt, 
     99                                         0, wx.LEFT|wx.RIGHT, 10), 
    92100                                     (self.wavelength_tcl, 0, wx.LEFT, 12), 
    93                                      (wavelength_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     101                            (wavelength_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    94102                                     (self.wavelength_unit_tcl, 0, wx.EXPAND)])  
    95103         
     
    100108        #Minimum wavelength [float] [Angstrom] 
    101109        wavelength_min_txt = wx.StaticText(self, -1, 'Wavelength min:')  
    102         self.wavelength_min_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)    
     110        self.wavelength_min_tcl = wx.TextCtrl(self, -1, 
     111                                               size=(_BOX_WIDTH, 20), style=0)    
    103112        wavelength_min_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    104         self.wavelength_min_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0)   
    105         self.wavelength_min_sizer.AddMany([(wavelength_min_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     113        self.wavelength_min_unit_tcl = wx.TextCtrl(self, -1, 
     114                                             size=(_BOX_WIDTH, 20), style=0)   
     115        self.wavelength_min_sizer.AddMany([(wavelength_min_txt,  
     116                                            0, wx.LEFT|wx.RIGHT, 10), 
    106117                                     (self.wavelength_min_tcl, 0, wx.LEFT, 10), 
    107                                      (wavelength_min_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    108                                      (self.wavelength_min_unit_tcl, 0, wx.EXPAND)])   
     118                            (wavelength_min_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     119                            (self.wavelength_min_unit_tcl, 0, wx.EXPAND)])   
    109120     
    110121    def _layout_wavelength_max(self): 
     
    114125        #Maximum wavelength [float] [Angstrom] 
    115126        wavelength_max_txt = wx.StaticText(self, -1, 'Wavelength max:')  
    116         self.wavelength_max_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)    
     127        self.wavelength_max_tcl = wx.TextCtrl(self, -1, 
     128                                             size=(_BOX_WIDTH, 20), style=0)    
    117129        wavelength_max_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    118         self.wavelength_max_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0)   
    119         self.wavelength_max_sizer.AddMany([(wavelength_max_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     130        self.wavelength_max_unit_tcl = wx.TextCtrl(self, -1, 
     131                                             size=(_BOX_WIDTH, 20), style=0)   
     132        self.wavelength_max_sizer.AddMany([(wavelength_max_txt, 0, 
     133                                             wx.LEFT|wx.RIGHT, 10), 
    120134                                     (self.wavelength_max_tcl, 0, wx.LEFT, 7), 
    121                                      (wavelength_max_unit_txt, 0,wx.LEFT|wx.RIGHT, 10), 
    122                                      (self.wavelength_max_unit_tcl, 0, wx.EXPAND)])  
     135                            (wavelength_max_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     136                            (self.wavelength_max_unit_tcl, 0, wx.EXPAND)])  
    123137     
    124138    def _layout_wavelength_spread(self): 
     
    130144        wavelength_spread_unit = 'percent' 
    131145        wavelength_spread_txt = wx.StaticText(self, -1, 'Wavelength spread:')  
    132         self.wavelength_spread_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)    
     146        self.wavelength_spread_tcl = wx.TextCtrl(self, -1, 
     147                                             size=(_BOX_WIDTH, 20), style=0)    
    133148        wavelength_spread_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    134         self.wavelength_spread_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20),style=0)   
    135         self.wavelength_spread_sizer.AddMany([(wavelength_spread_txt, 0, wx.LEFT, 10), 
    136                                      (self.wavelength_spread_tcl, 0, wx.LEFT, 5), 
    137                                      (wavelength_spread_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    138                                      (self.wavelength_spread_unit_tcl, 0, wx.EXPAND)])  
     149        self.wavelength_spread_unit_tcl = wx.TextCtrl(self, -1, 
     150                                             size=(_BOX_WIDTH, 20), style=0)   
     151        self.wavelength_spread_sizer.AddMany([(wavelength_spread_txt, 
     152                                                0, wx.LEFT, 10), 
     153                                (self.wavelength_spread_tcl, 0, wx.LEFT, 5), 
     154                        (wavelength_spread_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     155                        (self.wavelength_spread_unit_tcl, 0, wx.EXPAND)])  
    139156    def _layout_beam_size_name(self): 
    140157        """ 
     
    143160        # Beam size name [string] 
    144161        beam_size_name_txt = wx.StaticText(self, -1, 'Beam size name : ')   
    145         self.beam_size_name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0)  
    146         self.beam_size_name_sizer.AddMany([(beam_size_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     162        self.beam_size_name_tcl = wx.TextCtrl(self, -1, 
     163                                               size=(_BOX_WIDTH*5, 20), style=0)  
     164        self.beam_size_name_sizer.AddMany([(beam_size_name_txt, 
     165                                             0, wx.LEFT|wx.RIGHT, 10), 
    147166                                       (self.beam_size_name_tcl, 0, wx.EXPAND)]) 
    148167         
     
    157176        beam_size_txt = wx.StaticText(self, -1, 'Beam size:')  
    158177        x_beam_size_txt = wx.StaticText(self, -1, 'x = ')   
    159         self.x_beam_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)  
     178        self.x_beam_size_tcl = wx.TextCtrl(self, -1, 
     179                                            size=(_BOX_WIDTH, 20), style=0)  
    160180        y_beam_size_txt = wx.StaticText(self, -1, 'y = ')   
    161         self.y_beam_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)  
     181        self.y_beam_size_tcl = wx.TextCtrl(self, -1, 
     182                                            size=(_BOX_WIDTH, 20), style=0)  
    162183        z_beam_size_txt = wx.StaticText(self, -1, 'z = ')   
    163         self.z_beam_size_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)   
     184        self.z_beam_size_tcl = wx.TextCtrl(self, -1,  
     185                                           size=(_BOX_WIDTH, 20), style=0)   
    164186        beam_size_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
    165         self.beam_size_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=0)   
     187        self.beam_size_unit_tcl = wx.TextCtrl(self, -1,  
     188                                              size=(_BOX_WIDTH, 20), style=0)   
    166189        self.beam_size_sizer.AddMany([(beam_size_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    167190                                     (x_beam_size_txt, 0, wx.LEFT, 17), 
     
    172195                                     (self.z_beam_size_tcl, 0, wx.RIGHT, 10), 
    173196                                     (beam_size_unit_txt, 0, wx.EXPAND), 
    174                                      (self.beam_size_unit_tcl, 0, wx.RIGHT, 10)]) 
     197                                    (self.beam_size_unit_tcl, 0, wx.RIGHT, 10)]) 
    175198         
    176199    def _layout_button(self):   
     
    363386        self._source.wavelength_min = wavelength_min 
    364387        self._notes += " Change wavelength  min from" 
    365         self._notes += " %s to %s \n"%(self._source.wavelength_min, wavelength_min) 
     388        self._notes += " %s to %s \n" % (self._source.wavelength_min, 
     389                                          wavelength_min) 
    366390        #change the wavelength min unit 
    367391        unit = self.wavelength_min_unit_tcl.GetValue().lstrip().rstrip() 
    368392        if self._source.wavelength_min_unit != unit: 
    369393            self._notes += " Change wavelength min's unit from " 
    370             self._notes += "%s to %s"%(self._source.wavelength_min_unit, unit) 
     394            self._notes += "%s to %s" % (self._source.wavelength_min_unit, unit) 
    371395             
    372396    def on_change_wavelength_max(self): 
     
    378402        self._source.wavelength_max = wavelength_max 
    379403        self._notes += " Change wavelength  max from" 
    380         self._notes += " %s to %s \n"%(self._source.wavelength_max, wavelength_max) 
     404        self._notes += " %s to %s \n" % (self._source.wavelength_max, 
     405                                        wavelength_max) 
    381406        #change the wavelength max unit 
    382407        unit = self.wavelength_max_unit_tcl.GetValue().lstrip().rstrip() 
     
    392417        wavelength_spread = self.wavelength_spread_tcl.GetValue().lstrip().rstrip() 
    393418        self._notes += " Change wavelength  spread from" 
    394         self._notes += " %s to %s \n"%(self._source.wavelength_spread, wavelength_spread) 
     419        self._notes += " %s to %s \n" % (self._source.wavelength_spread,  
     420                                         wavelength_spread) 
    395421        self._source.wavelength_spread = wavelength_spread 
    396422        #change the wavelength spread unit 
     
    398424        if self._source.wavelength_spread_unit != unit: 
    399425            self._notes += " Change wavelength spread's unit from " 
    400             self._notes += "%s to %s"%(self._source.wavelength_spread_unit, unit) 
     426            self._notes += "%s to %s" % (self._source.wavelength_spread_unit,  
     427                                         unit) 
    401428            self._source.wavelength_spread_unit = unit 
    402429     
     
    411438        if self._source.beam_size_name != name: 
    412439            self._notes += "Change beam size  's " 
    413             self._notes += "name from %s to %s \n"%(self._source.beam_size_name, name) 
     440            self._notes += "name from %s to %s \n" % (self._source.beam_size_name, 
     441                                                       name) 
    414442            self._source.name = name 
    415443             
     
    426454                if self._source.beam_size.x != float(x_beam_size) : 
    427455                    self._notes += "Change x of beam size from " 
    428                     self._notes += "%s to %s \n"%(self._source.beam_size.x, x_beam_size) 
     456                    self._notes += "%s to %s \n" % (self._source.beam_size.x, 
     457                                                     x_beam_size) 
    429458                    self._source.beam_size.x  = float(x_beam_size) 
    430459            else: 
    431460                self._notes += "Error: Expected a float for the beam size 's x " 
    432461                self._notes += "won't changes x beam size from " 
    433                 self._notes += "%s to %s"%(self._source.beam_size.x, x_beam_size) 
     462                self._notes += "%s to %s" % (self._source.beam_size.x, 
     463                                            x_beam_size) 
    434464        #Change y coordinate 
    435465        y_beam_size = self.y_beam_size_tcl.GetValue().lstrip().rstrip() 
     
    441471                if self._source.beam_size.y != float(y_beam_size): 
    442472                    self._notes += "Change y of beam size from " 
    443                     self._notes += "%s to %s \n"%(self._source.beam_size.y, y_beam_size) 
     473                    self._notes += "%s to %s \n" % (self._source.beam_size.y, 
     474                                                     y_beam_size) 
    444475                    self._source.beam_size.y  = float(y_beam_size) 
    445476            else: 
    446477                self._notes += "Error: Expected a float for the beam size's y " 
    447478                self._notes += "won't changes y beam size from " 
    448                 self._notes += "%s to %s"%(self._source.beam_size.y, y_beam_size) 
     479                self._notes += "%s to %s" % (self._source.beam_size.y, 
     480                                              y_beam_size) 
    449481        #Change z coordinate 
    450482        z_beam_size = self.z_beam_size_tcl.GetValue().lstrip().rstrip() 
     
    456488                if self._source.beam_size.z != float(z_beam_size): 
    457489                    self._notes += "Change z of beam size from " 
    458                     self._notes += "%s to %s \n"%(self._source.beam_size.z, z_beam_size) 
     490                    self._notes += "%s to %s \n" % (self._source.beam_size.z, 
     491                                                     z_beam_size) 
    459492                    self._source.beam_size.z  = float(z_beam_size) 
    460493            else: 
    461494                self._notes += "Error: Expected a float for the beam size 's z " 
    462495                self._notes += "won't changes z beam size from " 
    463                 self._notes += "%s to %s"%(self._source.beam_size.z, z_beam_size) 
     496                self._notes += "%s to %s" % (self._source.beam_size.z, 
     497                                              z_beam_size) 
    464498        #change the beam center unit 
    465499        unit = self.beam_size_unit_tcl.GetValue().lstrip().rstrip() 
     
    471505    def on_click_apply(self, event): 
    472506        """ 
    473             Apply user values to the source 
     507        Apply user values to the source 
    474508        """ 
    475509        self.on_change_name() 
     
    484518        if self.manager is not None: 
    485519            self.manager.set_source(self._source, self._notes) 
     520        if event is not None: 
     521            event.Skip() 
    486522         
    487523    def on_click_cancel(self, event): 
    488524        """ 
    489             reset the current source 
     525        reset the current source 
    490526        """ 
    491527        self.reset_source() 
    492528        self.set_values() 
    493529        if self.manager is not None: 
    494              self.manager.set_source(self._source)     
     530            self.manager.set_source(self._source) 
     531        if event is not None: 
     532            event.Skip() 
    495533     
    496534if __name__ =="__main__": 
Note: See TracChangeset for help on using the changeset viewer.