Changeset b40ad40 in sasview


Ignore:
Timestamp:
Mar 5, 2015 4:53:03 PM (9 years ago)
Author:
Mathieu Doucet <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:
c4f6851
Parents:
c039589
Message:

pylint fixes

Location:
src/sas/guiframe/local_perspectives/plotting
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/sas/guiframe/local_perspectives/plotting/SectorSlicer.py

    r79492222 rb40ad40  
    1  
     1""" 
     2    Sector interactor 
     3""" 
    24import math 
    35import wx 
    4 #from copy import deepcopy 
    56from BaseInteractor import _BaseInteractor 
    67from sas.guiframe.events import NewPlotEvent 
     
    1617    """ 
    1718    def __init__(self, base, axes, color='black', zorder=3): 
    18          
     19 
    1920        _BaseInteractor.__init__(self, base, axes, color=color) 
    2021        ## Class initialization 
    2122        self.markers = [] 
    22         self.axes = axes    
    23         ## connect the plot to event  
     23        self.axes = axes 
     24        ## connect the plot to event 
    2425        self.connect = self.base.connect 
    25          
    26         ## compute qmax limit to reset the graph      
    27         x = math.pow(max(self.base.data2D.xmax,  
     26 
     27        ## compute qmax limit to reset the graph 
     28        x = math.pow(max(self.base.data2D.xmax, 
    2829                         math.fabs(self.base.data2D.xmin)), 2) 
    29         y = math.pow(max(self.base.data2D.ymax,  
     30        y = math.pow(max(self.base.data2D.ymax, 
    3031                         math.fabs(self.base.data2D.ymin)), 2) 
    3132        self.qmax = math.sqrt(x + y) 
     
    3334        self.nbins = 20 
    3435        ## Angle of the middle line 
    35         self.theta2 = math.pi/3 
     36        self.theta2 = math.pi / 3 
    3637        ## Absolute value of the Angle between the middle line and any side line 
    37         self.phi = math.pi/12 
     38        self.phi = math.pi / 12 
    3839        ## Middle line 
    39         self.main_line = LineInteractor(self, self.base.subplot, color='blue',  
     40        self.main_line = LineInteractor(self, self.base.subplot, color='blue', 
    4041                                        zorder=zorder, r=self.qmax, 
    41                                            theta= self.theta2) 
     42                                        theta=self.theta2) 
    4243        self.main_line.qmax = self.qmax 
    4344        ## Right Side line 
    4445        self.right_line = SideInteractor(self, self.base.subplot, color='black', 
    45                                           zorder=zorder, r=self.qmax, 
    46                                           phi=-1*self.phi, theta2=self.theta2) 
     46                                         zorder=zorder, r=self.qmax, 
     47                                         phi=-1 * self.phi, theta2=self.theta2) 
    4748        self.right_line.qmax = self.qmax 
    48         ## Left Side line  
     49        ## Left Side line 
    4950        self.left_line = SideInteractor(self, self.base.subplot, color='black', 
    5051                                        zorder=zorder, r=self.qmax, 
    51                                            phi=self.phi, theta2=self.theta2) 
     52                                        phi=self.phi, theta2=self.theta2) 
    5253        self.left_line.qmax = self.qmax 
    53         ## draw the sector                
     54        ## draw the sector 
    5455        self.update() 
    5556        self._post_data() 
     
    6061        """ 
    6162        receive an event containing parameters values to reset the slicer 
    62          
    63         :param event: event of type SlicerParameterEvent with params as  
     63 
     64        :param event: event of type SlicerParameterEvent with params as 
    6465        attribute 
    65          
     66 
    6667        """ 
    6768        wx.PostEvent(self.base.parent, 
     
    7172            self.set_params(event.params) 
    7273            self.base.update() 
    73              
     74 
    7475    def set_layer(self, n): 
    7576        """ 
    7677         Allow adding plot to the same panel 
    77           
     78 
    7879        :param n: the number of layer 
    79          
     80 
    8081        """ 
    8182        self.layernum = n 
    8283        self.update() 
    83          
     84 
    8485    def clear(self): 
    8586        """ 
     
    9293        self.base.connect.clearall() 
    9394        self.base.Unbind(EVT_SLICER_PARS) 
    94          
     95 
    9596    def update(self): 
    9697        """ 
     
    9899        resetting the widgets. 
    99100        """ 
    100         # Update locations   
    101         ## Check if the middle line was dragged and  
    102         #update the picture accordingly      
     101        # Update locations 
     102        ## Check if the middle line was dragged and 
     103        #update the picture accordingly 
    103104        if self.main_line.has_move: 
    104105            self.main_line.update() 
    105             self.right_line.update(delta=-self.left_line.phi/2, 
    106                                     mline=self.main_line.theta) 
    107             self.left_line.update(delta=self.left_line.phi/2, 
     106            self.right_line.update(delta=-self.left_line.phi / 2, 
    108107                                   mline=self.main_line.theta) 
    109         ## Check if the left side has moved and update the slicer accordingly   
     108            self.left_line.update(delta=self.left_line.phi / 2, 
     109                                  mline=self.main_line.theta) 
     110        ## Check if the left side has moved and update the slicer accordingly 
    110111        if self.left_line.has_move: 
    111112            self.main_line.update() 
     
    113114                                  side=True, left=True) 
    114115            self.right_line.update(phi=self.left_line.phi, delta=None, 
    115                                      mline=self.main_line, side=True, 
    116                                      left=False, right=True) 
    117         ## Check if the right side line has moved and  
     116                                   mline=self.main_line, side=True, 
     117                                   left=False, right=True) 
     118        ## Check if the right side line has moved and 
    118119        #update the slicer accordingly 
    119120        if self.right_line.has_move: 
     
    122123                                   side=True, left=False, right=True) 
    123124            self.left_line.update(phi=self.right_line.phi, delta=None, 
    124                                     mline=self.main_line, side=True, left=False) 
    125              
     125                                  mline=self.main_line, side=True, left=False) 
     126 
    126127    def save(self, ev): 
    127128        """ 
     
    137138        """ 
    138139        compute sector averaging of data2D into data1D 
    139          
     140 
    140141        :param nbins: the number of point to plot for the average 1D data 
    141142        """ 
     
    147148        ## Averaging 
    148149        from sas.dataloader.manipulations import SectorQ 
    149         radius = self.qmax  
    150         phimin =  -self.left_line.phi + self.main_line.theta 
     150        radius = self.qmax 
     151        phimin = -self.left_line.phi + self.main_line.theta 
    151152        phimax = self.left_line.phi + self.main_line.theta 
    152153        if nbins == None: 
    153154            nbins = 20 
    154155        sect = SectorQ(r_min=0.0, r_max=radius, 
    155                         phi_min=phimin + math.pi, 
    156                         phi_max=phimax + math.pi, nbins=nbins) 
    157       
     156                       phi_min=phimin + math.pi, 
     157                       phi_max=phimax + math.pi, nbins=nbins) 
     158 
    158159        sector = sect(self.base.data2D) 
    159160        ##Create 1D data resulting from average 
    160         
     161 
    161162        if hasattr(sector, "dxl"): 
    162163            dxl = sector.dxl 
     
    186187        new_plot.id = "SectorQ" + self.base.data2D.name 
    187188        new_plot.is_data = True 
    188         self.base.parent.update_theory(data_id=data.id, \ 
    189                                        theory=new_plot) 
    190         wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, 
    191                                     title="SectorQ" + self.base.data2D.name)) 
    192          
     189        self.base.parent.update_theory(data_id=data.id, theory=new_plot) 
     190        wx.PostEvent(self.base.parent, 
     191                     NewPlotEvent(plot=new_plot, title="SectorQ" + self.base.data2D.name)) 
     192 
    193193    def moveend(self, ev): 
    194194        """ 
    195         Called a dragging motion ends.Get slicer event  
     195        Called a dragging motion ends.Get slicer event 
    196196        """ 
    197197        self.base.thaw_axes() 
     
    202202        ## Send slicer paramers to plotter2D 
    203203        wx.PostEvent(self.base, event) 
    204          
     204 
    205205    def restore(self): 
    206206        """ 
     
    216216        """ 
    217217        pass 
    218          
     218 
    219219    def set_cursor(self, x, y): 
    220220        """ 
    221221        """ 
    222222        pass 
    223          
     223 
    224224    def get_params(self): 
    225225        """ 
    226226        Store a copy of values of parameters of the slicer into a dictionary. 
    227          
     227 
    228228        :return params: the dictionary created 
    229          
     229 
    230230        """ 
    231231        params = {} 
    232         ## Always make sure that the left and the right line are at phi  
     232        ## Always make sure that the left and the right line are at phi 
    233233        ## angle of the middle line 
    234234        if math.fabs(self.left_line.phi) != math.fabs(self.right_line.phi): 
     
    236236            msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 
    237237            raise ValueError, msg 
    238         params["Phi [deg]"] = self.main_line.theta * 180/math.pi 
    239         params["Delta_Phi [deg]"] = math.fabs(self.left_line.phi * 180/math.pi) 
     238        params["Phi [deg]"] = self.main_line.theta * 180 / math.pi 
     239        params["Delta_Phi [deg]"] = math.fabs(self.left_line.phi * 180 / math.pi) 
    240240        params["nbins"] = self.nbins 
    241241        return params 
    242      
     242 
    243243    def set_params(self, params): 
    244244        """ 
    245         Receive a dictionary and reset the slicer with values contained  
     245        Receive a dictionary and reset the slicer with values contained 
    246246        in the values of the dictionary. 
    247          
    248         :param params: a dictionary containing name of slicer parameters and  
     247 
     248        :param params: a dictionary containing name of slicer parameters and 
    249249            values the user assigned to the slicer. 
    250250        """ 
    251         main = params["Phi [deg]"]  * math.pi/180 
    252         phi = math.fabs(params["Delta_Phi [deg]"] * math.pi/180) 
     251        main = params["Phi [deg]"] * math.pi / 180 
     252        phi = math.fabs(params["Delta_Phi [deg]"] * math.pi / 180) 
    253253        self.nbins = int(params["nbins"]) 
    254254        self.main_line.theta = main 
     
    257257        self.right_line.update(phi=phi, delta=None, mline=self.main_line, 
    258258                               side=True, right=True) 
    259         self.left_line.update(phi=phi, delta=None,  
     259        self.left_line.update(phi=phi, delta=None, 
    260260                              mline=self.main_line, side=True) 
    261261        ## post the new corresponding data 
    262262        self._post_data(nbins=self.nbins) 
    263          
     263 
    264264    def freeze_axes(self): 
    265265        """ 
    266266        """ 
    267267        self.base.freeze_axes() 
    268      
     268 
    269269    def thaw_axes(self): 
    270270        """ 
     
    277277        self.base.draw() 
    278278 
    279          
     279 
    280280class SideInteractor(_BaseInteractor): 
    281281    """ 
    282282    Draw an oblique line 
    283      
     283 
    284284    :param phi: the phase between the middle line and one side line 
    285285    :param theta2: the angle between the middle line and x- axis 
    286      
     286 
    287287    """ 
    288288    def __init__(self, base, axes, color='black', zorder=5, r=1.0, 
    289                  phi=math.pi/4, theta2= math.pi/3): 
     289                 phi=math.pi / 4, theta2=math.pi / 3): 
    290290        """ 
    291291        """ 
     
    295295        self.axes = axes 
    296296        ## compute the value of the angle between the current line and 
    297         ## the x-axis   
     297        ## the x-axis 
    298298        self.save_theta = theta2 + phi 
    299299        self.theta = theta2 + phi 
     
    309309        x2 = -1 * self.radius * math.cos(self.theta) 
    310310        y2 = -1 * self.radius * math.sin(self.theta) 
    311         ## defining a new marker  
    312         try: 
    313             self.inner_marker = self.axes.plot([x1/2.5], [y1/2.5], linestyle='', 
    314                                           marker='s', markersize=10, 
    315                                           color=self.color, alpha=0.6, 
    316                                           pickradius=5, label="pick",  
    317                                           # Prefer this to other lines 
    318                                           zorder=zorder, visible=True)[0] 
    319         except: 
    320             self.inner_marker = self.axes.plot([x1/2.5],[y1/2.5], linestyle='', 
    321                                           marker='s', markersize=10, 
    322                                           color=self.color, alpha=0.6, 
    323                                           label="pick", visible=True)[0] 
    324             message  = "\nTHIS PROTOTYPE NEEDS THE LATEST" 
    325             message += " VERSION OF MATPLOTLIB\n Get the SVN version that" 
    326             message += " is at least as recent as June 1, 2007" 
    327             owner = self.base.base.parent 
    328             wx.PostEvent(owner,  
    329                          StatusEvent(status="sectorSlicer: %s" % message)) 
    330          
     311        ## defining a new marker 
     312        self.inner_marker = self.axes.plot([x1 / 2.5], [y1 / 2.5], linestyle='', 
     313                                           marker='s', markersize=10, 
     314                                           color=self.color, alpha=0.6, 
     315                                           pickradius=5, label="pick", 
     316                                           zorder=zorder, visible=True)[0] 
     317 
    331318        ## Defining the current line 
    332319        self.line = self.axes.plot([x1, x2], [y1, y2], 
    333                                       linestyle='-', marker='', 
    334                                       color=self.color, visible=True)[0] 
     320                                   linestyle='-', marker='', 
     321                                   color=self.color, visible=True)[0] 
    335322        ## Flag to differentiate the left line from the right line motion 
    336323        self.left_moving = False 
     
    339326        ## connecting markers and draw the picture 
    340327        self.connect_markers([self.inner_marker, self.line]) 
    341         
     328 
    342329    def set_layer(self, n): 
    343330        """ 
    344331        Allow adding plot to the same panel 
    345           
     332 
    346333        :param n: the number of layer 
    347          
     334 
    348335        """ 
    349336        self.layernum = n 
    350337        self.update() 
    351          
     338 
    352339    def clear(self): 
    353340        """ 
     
    362349            for item in range(len(self.axes.lines)): 
    363350                del self.axes.lines[0] 
    364      
     351 
    365352    def update(self, phi=None, delta=None, mline=None, 
    366                side=False, left= False, right=False): 
     353               side=False, left=False, right=False): 
    367354        """ 
    368355        Draw oblique line 
    369          
     356 
    370357        :param phi: the phase between the middle line and the current line 
    371358        :param delta: phi/2 applied only when the mline was moved 
    372          
     359 
    373360        """ 
    374361        #print "update left or right ", self.has_move 
     
    386373        if side: 
    387374            self.theta = mline.theta + self.phi 
    388                      
    389         if mline != None : 
     375 
     376        if mline != None: 
    390377            if delta != 0: 
    391378                self.theta2 = mline + delta 
     
    400387        x2 = -1 * self.radius * math.cos(theta3) 
    401388        y2 = -1 * self.radius * math.sin(theta3) 
    402         self.inner_marker.set(xdata=[x1/2.5], ydata=[y1/2.5]) 
    403         self.line.set(xdata=[x1, x2], ydata=[y1, y2])   
    404          
     389        self.inner_marker.set(xdata=[x1 / 2.5], ydata=[y1 / 2.5]) 
     390        self.line.set(xdata=[x1, x2], ydata=[y1, y2]) 
     391 
    405392    def save(self, ev): 
    406393        """ 
     
    416403        self.has_move = False 
    417404        self.base.moveend(ev) 
    418              
     405 
    419406    def restore(self): 
    420407        """ 
     
    433420            if  self.theta2 - self.theta <= 0 and self.theta2 > 0: 
    434421                self.restore() 
    435                 return  
     422                return 
    436423            elif self.theta2 < 0 and self.theta < 0 and \ 
    437                 self.theta-self.theta2 >= 0: 
    438                 self.restore() 
    439                 return                              
     424                self.theta - self.theta2 >= 0: 
     425                self.restore() 
     426                return 
    440427            elif  self.theta2 < 0 and self.theta > 0 and \ 
    441                 (self.theta2 + 2 * math.pi - self.theta) >= math.pi/2: 
    442                 #print "my theta", self.theta 
    443                 self.restore() 
    444                 return  
     428                (self.theta2 + 2 * math.pi - self.theta) >= math.pi / 2: 
     429                self.restore() 
     430                return 
    445431            elif  self.theta2 < 0 and self.theta < 0 and \ 
    446                 (self.theta2 - self.theta) >= math.pi/2: 
    447                 #print "my theta", self.theta 
    448                 self.restore() 
    449                 return  
    450             elif self.theta2 > 0 and (self.theta2-self.theta >= math.pi/2 or \ 
    451                 (self.theta2-self.theta >= math.pi/2)): 
    452                 #print "self theta encore" 
    453                 self.restore() 
    454                 return  
     432                (self.theta2 - self.theta) >= math.pi / 2: 
     433                self.restore() 
     434                return 
     435            elif self.theta2 > 0 and (self.theta2 - self.theta >= math.pi / 2 or \ 
     436                (self.theta2 - self.theta >= math.pi / 2)): 
     437                self.restore() 
     438                return 
    455439        else: 
    456             #print "left move" 
    457             if  self.theta < 0 and (self.theta + math.pi*2-self.theta2) <= 0: 
    458                 self.restore() 
    459                 return  
    460             elif self.theta2 < 0 and (self.theta-self.theta2) <= 0: 
    461                 self.restore() 
    462                 return                              
    463             elif  self.theta > 0 and self.theta-self.theta2 <= 0: 
    464                 #print "my theta", self.theta 
    465                 self.restore() 
    466                 return  
    467             elif self.theta-self.theta2 >= math.pi/2 or  \ 
    468                 ((self.theta + math.pi * 2 - self.theta2) >= math.pi/2 and \ 
     440            if  self.theta < 0 and (self.theta + math.pi * 2 - self.theta2) <= 0: 
     441                self.restore() 
     442                return 
     443            elif self.theta2 < 0 and (self.theta - self.theta2) <= 0: 
     444                self.restore() 
     445                return 
     446            elif  self.theta > 0 and self.theta - self.theta2 <= 0: 
     447                self.restore() 
     448                return 
     449            elif self.theta - self.theta2 >= math.pi / 2 or  \ 
     450                ((self.theta + math.pi * 2 - self.theta2) >= math.pi / 2 and \ 
    469451                 self.theta < 0 and self.theta2 > 0): 
    470                 #print "self theta encore" 
    471                 self.restore() 
    472                 return  
    473              
     452                self.restore() 
     453                return 
     454 
    474455        self.phi = math.fabs(self.theta2 - self.theta) 
    475456        if self.phi > math.pi: 
    476457            self.phi = 2 * math.pi - math.fabs(self.theta2 - self.theta) 
    477458        self.base.base.update() 
    478          
     459 
    479460    def set_cursor(self, x, y): 
    480461        """ 
     
    482463        self.move(x, y, None) 
    483464        self.update() 
    484      
     465 
    485466    def get_params(self): 
    486467        """ 
     
    490471        params["theta"] = self.theta 
    491472        return params 
    492      
     473 
    493474    def set_params(self, params): 
    494475        """ 
    495476        """ 
    496         x = params["radius"]  
     477        x = params["radius"] 
    497478        self.set_cursor(x, None) 
    498          
     479 
    499480 
    500481class LineInteractor(_BaseInteractor): 
     
    503484    """ 
    504485    def __init__(self, base, axes, color='black', 
    505                  zorder=5, r=1.0, theta=math.pi/4): 
     486                 zorder=5, r=1.0, theta=math.pi / 4): 
    506487        """ 
    507488        """ 
    508489        _BaseInteractor.__init__(self, base, axes, color=color) 
    509          
     490 
    510491        self.markers = [] 
    511492        self.axes = axes 
    512         self.save_theta = theta  
    513         self.theta= theta 
     493        self.save_theta = theta 
     494        self.theta = theta 
    514495        self.radius = r 
    515496        self.scale = 10.0 
     
    517498        x1 = self.radius * math.cos(self.theta) 
    518499        y1 = self.radius * math.sin(self.theta) 
    519         x2 = -1*self.radius * math.cos(self.theta) 
    520         y2 = -1*self.radius * math.sin(self.theta) 
    521         try: 
    522             # Inner circle marker 
    523             self.inner_marker = self.axes.plot([x1/2.5], [y1/2.5], linestyle='', 
    524                                           marker='s', markersize=10, 
    525                                           color=self.color, alpha=0.6, 
    526                                           pickradius=5, label="pick",  
    527                                           # Prefer this to other lines 
    528                                           zorder=zorder,  
    529                                           visible=True)[0] 
    530         except: 
    531             self.inner_marker = self.axes.plot([x1/2.5], [y1/2.5], linestyle='', 
    532                                           marker='s', markersize=10, 
    533                                           color=self.color, alpha=0.6, 
    534                                           label="pick",  
    535                                           visible=True)[0] 
    536             message  = "\nTHIS PROTOTYPE NEEDS THE LATEST VERSION" 
    537             message += " OF MATPLOTLIB\n Get the SVN version that is at" 
    538             message += " least as recent as June 1, 2007" 
     500        x2 = -1 * self.radius * math.cos(self.theta) 
     501        y2 = -1 * self.radius * math.sin(self.theta) 
     502        # Inner circle marker 
     503        self.inner_marker = self.axes.plot([x1 / 2.5], [y1 / 2.5], linestyle='', 
     504                                           marker='s', markersize=10, 
     505                                           color=self.color, alpha=0.6, 
     506                                           pickradius=5, label="pick", 
     507                                           zorder=zorder, 
     508                                           visible=True)[0] 
    539509        self.line = self.axes.plot([x1, x2], [y1, y2], 
    540                                       linestyle='-', marker='', 
    541                                       color=self.color, visible=True)[0] 
     510                                   linestyle='-', marker='', 
     511                                   color=self.color, visible=True)[0] 
    542512        self.npts = 20 
    543513        self.has_move = False 
     
    550520        self.layernum = n 
    551521        self.update() 
    552          
     522 
    553523    def clear(self): 
    554524        """ 
     
    562532            for item in range(len(self.axes.lines)): 
    563533                del self.axes.lines[0] 
    564    
     534 
    565535    def update(self, theta=None): 
    566536        """ 
    567537        Draw the new roughness on the graph. 
    568538        """ 
    569         
     539 
    570540        if theta != None: 
    571541            self.theta = theta 
     
    574544        x2 = -1 * self.radius * math.cos(self.theta) 
    575545        y2 = -1 * self.radius * math.sin(self.theta) 
    576          
    577         self.inner_marker.set(xdata=[x1/2.5], ydata=[y1/2.5]) 
    578         self.line.set(xdata=[x1, x2], ydata=[y1, y2])   
    579      
     546 
     547        self.inner_marker.set(xdata=[x1 / 2.5], ydata=[y1 / 2.5]) 
     548        self.line.set(xdata=[x1, x2], ydata=[y1, y2]) 
     549 
    580550    def save(self, ev): 
    581551        """ 
     
    583553        can restore on Esc. 
    584554        """ 
    585         self.save_theta= self.theta 
     555        self.save_theta = self.theta 
    586556        self.base.freeze_axes() 
    587557 
     
    591561        self.has_move = False 
    592562        self.base.moveend(ev) 
    593              
     563 
    594564    def restore(self): 
    595565        """ 
     
    605575        self.has_move = True 
    606576        self.base.base.update() 
    607          
     577 
    608578    def set_cursor(self, x, y): 
    609579        """ 
     
    611581        self.move(x, y, None) 
    612582        self.update() 
    613          
     583 
    614584    def get_params(self): 
    615585        """ 
     
    619589        params["theta"] = self.theta 
    620590        return params 
    621      
     591 
    622592    def set_params(self, params): 
    623593        """ 
    624594        """ 
    625         x = params["radius"]  
     595        x = params["radius"] 
    626596        self.set_cursor(x, None) 
    627          
  • src/sas/guiframe/local_perspectives/plotting/SimplePlot.py

    r79492222 rb40ad40  
    33""" 
    44import wx 
    5 from sas.guiframe.local_perspectives.plotting.Plotter2D import ModelPanel2D \ 
    6                     as PlotPanel 
     5from sas.guiframe.local_perspectives.plotting.Plotter2D import ModelPanel2D as PlotPanel 
    76from sas.plottools.toolbar import NavigationToolBar 
    87from sas.plottools.plottables import Graph 
    98from sas.guiframe.utils import PanelMenu 
    10  
    11 class SimplePlotPanel(PlotPanel):    
     9from sas.guiframe.events import StatusEvent 
     10 
     11class SimplePlotPanel(PlotPanel): 
    1212    """ 
    1313    PlotPanel for 1d and 2d 
    14     """  
     14    """ 
    1515    _window_caption = 'Simple Plot' 
    16     def __init__(self, parent, id=-1, color = None, 
     16    def __init__(self, parent, id=-1, color=None, 
    1717                 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 
    1818        """ 
     
    2222 
    2323        self.SetColor(wx.WHITE) 
    24          
     24 
    2525        self.toolbar = NavigationToolBar(parent=self, canvas=self.canvas) 
    2626        self.toolbar.Show(False) 
    2727        self.scale = parent.scale 
    2828        self.window_caption = self._window_caption 
    29              
     29 
    3030    def draw(self): 
    3131        """ 
     
    3434        self.canvas.set_resizing(self.resizing) 
    3535        self.canvas.draw() 
    36          
     36 
    3737    def add_toolbar(self): 
    3838        """ 
    3939        """ 
    40         pass    
    41       
     40        pass 
     41 
    4242    def onContextMenu(self, event): 
    4343        """ 
    4444        2D plot context menu 
    45          
     45 
    4646        :param event: wx context event 
    47          
     47 
    4848        """ 
    4949        slicerpop = PanelMenu() 
    5050        slicerpop.set_plots(self.plots) 
    5151        slicerpop.set_graph(self.graph) 
    52               
    53         id = wx.NewId() 
    54         slicerpop.Append(id, '&Save Image') 
    55         wx.EVT_MENU(self, id, self.onSaveImage) 
    56          
    57         id = wx.NewId() 
    58         slicerpop.Append(id,'&Print Image', 'Print image') 
    59         wx.EVT_MENU(self, id, self.onPrint) 
    60          
    61         id = wx.NewId() 
    62         slicerpop.Append(id,'&Print Preview', 'Print preview') 
    63         wx.EVT_MENU(self, id, self.onPrinterPreview) 
    64  
    65         id = wx.NewId() 
    66         slicerpop.Append(id, '&Copy to Clipboard', 'Copy to the clipboard') 
    67         wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 
     52 
     53        wx_id = wx.NewId() 
     54        slicerpop.Append(wx_id, '&Save Image') 
     55        wx.EVT_MENU(self, wx_id, self.onSaveImage) 
     56 
     57        wx_id = wx.NewId() 
     58        slicerpop.Append(wx_id, '&Print Image', 'Print image') 
     59        wx.EVT_MENU(self, wx_id, self.onPrint) 
     60 
     61        wx_id = wx.NewId() 
     62        slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 
     63        wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 
     64 
     65        wx_id = wx.NewId() 
     66        slicerpop.Append(wx_id, '&Copy to Clipboard', 'Copy to the clipboard') 
     67        wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 
    6868 
    6969        if self.dimension != 3: 
    7070            slicerpop.AppendSeparator() 
    71             id = wx.NewId() 
    72             slicerpop.Append(id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 
    73             wx.EVT_MENU(self, id, self.on_grid_onoff) 
     71            wx_id = wx.NewId() 
     72            slicerpop.Append(wx_id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 
     73            wx.EVT_MENU(self, wx_id, self.on_grid_onoff) 
    7474 
    7575        if self.data.__class__.__name__ == 'Data1D': 
    7676            slicerpop.AppendSeparator() 
    77             id = wx.NewId() 
    78             slicerpop.Append(id, '&Change Scale') 
    79             wx.EVT_MENU(self, id, self._onProperties)         
     77            wx_id = wx.NewId() 
     78            slicerpop.Append(wx_id, '&Change Scale') 
     79            wx.EVT_MENU(self, wx_id, self._onProperties) 
    8080        elif self.data2D.__class__.__name__ == 'Data2D': 
    8181            slicerpop.AppendSeparator() 
    82             id = wx.NewId() 
    83             slicerpop.Append(id, '&Toggle Linear/Log Scale') 
    84             wx.EVT_MENU(self, id, self._onToggleScale)  
    85                  
     82            wx_id = wx.NewId() 
     83            slicerpop.Append(wx_id, '&Toggle Linear/Log Scale') 
     84            wx.EVT_MENU(self, wx_id, self._onToggleScale) 
     85 
    8686        try: 
    8787            pos_evt = event.GetPosition() 
     
    9292        self.PopupMenu(slicerpop, pos) 
    9393        if self.scale != None: 
    94             self.parent.scale2d = self.scale  
    95      
     94            self.parent.scale2d = self.scale 
     95 
    9696    def on_grid_onoff(self, event): 
    9797        """ 
     
    9999        """ 
    100100        switch = (not self.grid_on) 
    101         self.onGridOnOff(switch)  
    102                  
     101        self.onGridOnOff(switch) 
     102 
    103103    def onLeftDown(self, event): 
    104104        """ 
    105105        left button down and ready to drag 
    106          
     106 
    107107        """ 
    108108        # Check that the LEFT button was pressed 
     
    120120                    wx.PostEvent(self.parent, StatusEvent(status=self.position)) 
    121121                except: 
    122                     self.position = None     
    123               
    124     def _OnReSize(self, event):    
     122                    self.position = None 
     123 
     124    def _OnReSize(self, event): 
    125125        """ 
    126126        On response of the resize of a panel, set axes_visiable False 
     
    134134 
    135135        # Ready for another event 
    136         # Do not remove this Skip.  
     136        # Do not remove this Skip. 
    137137        # Otherwise it will get runtime error on wx>=2.9. 
    138         event.Skip()  
     138        event.Skip() 
    139139        # set the resizing flag 
    140140        self.canvas.set_resizing(self.resizing) 
     
    143143            self.size, _ = self.GetClientSizeTuple() 
    144144        self.SetSizer(self.sizer) 
    145          
     145 
    146146    def on_set_focus(self, event): 
    147147        """ 
     
    149149        """ 
    150150        pass 
    151          
     151 
    152152    def on_kill_focus(self, event): 
    153153        """ 
     
    155155        """ 
    156156        pass 
    157      
     157 
    158158    def show_plot(self, plot): 
    159159        """ 
     
    182182        self.graph.yaxis(_yaxis, _yunit) 
    183183        self.xaxis(_xaxis, _xunit) 
    184         self.yaxis(_yaxis, _yunit)  
     184        self.yaxis(_yaxis, _yunit) 
    185185        self.set_xscale(self.xscale) 
    186         self.set_yscale(self.yscale)    
    187         self.graph.render(self)     
    188                    
     186        self.set_yscale(self.yscale) 
     187        self.graph.render(self) 
     188 
    189189class PlotFrame(wx.Frame): 
    190190    """ 
    191191    Frame for simple plot 
    192192    """ 
    193     def __init__(self, parent, id, title, scale='log_{10}',  
    194                  size=wx.Size(550, 470)):  
     193    def __init__(self, parent, id, title, scale='log_{10}', 
     194                 size=wx.Size(550, 470)): 
    195195        """ 
    196196        comment 
     
    199199        # Initialize the Frame object 
    200200        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size) 
    201          
     201 
    202202        # Panel for 1D plot 
    203203        self.parent = parent 
     
    214214        """ 
    215215        tsize = (13, 13) 
    216         save_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_TOOLBAR, 
    217                                             tsize) 
    218         quit_bmp = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR,  
    219                                            tsize) 
    220         print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR,  
    221                                            tsize) 
    222         preview_bmp = wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_TOOLBAR,  
    223                                            tsize) 
    224         copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR,  
    225                                            tsize) 
     216        save_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_TOOLBAR, tsize) 
     217        quit_bmp = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, tsize) 
     218        print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR, tsize) 
     219        preview_bmp = wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_TOOLBAR, tsize) 
     220        copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, tsize) 
    226221        menu_bar = wx.MenuBar() 
    227          
    228         menu = wx.Menu()         
     222 
     223        menu = wx.Menu() 
    229224        id = wx.NewId() 
    230225        item = wx.MenuItem(menu, id, "&Save Image") 
     
    244239        menu.AppendItem(item) 
    245240        wx.EVT_MENU(self, id, self.on_print_preview) 
    246          
     241 
    247242        menu.AppendSeparator() 
    248243        id = wx.NewId() 
     
    253248        menu_bar.Append(menu, "&File") 
    254249        wx.EVT_MENU(self, id, self.on_close) 
    255          
     250 
    256251        menu_edit = wx.Menu() 
    257252        id = wx.NewId() 
     
    260255        menu_edit.AppendItem(item) 
    261256        wx.EVT_MENU(self, id, self.on_copy_image) 
    262          
     257 
    263258        menu_bar.Append(menu_edit, "&Edit") 
    264259        self.menu_bar = menu_bar 
     
    269264        un focusing 
    270265        """ 
    271         pass     
    272      
     266        pass 
     267 
    273268    def add_plot(self, plot): 
    274269        """ 
     
    278273        plotpanel.scale = self.scale 
    279274        plotpanel.show_plot(plot) 
    280          
     275 
    281276    def set_schedule_full_draw(self, panel, func): 
    282277        """ 
    283278        """ 
    284279        self.plotpanel.resizing = False 
    285      
     280 
    286281    def im_show(self, img): 
    287282        """ 
     
    290285        """ 
    291286        self.plotpanel.subplot.imshow(img) 
    292          
    293     def set_schedule(self, schedule=False):  
     287 
     288    def set_schedule(self, schedule=False): 
    294289        """ 
    295290        """ 
    296291        #Not implemented 
    297      
     292 
    298293    def disable_app_menu(self, panel): 
    299294        """ 
    300295        """ 
    301         #Not implemented  
    302      
    303     def get_current_context_menu(self, plotpanel):  
    304         """ 
    305         """ 
    306296        #Not implemented 
    307      
     297 
     298    def get_current_context_menu(self, plotpanel): 
     299        """ 
     300        """ 
     301        #Not implemented 
     302 
    308303    def on_save_file(self, event): 
    309304        """ 
     
    317312        """ 
    318313        self.plotpanel.onPrint(event) 
    319      
     314 
    320315    def on_print_preview(self, event): 
    321316        """ 
     
    329324        """ 
    330325        self.plotpanel.OnCopyFigureMenu(event) 
    331              
     326 
    332327    def on_close(self, event): 
    333328        """ 
    334         On Close  
     329        On Close 
    335330        """ 
    336331        try: 
     
    339334        except: 
    340335            self.Destroy() 
    341                            
     336 
  • src/sas/guiframe/local_perspectives/plotting/SlicerParameters.py

    r79492222 rb40ad40  
    1212class SlicerParameterPanel(wx.Dialog): 
    1313    """ 
    14     Panel class to show the slicer parameters  
     14    Panel class to show the slicer parameters 
    1515    """ 
    1616    #TODO: show units 
    1717    #TODO: order parameters properly 
    18      
     18 
    1919    def __init__(self, parent, *args, **kwargs): 
    20         wx.Dialog.__init__(self, parent, *args, **kwargs) 
    2120        """ 
    22         Dialog window that allow to edit parameters slicer  
     21        Dialog window that allow to edit parameters slicer 
    2322        by entering new values 
    2423        """ 
     24        wx.Dialog.__init__(self, parent, *args, **kwargs) 
    2525        self.params = {} 
    2626        self.parent = parent 
     
    3333        title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) 
    3434        self.bck.Add(title, (0, 0), (1, 2), 
    35                      flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=15) 
     35                     flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
    3636        # Bindings 
    3737        self.parent.Bind(EVT_SLICER, self.onEVT_SLICER) 
     
    4242        Process EVT_SLICER events 
    4343        When the slicer changes, update the panel 
    44          
     44 
    4545        :param event: EVT_SLICER event 
    4646        """ 
     
    5050        else: 
    5151            self.set_slicer(event.type, event.params) 
    52          
     52 
    5353    def set_slicer(self, type, params): 
    5454        """ 
    5555        Rebuild the panel 
    5656        """ 
    57         self.bck.Clear(True)   
    58         self.type = type   
     57        self.bck.Clear(True) 
     58        self.type = type 
    5959        if type == None: 
    6060            label = "Right-click on 2D plot for slicer options" 
    6161            title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) 
    62             self.bck.Add(title, (0, 0), (1, 2),  
    63                          flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=15) 
     62            self.bck.Add(title, (0, 0), (1, 2), 
     63                         flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
    6464        else: 
    65             title = wx.StaticText(self, -1,  
     65            title = wx.StaticText(self, -1, 
    6666                                  "Slicer Parameters", style=wx.ALIGN_LEFT) 
    6767            self.bck.Add(title, (0, 0), (1, 2), 
    68                          flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=15) 
     68                         flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
    6969            ix = 0 
    7070            iy = 0 
     
    7777                if not item in ["count", "errors"]: 
    7878                    text = wx.StaticText(self, -1, item, style=wx.ALIGN_LEFT) 
    79                     self.bck.Add(text, (iy, ix), (1, 1),  
    80                                  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     79                    self.bck.Add(text, (iy, ix), (1, 1), 
     80                                 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    8181                    ctl = wx.TextCtrl(self, -1, size=(80, 20), 
    8282                                      style=wx.TE_PROCESS_ENTER) 
     
    8888                    self.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter) 
    8989                    self.parameters.append([item, ctl]) 
    90                     self.bck.Add(ctl, (iy, ix), (1, 1),  
    91                                  wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     90                    self.bck.Add(ctl, (iy, ix), (1, 1), 
     91                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    9292                    ix = 3 
    93                     self.bck.Add((20, 20), (iy, ix), (1, 1),  
    94                                  wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     93                    self.bck.Add((20, 20), (iy, ix), (1, 1), 
     94                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    9595                else: 
    96                     text = wx.StaticText(self, -1, item + " : ",  
     96                    text = wx.StaticText(self, -1, item + " : ", 
    9797                                         style=wx.ALIGN_LEFT) 
    98                     self.bck.Add(text, (iy, ix), (1, 1),  
    99                                  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    100                     ctl = wx.StaticText(self, -1,  
    101                                     format_number(str(params[item])),  
    102                                     style=wx.ALIGN_LEFT) 
     98                    self.bck.Add(text, (iy, ix), (1, 1), 
     99                                 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
     100                    ctl = wx.StaticText(self, -1, 
     101                                        format_number(str(params[item])), 
     102                                        style=wx.ALIGN_LEFT) 
    103103                    ix = 1 
    104                     self.bck.Add(ctl, (iy, ix), (1, 1),  
    105                                  wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     104                    self.bck.Add(ctl, (iy, ix), (1, 1), 
     105                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    106106            iy += 1 
    107107            ix = 1 
    108             self.bck.Add((20, 20), (iy, ix), (1, 1),  
    109                          wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     108            self.bck.Add((20, 20), (iy, ix), (1, 1), 
     109                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    110110        self.bck.Layout() 
    111111        self.bck.Fit(self) 
     
    119119        evt.Skip() 
    120120        if evt.type == "UPDATE": 
    121             for item in self.parameters:               
     121            for item in self.parameters: 
    122122                if item[0] in evt.params: 
    123123                    item[1].SetValue("%-5.3g" % evt.params[item[0]]) 
    124124                    item[1].Refresh() 
    125          
    126     def onTextEnter(self, evt):  
     125 
     126    def onTextEnter(self, evt): 
    127127        """ 
    128128        Parameters have changed 
    129         """  
     129        """ 
    130130        params = {} 
    131131        has_error = False 
     
    133133            try: 
    134134                params[item[0]] = float(item[1].GetValue()) 
    135                 item[1].SetBackgroundColour( 
    136                         wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 
     135                item[1].SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 
    137136                item[1].Refresh() 
    138137            except: 
     
    146145            event = SlicerParameterEvent(type=self.type, params=params) 
    147146            wx.PostEvent(self.parent, event) 
    148          
  • src/sas/guiframe/local_perspectives/plotting/slicerpanel.py

    r27ab091 rb40ad40  
    1  
    2  
    31import wx 
    42import wx.lib.newevent 
     
    1311class SlicerPanel(wx.Panel, PanelBase): 
    1412    """ 
    15     Panel class to show the slicer parameters  
     13    Panel class to show the slicer parameters 
    1614    """ 
    1715    #TODO: show units 
     
    2220    window_caption = "Slicer Panel" 
    2321    CENTER_PANE = False 
    24      
     22 
    2523    def __init__(self, parent, id=-1, type=None, base=None, 
    26                 params=None, *args, **kwargs): 
     24                 params=None, *args, **kwargs): 
    2725        wx.Panel.__init__(self, parent, id, *args, **kwargs) 
    2826        PanelBase.__init__(self) 
    29         ##  Initialization of the class      
     27        ##  Initialization of the class 
    3028        self.base = base 
    3129        if params is None: 
     
    3937        self.bck = wx.GridBagSizer(5, 5) 
    4038        self.SetSizer(self.bck) 
    41         if type == None and params == None:   
    42             label = "Right-click on 2D plot for slicer options"   
     39        if type == None and params == None: 
     40            label = "Right-click on 2D plot for slicer options" 
    4341            title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) 
    44             self.bck.Add(title, (0, 0), (1, 2),  
    45                          flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=15) 
     42            self.bck.Add(title, (0, 0), (1, 2), 
     43                         flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
    4644        else: 
    4745            self.set_slicer(type, params) 
     
    5452        Process EVT_SLICER events 
    5553        When the slicer changes, update the panel 
    56          
     54 
    5755        :param event: EVT_SLICER event 
    58          
     56 
    5957        """ 
    6058        event.Skip() 
    6159        if event.obj_class == None: 
    62             self.set_slicer(None, None)  
     60            self.set_slicer(None, None) 
    6361        else: 
    6462            self.set_slicer(event.type, event.params) 
    65          
     63 
    6664    def set_slicer(self, type, params): 
    6765        """ 
    6866        Rebuild the panel 
    6967        """ 
    70         self.bck.Clear(True)   
    71         self.type = type   
     68        self.bck.Clear(True) 
     69        self.type = type 
    7270        if type == None: 
    7371            label = "Right-click on 2D plot for slicer options" 
    7472            title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) 
    75             self.bck.Add(title, (0, 0), (1, 2),  
    76                          flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=15) 
     73            self.bck.Add(title, (0, 0), (1, 2), 
     74                         flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
    7775        else: 
    7876            title_text = str(type) + "Parameters" 
    79             title = wx.StaticText(self, -1, title_text,  
     77            title = wx.StaticText(self, -1, title_text, 
    8078                                  style=wx.ALIGN_LEFT) 
    81             self.bck.Add(title, (0, 0), (1, 2),  
    82                          flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=15) 
     79            self.bck.Add(title, (0, 0), (1, 2), 
     80                         flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
    8381            n = 1 
    8482            self.parameters = [] 
     
    8684            keys.sort() 
    8785            for item in keys: 
    88                 if not item.lower() in ["num_points", "avg", "avg_error", "sum", 
    89                                          "sum_error"]: 
     86                if not item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 
    9087                    n += 1 
    9188                    text = wx.StaticText(self, -1, item, style=wx.ALIGN_LEFT) 
    92                     self.bck.Add(text, (n-1, 0),  
    93                             flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=15) 
    94                     ctl = wx.TextCtrl(self, -1, size=(80, 20),  
     89                    self.bck.Add(text, (n - 1, 0), 
     90                                 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
     91                    ctl = wx.TextCtrl(self, -1, size=(80, 20), 
    9592                                      style=wx.TE_PROCESS_ENTER) 
    9693                    hint_msg = "Modify the value of %s to change " % item 
     
    10299                    ctl.Bind(wx.EVT_KILL_FOCUS, self.onTextEnter) 
    103100                    self.parameters.append([item, ctl]) 
    104                     self.bck.Add(ctl, (n-1, 1), flag=wx.TOP|wx.BOTTOM, border=0) 
     101                    self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 
    105102            for item in keys: 
    106                 if  item.lower() in ["num_points", "avg", "avg_error", "sum", 
    107                                       "sum_error"]: 
     103                if  item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 
    108104                    n += 1 
    109                     text = wx.StaticText(self, -1, item + ": ",  
    110                                          style=wx.ALIGN_LEFT) 
    111                     self.bck.Add(text, (n-1, 0),  
    112                                  flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL,  
     105                    text = wx.StaticText(self, -1, item + ": ", style=wx.ALIGN_LEFT) 
     106                    self.bck.Add(text, (n - 1, 0), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 
    113107                                 border=15) 
    114                     ctl = wx.StaticText(self, -1,  
     108                    ctl = wx.StaticText(self, -1, 
    115109                                        str(format_number(params[item])), 
    116110                                        style=wx.ALIGN_LEFT) 
    117111                    ctl.SetToolTipString("Result %s" % item) 
    118                     self.bck.Add(ctl, (n-1, 1), flag=wx.TOP|wx.BOTTOM, border=0)        
     112                    self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 
    119113        self.bck.Layout() 
    120         #self.bck.Fit(self) 
    121114        self.Layout() 
    122115        psizer = self.parent.GetSizer() 
    123116        if psizer != None: 
    124117            psizer.Layout() 
    125          
     118 
    126119    def onSetFocus(self, evt): 
    127120        """ 
     
    134127        wx.CallAfter(widget.SetSelection, -1, -1) 
    135128        return 
    136      
     129 
    137130    def onParamChange(self, evt): 
    138131        """ 
    139132        Receive and event and reset the text field contained in self.parameters 
    140              
     133 
    141134        """ 
    142135        evt.Skip() 
    143         for item in self.parameters:               
     136        for item in self.parameters: 
    144137            if item[0] in evt.params: 
    145138                item[1].SetValue(format_number(evt.params[item[0]])) 
    146139                item[1].Refresh() 
    147     
    148     def onTextEnter(self, evt):  
     140 
     141    def onTextEnter(self, evt): 
    149142        """ 
    150143        Parameters have changed 
     
    156149            try: 
    157150                params[item[0]] = float(item[1].GetValue()) 
    158                 item[1].SetBackgroundColour( 
    159                         wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 
     151                item[1].SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 
    160152                item[1].Refresh() 
    161153            except: 
     
    163155                item[1].SetBackgroundColour("pink") 
    164156                item[1].Refresh() 
    165              
     157 
    166158        if has_error == False: 
    167159            # Post parameter event 
     
    175167        """ 
    176168        ID = self.uid 
    177         self.parent.delete_panel(ID)             
     169        self.parent.delete_panel(ID) 
    178170        self.frame.Destroy() 
Note: See TracChangeset for help on using the changeset viewer.