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/collimation_editor.py

    r79492222 r49ab5d7  
    1111_BOX_WIDTH = 60 
    1212 
    13 if sys.platform.count("win32")>0: 
     13if sys.platform.count("win32") > 0: 
    1414    _STATICBOX_WIDTH = 500 
    1515    PANEL_WIDTH = 530 
     
    2121    PANEL_HEIGHT = 480 
    2222    FONT_VARIANT = 1 
    23      
     23 
    2424class CollimationDialog(wx.Dialog): 
    2525    """ 
     
    3333        wx.Dialog.__init__(self, parent=parent, *args, **kwds) 
    3434        self.parent = parent 
    35         self.manager = manager  
     35        self.manager = manager 
    3636        self._collimation = collimation 
    3737        self._reset_collimation = deepcopy(collimation) 
     
    4242        self.box_collimation = None 
    4343        self.boxsizer_collimation = None 
    44          
    45          
     44 
     45 
    4646        self._do_layout() 
    4747        self.set_values() 
    48   
     48 
    4949    def _define_structure(self): 
    5050        """ 
    51         define initial sizer  
     51        define initial sizer 
    5252        """ 
    5353        self.main_sizer = wx.BoxSizer(wx.VERTICAL) 
     
    5656        self.boxsizer_collimation = wx.StaticBoxSizer(self.box_collimation, 
    5757                                                       wx.VERTICAL) 
    58          
     58 
    5959        collimation_box = wx.StaticBox(self, -1, "Edit Number of Collimations") 
    6060        self.collimation_sizer = wx.StaticBoxSizer(collimation_box, wx.VERTICAL) 
     
    6262        self.collimation_button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    6363        self.collimation_hint_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    64          
     64 
    6565        self.name_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    6666        self.length_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    6767        self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    68          
     68 
    6969        aperture_box = wx.StaticBox(self, -1, "Edit Aperture") 
    7070        self.aperture_sizer = wx.StaticBoxSizer(aperture_box, wx.VERTICAL) 
    7171        self.aperture_button_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    7272        self.aperture_hint_sizer = wx.BoxSizer(wx.HORIZONTAL) 
    73        
     73 
    7474    def _layout_collimation(self): 
    7575        """ 
    7676        Do the layout for collimation related widgets 
    7777        """ 
    78         collimation_name_txt = wx.StaticText(self, -1, "Collimation:")  
     78        collimation_name_txt = wx.StaticText(self, -1, "Collimation:") 
    7979        hint_collimation_txt = 'Current available collimation.' 
    80         collimation_name_txt.SetToolTipString(hint_collimation_txt)  
     80        collimation_name_txt.SetToolTipString(hint_collimation_txt) 
    8181        self.collimation_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    82         wx.EVT_COMBOBOX(self.collimation_cbox, -1, self.on_select_collimation)  
     82        wx.EVT_COMBOBOX(self.collimation_cbox, -1, self.on_select_collimation) 
    8383        hint_collimation_name_txt = 'Name of collimations.' 
    84         self.collimation_cbox.SetToolTipString(hint_collimation_name_txt)  
    85     
     84        self.collimation_cbox.SetToolTipString(hint_collimation_name_txt) 
     85 
    8686        self.bt_add_collimation = wx.Button(self, -1, "Add") 
    8787        self.bt_add_collimation.SetToolTipString("Edit data's collimation.") 
    8888        self.bt_add_collimation.Bind(wx.EVT_BUTTON, self.add_collimation) 
    89          
     89 
    9090        self.bt_remove_collimation = wx.Button(self, -1, "Remove") 
    9191        hint = "Remove data's collimation." 
    9292        self.bt_remove_collimation.SetToolTipString(hint) 
    9393        self.bt_remove_collimation.Bind(wx.EVT_BUTTON, self.remove_collimation) 
    94        
     94 
    9595        self.collimation_button_sizer.AddMany([(collimation_name_txt, 0, 
    9696                                                 wx.LEFT, 15), 
     
    100100                                       0, wx.LEFT, 5)]) 
    101101        collimation_hint_txt = 'No collimation is available for this data.' 
    102         self.collimation_txt = wx.StaticText(self, -1, collimation_hint_txt)  
     102        self.collimation_txt = wx.StaticText(self, -1, collimation_hint_txt) 
    103103        self.collimation_hint_sizer.Add(self.collimation_txt, 0, wx.LEFT, 10) 
    104104        self.collimation_sizer.AddMany([(self.collimation_button_sizer, 
     
    106106                                     (self.collimation_hint_sizer, 
    107107                                       0, wx.ALL, 10)]) 
    108       
     108 
    109109        self.fill_collimation_combox() 
    110110        self.enable_collimation() 
    111          
     111 
    112112 
    113113    def _layout_name(self): 
     
    116116        """ 
    117117        #Collimation name [string] 
    118         name_txt = wx.StaticText(self, -1, 'Name : ')   
    119         self.name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0)  
    120         self.name_sizer.AddMany([(name_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     118        name_txt = wx.StaticText(self, -1, 'Name : ') 
     119        self.name_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH * 5, 20), style=0) 
     120        self.name_sizer.AddMany([(name_txt, 0, wx.LEFT | wx.RIGHT, 10), 
    121121                                       (self.name_tcl, 0, wx.EXPAND)]) 
    122          
     122 
    123123    def _layout_length(self): 
    124124        """ 
     
    126126        """ 
    127127        #Collimation length 
    128         length_txt = wx.StaticText(self, -1, 'Length:')  
    129         self.length_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0)    
    130         length_unit_txt = wx.StaticText(self, -1, 'Unit: ')  
     128        length_txt = wx.StaticText(self, -1, 'Length:') 
     129        self.length_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 
     130        length_unit_txt = wx.StaticText(self, -1, 'Unit: ') 
    131131        self.length_unit_tcl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
    132                                            style=0)   
    133         self.length_sizer.AddMany([(length_txt, 0, wx.LEFT|wx.RIGHT, 10), 
     132                                           style=0) 
     133        self.length_sizer.AddMany([(length_txt, 0, wx.LEFT | wx.RIGHT, 10), 
    134134                                     (self.length_tcl, 0, wx.LEFT, 12), 
    135                                      (length_unit_txt, 0, wx.LEFT|wx.RIGHT, 10), 
    136                                      (self.length_unit_tcl, 0, wx.EXPAND)])  
    137     
    138     def _layout_button(self):   
     135                                     (length_unit_txt, 0, wx.LEFT | wx.RIGHT, 10), 
     136                                     (self.length_unit_tcl, 0, wx.EXPAND)]) 
     137 
     138    def _layout_button(self): 
    139139        """ 
    140140        Do the layout for the button widgets 
    141         """  
    142         self.bt_apply = wx.Button(self, -1,'Apply') 
     141        """ 
     142        self.bt_apply = wx.Button(self, -1, 'Apply') 
    143143        self.bt_apply.Bind(wx.EVT_BUTTON, self.on_click_apply) 
    144144        self.bt_apply.SetToolTipString("Apply current changes to collimation.") 
    145         self.bt_cancel = wx.Button(self, -1,'Cancel') 
     145        self.bt_cancel = wx.Button(self, -1, 'Cancel') 
    146146        self.bt_cancel.SetToolTipString("Cancel current changes.") 
    147147        self.bt_cancel.Bind(wx.EVT_BUTTON, self.on_click_cancel) 
    148         self.bt_close = wx.Button(self, wx.ID_CANCEL,'Close') 
     148        self.bt_close = wx.Button(self, wx.ID_CANCEL, 'Close') 
    149149        self.bt_close.SetToolTipString("Close window.") 
    150150        self.button_sizer.AddMany([(self.bt_apply, 0, wx.LEFT, 200), 
     
    155155        Do the layout for aperture related widgets 
    156156        """ 
    157         aperture_name_txt = wx.StaticText(self, -1, "Aperture:")  
     157        aperture_name_txt = wx.StaticText(self, -1, "Aperture:") 
    158158        hint_aperture_txt = 'Current available aperture.' 
    159         aperture_name_txt.SetToolTipString(hint_aperture_txt)  
     159        aperture_name_txt.SetToolTipString(hint_aperture_txt) 
    160160        self.aperture_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    161161        hint_aperture_name_txt = 'Name of apertures.' 
    162         self.aperture_cbox.SetToolTipString(hint_aperture_name_txt)  
    163      
     162        self.aperture_cbox.SetToolTipString(hint_aperture_name_txt) 
     163 
    164164        self.bt_add_aperture = wx.Button(self, -1, "Add") 
    165165        self.bt_add_aperture.SetToolTipString("Edit data's aperture.") 
     
    171171        self.bt_remove_aperture.SetToolTipString("Remove data's aperture.") 
    172172        self.bt_remove_aperture.Bind(wx.EVT_BUTTON, self.remove_aperture) 
    173        
     173 
    174174        self.aperture_button_sizer.AddMany([(aperture_name_txt, 0, wx.LEFT, 15), 
    175175                                     (self.aperture_cbox, 0, wx.LEFT, 5), 
     
    178178                                     (self.bt_remove_aperture, 0, wx.LEFT, 5)]) 
    179179        aperture_hint_txt = 'No aperture is available for this data.' 
    180         self.aperture_txt = wx.StaticText(self, -1, aperture_hint_txt)  
     180        self.aperture_txt = wx.StaticText(self, -1, aperture_hint_txt) 
    181181        self.aperture_hint_sizer.Add(self.aperture_txt, 0, wx.LEFT, 10) 
    182182        self.aperture_sizer.AddMany([(self.aperture_button_sizer, 
     
    185185        self.fill_aperture_combox() 
    186186        self.enable_aperture() 
    187      
     187 
    188188    def _do_layout(self): 
    189189        """ 
     
    196196        self._layout_aperture() 
    197197        self._layout_button() 
    198       
     198 
    199199        self.boxsizer_collimation.AddMany([(self.name_sizer, 0, 
    200                                           wx.EXPAND|wx.TOP|wx.BOTTOM, 5), 
     200                                          wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 
    201201                                          (self.length_sizer, 0, 
    202                                      wx.EXPAND|wx.TOP|wx.BOTTOM, 5), 
     202                                     wx.EXPAND | wx.TOP | wx.BOTTOM, 5), 
    203203                                     (self.aperture_sizer, 0, 
    204                                      wx.EXPAND|wx.ALL, 10)]) 
     204                                     wx.EXPAND | wx.ALL, 10)]) 
    205205        self.main_sizer.AddMany([(self.collimation_sizer, 0, wx.ALL, 10), 
    206206                                  (self.boxsizer_collimation, 0, wx.ALL, 10), 
    207207                                  (self.button_sizer, 0, 
    208                                     wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 
     208                                    wx.EXPAND | wx.TOP | wx.BOTTOM, 5)]) 
    209209        self.SetSizer(self.main_sizer) 
    210210        self.SetAutoLayout(True) 
    211          
     211 
    212212    def get_current_collimation(self): 
    213213        """ 
     
    215215        if not self.collimation_cbox.IsEnabled(): 
    216216            return None, None, None 
    217         position = self.collimation_cbox.GetSelection()  
     217        position = self.collimation_cbox.GetSelection() 
    218218        if position == wx.NOT_FOUND: 
    219219            return None, None, None 
    220         collimation_name = self.collimation_cbox.GetStringSelection()  
     220        collimation_name = self.collimation_cbox.GetStringSelection() 
    221221        collimation = self.collimation_cbox.GetClientData(position) 
    222222        return collimation, collimation_name, position 
    223      
     223 
    224224    def fill_collimation_combox(self): 
    225225        """ 
     
    232232            self.collimation_cbox.SetClientData(pos, collimation) 
    233233            self.collimation_cbox.SetSelection(pos) 
    234             self.collimation_cbox.SetStringSelection(str(collimation.name))  
    235              
     234            self.collimation_cbox.SetStringSelection(str(collimation.name)) 
     235 
    236236    def add_collimation(self, event): 
    237237        """ 
    238238        Append empty collimation to data's list of collimation 
    239239        """ 
    240          
     240 
    241241        if not self.collimation_cbox.IsEnabled(): 
    242242            self.collimation_cbox.Enable() 
     
    245245        position = self.collimation_cbox.Append(str(collimation.name)) 
    246246        self.collimation_cbox.SetClientData(position, collimation) 
    247         self.collimation_cbox.SetSelection(position)  
    248         self.enable_collimation()  
     247        self.collimation_cbox.SetSelection(position) 
     248        self.enable_collimation() 
    249249        self.bt_add_aperture.Enable() 
    250250        self.fill_aperture_combox() 
    251251        self.enable_aperture() 
    252252        self.set_values() 
    253          
     253 
    254254    def remove_collimation(self, event): 
    255255        """ 
     
    262262                if collimation in self._collimation: 
    263263                    self._collimation.remove(collimation) 
    264                     self.collimation_cbox.Delete(position)  
     264                    self.collimation_cbox.Delete(position) 
    265265                    #set the combo box box the next available item 
    266266                    position = self.collimation_cbox.GetCount() 
    267267                    if position > 0: 
    268                         position -= 1  
     268                        position -= 1 
    269269                    self.collimation_cbox.SetSelection(position) 
    270         if not self._collimation and self.collimation_cbox.GetCount() == 0:        
    271             self.bt_add_aperture.Disable()   
     270        if not self._collimation and self.collimation_cbox.GetCount() == 0: 
     271            self.bt_add_aperture.Disable() 
    272272            self.name_tcl.Clear() 
    273273            self.length_tcl.Clear() 
     
    278278        self.enable_collimation() 
    279279        self.enable_aperture() 
    280          
     280 
    281281    def on_select_collimation(self, event): 
    282282        """ 
    283         fill the control on the panel according to  
    284         the current  selected collimation  
     283        fill the control on the panel according to 
     284        the current  selected collimation 
    285285        """ 
    286286        self.set_values() 
    287287        self.fill_aperture_combox() 
    288288        self.enable_aperture() 
    289      
     289 
    290290    def enable_collimation(self): 
    291291        """ 
     
    298298            n_collimation = self.collimation_cbox.GetCount() 
    299299            collimation_hint_txt = "collimations" 
    300             collimation_hint_txt += " available: %s "% str(n_collimation) 
     300            collimation_hint_txt += " available: %s " % str(n_collimation) 
    301301            if len(self._collimation) > 0: 
    302302                self.bt_remove_collimation.Enable() 
     
    308308            collimation_hint_txt = 'No collimation is available for this data.' 
    309309        self.collimation_txt.SetLabel(collimation_hint_txt) 
    310             
    311     
     310 
     311 
    312312    def reset_collimation_combobox(self, edited_collimation): 
    313313        """ 
     
    318318            if collimation == edited_collimation: 
    319319                collimation = edited_collimation 
    320                 self.collimation_cbox.SetString(position, str(collimation.name))  
     320                self.collimation_cbox.SetString(position, str(collimation.name)) 
    321321                self.collimation_cbox.SetClientData(position, collimation) 
    322                 self.collimation_cbox.SetStringSelection(str(collimation.name))  
    323           
     322                self.collimation_cbox.SetStringSelection(str(collimation.name)) 
     323 
    324324    def add_aperture(self, event): 
    325325        """ 
     
    333333        position = self.aperture_cbox.Append(str(aperture.name)) 
    334334        self.aperture_cbox.SetClientData(position, aperture) 
    335         self.aperture_cbox.SetSelection(position)  
     335        self.aperture_cbox.SetSelection(position) 
    336336        self.enable_aperture() 
    337          
     337 
    338338    def edit_aperture(self, event): 
    339339        """ 
     
    341341        """ 
    342342        if self._collimation is None or not self.aperture_cbox.IsEnabled(): 
    343             return  
    344         position = self.aperture_cbox.GetSelection()  
     343            return 
     344        position = self.aperture_cbox.GetSelection() 
    345345        if position != wx.NOT_FOUND: 
    346             name = self.aperture_cbox.GetStringSelection()  
     346            name = self.aperture_cbox.GetStringSelection() 
    347347            aperture = self.aperture_cbox.GetClientData(position) 
    348348            dlg = ApertureDialog(parent=self, aperture=aperture) 
    349349            dlg.set_manager(self) 
    350350            dlg.ShowModal() 
    351              
     351 
    352352    def remove_aperture(self, event): 
    353353        """ 
     
    363363                if aperture in collimation.aperture: 
    364364                    collimation.aperture.remove(aperture) 
    365                     self.aperture_cbox.Delete(position)  
     365                    self.aperture_cbox.Delete(position) 
    366366                    #set the combo box box the next available item 
    367367                    position = self.aperture_cbox.GetCount() 
    368368                    if position > 0: 
    369                         position -= 1  
     369                        position -= 1 
    370370                    self.aperture_cbox.SetSelection(position) 
    371                     
     371 
    372372        #disable or enable the combo box when necessary 
    373373        self.enable_aperture() 
    374          
     374 
    375375    def set_aperture(self, aperture): 
    376376        """ 
     
    386386                    self.reset_aperture_combobox(edited_aperture=aperture) 
    387387                    return 
    388                  
     388 
    389389    def enable_aperture(self): 
    390390        """ 
     
    397397            self.bt_remove_aperture.Enable() 
    398398            n_aperture = self.aperture_cbox.GetCount() 
    399             aperture_hint_txt = 'apertures available: %s '%str(n_aperture) 
     399            aperture_hint_txt = 'apertures available: %s ' % str(n_aperture) 
    400400            if len(collimation.aperture) > 0: 
    401401                self.bt_remove_aperture.Enable() 
     
    408408            aperture_hint_txt = 'No aperture is available for this data.' 
    409409        self.aperture_txt.SetLabel(aperture_hint_txt) 
    410      
     410 
    411411    def reset_aperture_combobox(self, edited_aperture): 
    412412        """ 
     
    417417            if aperture == edited_aperture: 
    418418                aperture = edited_aperture 
    419                 self.aperture_cbox.SetString(position, str(aperture.name))  
     419                self.aperture_cbox.SetString(position, str(aperture.name)) 
    420420                self.aperture_cbox.SetClientData(position, aperture) 
    421                 self.aperture_cbox.SetStringSelection(str(aperture.name))  
    422                  
     421                self.aperture_cbox.SetStringSelection(str(aperture.name)) 
     422 
    423423    def fill_aperture_combox(self): 
    424424        """ 
     
    433433            self.aperture_cbox.SetClientData(pos, aperture) 
    434434            self.aperture_cbox.SetSelection(pos) 
    435             self.aperture_cbox.SetStringSelection(str(aperture.name))  
    436           
     435            self.aperture_cbox.SetStringSelection(str(aperture.name)) 
     436 
    437437    def set_manager(self, manager): 
    438         """     
     438        """ 
    439439        Set manager of this window 
    440440        """ 
    441441        self.manager = manager 
    442          
     442 
    443443    def set_values(self): 
    444444        """ 
     
    459459        #Length unit 
    460460        self.length_unit_tcl.SetValue(str(collimation.length_unit)) 
    461          
     461 
    462462    def get_collimation(self): 
    463463        """ 
     
    465465        """ 
    466466        return self._collimation 
    467      
     467 
    468468    def get_notes(self): 
    469469        """ 
     
    471471        """ 
    472472        return self._notes 
    473      
     473 
    474474    def on_change_name(self): 
    475475        """ 
     
    477477        """ 
    478478        collimation, collimation_name, position = self.get_current_collimation() 
    479         if collimation is None:  
     479        if collimation is None: 
    480480            return 
    481481        #Change the name of the collimation 
     
    485485        if collimation.name != name: 
    486486            self._notes += "Change collimation 's " 
    487             self._notes += "name from %s to %s \n"%(collimation.name, name) 
     487            self._notes += "name from %s to %s \n" % (collimation.name, name) 
    488488            collimation.name = name 
    489             self.collimation_cbox.SetString(position, str(collimation.name))  
     489            self.collimation_cbox.SetString(position, str(collimation.name)) 
    490490            self.collimation_cbox.SetClientData(position, collimation) 
    491             self.collimation_cbox.SetStringSelection(str(collimation.name))  
    492     
     491            self.collimation_cbox.SetStringSelection(str(collimation.name)) 
     492 
    493493    def on_change_length(self): 
    494494        """ 
     
    496496        """ 
    497497        collimation, collimation_name, position = self.get_current_collimation() 
    498         if collimation is None:  
     498        if collimation is None: 
    499499            return 
    500500        #Change length   
     
    507507                if collimation.length != float(length): 
    508508                    self._notes += "Change Collimation length from " 
    509                     self._notes += "%s to %s \n"%(collimation.length, length) 
    510                     collimation.length  = float(length) 
     509                    self._notes += "%s to %s \n" % (collimation.length, length) 
     510                    collimation.length = float(length) 
    511511            else: 
    512512                self._notes += "Error: Expected a float for collimation length" 
    513513                self._notes += " won't changes length from " 
    514                 self._notes += "%s to %s"%(collimation.length, length) 
     514                self._notes += "%s to %s" % (collimation.length, length) 
    515515        #change length  unit 
    516516        unit = self.length_unit_tcl.GetValue().lstrip().rstrip() 
    517517        if collimation.length_unit != unit: 
    518518            self._notes += " Change length's unit from " 
    519             self._notes += "%s to %s"%(collimation.length_unit, unit) 
     519            self._notes += "%s to %s" % (collimation.length_unit, unit) 
    520520            collimation.length_unit = unit 
    521      
     521 
    522522    def on_click_apply(self, event): 
    523523        """ 
     
    529529        if self.manager is not None: 
    530530            self.manager.set_collimation(self._collimation, self._notes) 
    531         
     531 
    532532    def on_click_cancel(self, event): 
    533533        """ 
     
    538538        if self.manager is not None: 
    539539            self.manager.set_collimation(self._collimation) 
    540         
    541   
     540 
     541 
    542542if __name__ == "__main__": 
    543543 
    544     app  = wx.App() 
     544    app = wx.App() 
    545545    dlg = CollimationDialog(collimation=[Collimation()]) 
    546546    dlg.ShowModal() 
    547547    app.MainLoop() 
    548   
Note: See TracChangeset for help on using the changeset viewer.