Ignore:
Timestamp:
Mar 4, 2015 3:28:39 PM (9 years ago)
Author:
Doucet, Mathieu <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
2f732b0
Parents:
76aed53
Message:

Take care of white spaces (pylint)

File:
1 edited

Legend:

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

    r9654baf r49ab5d7  
    22This software was developed by the University of Tennessee as part of the 
    33Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
     4project funded by the US National Science Foundation. 
    55 
    66See the license text in license.txt 
     
    1515from sas.guiframe.panel_base import PanelBase 
    1616 
    17 from sas.guiframe.events import StatusEvent   
    18 from sas.calculator.slit_length_calculator import SlitlengthCalculator   
     17from sas.guiframe.events import StatusEvent 
     18from sas.calculator.slit_length_calculator import SlitlengthCalculator 
    1919from calculator_widgets import OutputTextCtrl 
    2020from calculator_widgets import InterActiveOutputTextCtrl 
    21 from sas.perspectives.calculator import calculator_widgets as widget    
     21from sas.perspectives.calculator import calculator_widgets as widget 
    2222from sas.guiframe.documentation_window import DocumentationWindow 
    2323 
     
    3232    PANEL_HEIGHT = 210 
    3333    FONT_VARIANT = 1 
    34   
     34 
    3535class SlitLengthCalculatorPanel(wx.Panel, PanelBase): 
    3636    """ 
     
    4343    ## Flag to tell the AUI manager to put this panel in the center pane 
    4444    CENTER_PANE = True 
    45      
     45 
    4646    def __init__(self, parent, *args, **kwds): 
    4747        wx.Panel.__init__(self, parent, *args, **kwds) 
     
    5252        self.reader = None 
    5353        # Default location 
    54         self._default_save_location = os.getcwd()   
     54        self._default_save_location = os.getcwd() 
    5555        # Object that receive status event 
    5656        self.parent = parent 
    5757        self._do_layout() 
    58         
     58 
    5959    def _define_structure(self): 
    6060        """ 
     
    6262        """ 
    6363        self.main_sizer = wx.BoxSizer(wx.VERTICAL) 
    64         self.box_source = wx.StaticBox(self, -1,str("Slit Size Calculator")) 
     64        self.box_source = wx.StaticBox(self, -1, str("Slit Size Calculator")) 
    6565        self.boxsizer_source = wx.StaticBoxSizer(self.box_source, 
    6666                                                    wx.VERTICAL) 
     
    6969        self.hint_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    7070        self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    71         
     71 
    7272    def _layout_data_name(self): 
    7373        """ 
     
    7575        """ 
    7676        data_name_txt = wx.StaticText(self, -1, 'Data: ') 
    77         self.data_name_tcl = OutputTextCtrl(self, -1,  
    78                                             size=(_BOX_WIDTH*4, -1)) 
     77        self.data_name_tcl = OutputTextCtrl(self, -1, 
     78                                            size=(_BOX_WIDTH * 4, -1)) 
    7979        data_hint = "Loaded data" 
    8080        self.data_name_tcl.SetToolTipString(data_hint) 
     
    9898        self.slit_size_tcl.SetToolTipString(slit_size_hint) 
    9999        slit_size_unit_txt = wx.StaticText(self, -1, 'Unit: ') 
    100         self.slit_size_unit_tcl = OutputTextCtrl(self, -1,  
    101                                                  size=(_BOX_WIDTH, -1))  
     100        self.slit_size_unit_tcl = OutputTextCtrl(self, -1, 
     101                                                 size=(_BOX_WIDTH, -1)) 
    102102        slit_size_unit_hint = "Full slit size's unit" 
    103103        self.slit_size_unit_tcl.SetToolTipString(slit_size_unit_hint) 
     
    106106                                      (slit_size_unit_txt, 0, wx.LEFT, 10), 
    107107                                    (self.slit_size_unit_tcl, 0, wx.LEFT, 10)]) 
    108      
     108 
    109109    def _layout_hint(self): 
    110110        """ 
    111             Fill the sizer containing hint  
     111            Fill the sizer containing hint 
    112112        """ 
    113113        hint_msg = "This calculation works only for  SAXSess beam profile data." 
    114114        self.hint_txt = wx.StaticText(self, -1, hint_msg) 
    115115        self.hint_sizer.AddMany([(self.hint_txt, 0, wx.LEFT, 15)]) 
    116      
    117     def _layout_button(self):   
     116 
     117    def _layout_button(self): 
    118118        """ 
    119119            Do the layout for the button widgets 
    120         """  
    121         self.bt_close = wx.Button(self, wx.ID_CANCEL,'Close') 
     120        """ 
     121        self.bt_close = wx.Button(self, wx.ID_CANCEL, 'Close') 
    122122        self.bt_close.Bind(wx.EVT_BUTTON, self.on_close) 
    123123        self.bt_close.SetToolTipString("Close this window.") 
    124   
     124 
    125125        id = wx.NewId() 
    126126        self.button_help = wx.Button(self, id, "HELP") 
    127127        self.button_help.SetToolTipString("Help for slit length calculator.") 
    128         self.Bind(wx.EVT_BUTTON, self.on_help,id=id)    
     128        self.Bind(wx.EVT_BUTTON, self.on_help, id=id) 
    129129 
    130130        self.button_sizer.AddMany([(self.button_help, 0, wx.LEFT, 280), 
    131131                                   (self.bt_close, 0, wx.LEFT, 20)]) 
    132                 
     132 
    133133    def _do_layout(self): 
    134134        """ 
     
    141141        self._layout_button() 
    142142        self.boxsizer_source.AddMany([(self.data_name_sizer, 0, 
    143                                           wx.EXPAND|wx.TOP|wx.BOTTOM, 5), 
     143                                          wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 
    144144                                   (self.slit_size_sizer, 0, 
    145                                      wx.EXPAND|wx.TOP|wx.BOTTOM, 5), 
     145                                     wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 
    146146                                     (self.hint_sizer, 0, 
    147                                      wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 
     147                                     wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 
    148148        self.main_sizer.AddMany([(self.boxsizer_source, 0, wx.ALL, 10), 
    149149                                  (self.button_sizer, 0, 
    150                                     wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 
     150                                    wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 
    151151        self.SetSizer(self.main_sizer) 
    152152        self.SetAutoLayout(True) 
    153          
     153 
    154154    def choose_data_file(self, location=None): 
    155155        path = None 
     
    157157        if location == None: 
    158158            location = os.getcwd() 
    159          
    160         wildcard = "SAXSess Data 1D (*.DAT, *.dat)|*.DAT"  
    161          
     159 
     160        wildcard = "SAXSess Data 1D (*.DAT, *.dat)|*.DAT" 
     161 
    162162        dlg = wx.FileDialog(self, "Choose a file", location, 
    163163                            "", wildcard, wx.OPEN) 
     
    166166            filename = os.path.basename(path) 
    167167        dlg.Destroy() 
    168          
     168 
    169169        return path 
    170170 
    171     def on_help(self, event):     
     171    def on_help(self, event): 
    172172        """ 
    173173        Bring up the slit length calculator Documentation whenever 
    174         the HELP button is clicked.  
    175          
     174        the HELP button is clicked. 
     175 
    176176        Calls DocumentationWindow with the path of the location within the 
    177         documentation tree (after /doc/ ....".  Note that when using old  
    178         versions of Wx (before 2.9) and thus not the release version of  
    179         installers, the help comes up at the top level of the file as  
     177        documentation tree (after /doc/ ....".  Note that when using old 
     178        versions of Wx (before 2.9) and thus not the release version of 
     179        installers, the help comes up at the top level of the file as 
    180180        webbrowser does not pass anything past the # to the browser when it is 
    181181        running "file:///...." 
    182      
     182 
    183183    :param evt: Triggers on clicking the help button 
    184184    """ 
    185                  
     185 
    186186        _TreeLocation = "user/perspectives/calculator/slit_calculator_help.html" 
    187187        _doc_viewer = DocumentationWindow(self, -1, \ 
    188              _TreeLocation,"Slit Length Calculator Help") 
     188             _TreeLocation, "Slit Length Calculator Help") 
    189189 
    190190    def on_close(self, event): 
     
    193193        """ 
    194194        self.parent.Close() 
    195          
     195 
    196196    def on_load_data(self, event): 
    197197        """ 
     
    201201        """ 
    202202        path = self.choose_data_file(location=self._default_save_location) 
    203          
     203 
    204204        if path is None: 
    205             return  
     205            return 
    206206        self._default_save_location = path 
    207207        try: 
     
    212212                self.reader.stop() 
    213213            if self.parent.parent is not None: 
    214                 wx.PostEvent(self.parent.parent,  
     214                wx.PostEvent(self.parent.parent, 
    215215                                StatusEvent(status="Loading...", 
    216216                                type="progress")) 
     
    222222        except: 
    223223            if self.parent.parent is None: 
    224                 return  
     224                return 
    225225            msg = "Slit Length Calculator: %s" % (sys.exc_value) 
    226226            wx.PostEvent(self.parent.parent, 
    227227                          StatusEvent(status=msg, type='stop')) 
    228             return  
    229          
     228            return 
     229 
    230230    def load_update(self): 
    231231        """ 
     
    233233        """ 
    234234        if self.parent.parent is None: 
    235                 return  
     235                return 
    236236        if self.reader.isrunning(): 
    237237            type = "progress" 
     
    240240        wx.PostEvent(self.parent.parent, StatusEvent(status="", 
    241241                                                  type=type)) 
    242              
     242 
    243243    def complete_loading(self, data=None, filename=''): 
    244244        """ 
     
    247247        if data is None or data.__class__.__name__ == 'Data2D': 
    248248            if self.parent.parent is None: 
    249                 return  
     249                return 
    250250            msg = "Slit Length cannot be computed for 2D Data" 
    251             wx.PostEvent(self.parent.parent,  
     251            wx.PostEvent(self.parent.parent, 
    252252                         StatusEvent(status=msg, type='stop')) 
    253             return  
     253            return 
    254254        self.data_name_tcl.SetValue(str(data.filename)) 
    255255        #compute the slit size 
     
    265265        except: 
    266266            if self.parent.parent is None: 
    267                 return  
     267                return 
    268268            msg = "Slit Size Calculator: %s" % (sys.exc_value) 
    269269            wx.PostEvent(self.parent.parent, 
    270270                          StatusEvent(status=msg, type='stop')) 
    271             return  
     271            return 
    272272        self.slit_size_tcl.SetValue(str(slit_length)) 
    273273        #Display unit 
    274274        self.slit_size_unit_tcl.SetValue('[Unknown]') 
    275275        if self.parent.parent is None: 
    276             return  
     276            return 
    277277        msg = "Load Complete" 
    278278        wx.PostEvent(self.parent.parent, StatusEvent(status=msg, type='stop')) 
    279      
    280      
     279 
     280 
    281281class SlitLengthCalculatorWindow(widget.CHILD_FRAME): 
    282282    """ 
    283283    """ 
    284284    def __init__(self, parent=None, manager=None, title="Slit Size Calculator", 
    285                 size=(PANEL_WIDTH,PANEL_HEIGHT), *args, **kwds): 
    286         """ 
    287         """ 
    288         kwds['size']= size 
    289         kwds['title']= title 
     285                size=(PANEL_WIDTH, PANEL_HEIGHT), *args, **kwds): 
     286        """ 
     287        """ 
     288        kwds['size'] = size 
     289        kwds['title'] = title 
    290290        widget.CHILD_FRAME.__init__(self, parent, *args, **kwds) 
    291291        self.parent = parent 
     
    303303            self.manager.cal_slit_frame = None 
    304304        self.Destroy() 
    305          
    306 if __name__ == "__main__":  
     305 
     306if __name__ == "__main__": 
    307307    app = wx.PySimpleApp() 
    308308    widget.CHILD_FRAME = wx.Frame 
    309     frame = SlitLengthCalculatorWindow()     
     309    frame = SlitLengthCalculatorWindow() 
    310310    frame.Show(True) 
    311     app.MainLoop()      
     311    app.MainLoop() 
Note: See TracChangeset for help on using the changeset viewer.