Changeset 090e07e in sasview


Ignore:
Timestamp:
Mar 5, 2015 2:06:18 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:
c039589
Parents:
7d56795
Message:

pylint fixes

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

Legend:

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

    r79492222 r090e07e  
    11 
    22################################################################################ 
    3 #This software was developed by the University of Tennessee as part of the 
    4 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    5 #project funded by the US National Science Foundation.  
     3# This software was developed by the University of Tennessee as part of the 
     4# Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5# project funded by the US National Science Foundation. 
    66# 
    7 #See the license text in license.txt 
     7# See the license text in license.txt 
    88# 
    9 #copyright 2008, University of Tennessee 
     9# copyright 2008, University of Tennessee 
    1010################################################################################ 
    1111 
     
    1515import math 
    1616import numpy 
    17  
     17import logging 
    1818from sas.plottools.PlotPanel import PlotPanel 
    19 from sas.guiframe.events import StatusEvent  
     19from sas.guiframe.events import StatusEvent 
    2020from sas.guiframe.events import PanelOnFocusEvent 
    2121from sas.guiframe.utils import PanelMenu 
     
    4242    Plot panel for use with the GUI manager 
    4343    """ 
    44      
     44 
    4545    ## Internal name for the AUI manager 
    4646    window_name = "plotpanel" 
     
    5252    ## Group ID 
    5353    group_id = None 
    54      
    55     def __init__(self, parent, id=-1, color = None, 
     54 
     55    def __init__(self, parent, id=-1, color=None, 
    5656                 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 
    5757        PlotPanel.__init__(self, parent, id=id, style=style, **kwargs) 
     
    6464        self.plots = {} 
    6565        self.frame = None 
    66         #context menu 
     66        # context menu 
    6767        self._slicerpop = None 
    68          
     68 
    6969        self._available_data = [] 
    7070        self._menu_add_ids = [] 
     
    7575        self.is_xtick = False 
    7676        self.is_ytick = False 
    77        
     77 
    7878        self.hide_menu = None 
    7979        ## Unique ID (from gui_manager) 
     
    8181        self.x_size = None 
    8282        ## Default locations 
    83         #self._default_save_location = os.getcwd()  
    84         self.size = None   
    85         self.vl_ind = 0      
    86         ## Graph         
    87         #self.graph = Graph() 
     83        # self._default_save_location = os.getcwd() 
     84        self.size = None 
     85        self.vl_ind = 0 
     86        ## Graph 
     87        # self.graph = Graph() 
    8888        self.graph.xaxis("\\rm{Q}", 'A^{-1}') 
    8989        self.graph.yaxis("\\rm{Intensity} ", "cm^{-1}") 
    9090        self.graph.render(self) 
    9191        self.cursor_id = None 
    92          
     92 
    9393        # In resizing event 
    9494        self.resizing = False 
    9595        self.canvas.set_resizing(self.resizing) 
    9696        self.Bind(wx.EVT_SIZE, self._OnReSize) 
    97         self._add_more_tool() 
    9897        self.parent.SetFocus() 
    99          
    100          
     98 
     99 
    101100    def get_symbol_label(self): 
    102101        """ 
     
    139138        _labels['Step'] = i 
    140139        return _labels 
    141      
     140 
    142141    def get_color_label(self): 
    143142        """ 
     
    161160        return _labels 
    162161 
    163      
     162 
    164163    def set_data(self, list=None): 
    165164        """ 
    166165        """ 
    167166        pass 
    168      
     167 
    169168    def _reset(self): 
    170169        """ 
    171170        Resets internal data and graph 
    172         """     
     171        """ 
    173172        self.graph.reset() 
    174         self.plots      = {} 
     173        self.plots = {} 
    175174        self.is_zoomed = False 
    176          
    177     def _OnReSize(self, event):    
     175 
     176    def _OnReSize(self, event): 
    178177        """ 
    179178        On response of the resize of a panel, set axes_visiable False 
     
    196195        # Ready for another event 
    197196        # Do not remove this Skip. Otherwise it will get runtime error on wx>=2.9. 
    198         event.Skip()  
     197        event.Skip() 
    199198        # set the resizing flag 
    200199        self.resizing = True 
     
    205204            self.size, _ = self.GetClientSizeTuple() 
    206205        self.SetSizer(self.sizer) 
    207         wx.CallAfter(self.parent.disable_app_menu,self) 
    208          
     206        wx.CallAfter(self.parent.disable_app_menu, self) 
     207 
    209208    def on_plot_qrange(self, event=None): 
    210209        """ 
     
    213212        if event == None: 
    214213            return 
    215         event.Skip()  
     214        event.Skip() 
    216215        active_ctrl = event.active 
    217216        if active_ctrl == None: 
     
    225224                self.ly = [] 
    226225                for ind_ly in range(len(colors)): 
    227                     self.ly.append(self.subplot.axvline(color=colors[ind_ly],  
     226                    self.ly.append(self.subplot.axvline(color=colors[ind_ly], 
    228227                                                        lw=2.5, alpha=0.7)) 
    229                     self.ly[ind_ly].set_rasterized(True)       
     228                    self.ly[ind_ly].set_rasterized(True) 
    230229            try: 
    231230                # Display x,y in the status bar if possible 
     
    235234                    wx.PostEvent(self.parent, StatusEvent(status=position)) 
    236235            except: 
    237                 pass 
     236                logging.error(sys.exc_value) 
    238237            if not event.leftdown: 
    239                 # text event  
     238                # text event 
    240239                try: 
    241240                    is_moved = False 
     
    247246                            is_moved = True 
    248247                    if is_moved: 
    249                         self.canvas.draw()  
     248                        self.canvas.draw() 
    250249                except: 
    251                     pass 
    252                 event.Skip()  
     250                    logging.error(sys.exc_value) 
     251                event.Skip() 
    253252                return 
    254253            self.q_ctrl = ctrl 
    255             try: 
    256                 pos_x_min = float(self.q_ctrl[0].GetValue()) 
    257             except: 
    258                 pos_x_min = xmin 
    259             try: 
    260                 pos_x_max = float(self.q_ctrl[1].GetValue()) 
    261             except: 
    262                 pos_x_max = xmax 
     254            pos_x_min = float(self.q_ctrl[0].GetValue()) 
     255            pos_x_max = float(self.q_ctrl[1].GetValue()) 
    263256            pos_x = [pos_x_min, pos_x_max] 
    264257            for ind_ly in range(len(colors)): 
     
    268261        else: 
    269262            self.q_ctrl = None 
    270      
     263 
    271264    def get_data_xy_vals(self, xval): 
    272265        """ 
     
    283276        except: 
    284277            return None 
    285             
     278 
    286279    def _find_nearest(self, array, value): 
    287280        """ 
     
    292285        """ 
    293286        idx = (numpy.abs(array - value)).argmin() 
    294         return int(idx)#array.flat[idx] 
    295      
     287        return int(idx)  # array.flat[idx] 
     288 
    296289    def _check_line_positions(self, pos_x=None, nop=None): 
    297290        """ 
     
    316309                self.q_ctrl[0].SetValue(str(pos_x)) 
    317310                self.q_ctrl[1].SetBackgroundColour('pink') 
    318                  
     311 
    319312    def _get_cusor_lines(self, event): 
    320313        """ 
    321314        Revmove or switch cursor line if drawn 
    322315        :Param event: LeftClick mouse event 
    323         """   
     316        """ 
    324317        ax = event.inaxes 
    325318        if hasattr(event, "action"): 
     
    330323                self.canvas.draw() 
    331324                self.q_ctrl = None 
    332                 return  
     325                return 
    333326        if self.ly != None and event.xdata != None: 
    334327            # Selecting a new line if cursor lines are displayed already 
     
    339332                self.vl_ind = 1 
    340333            else: 
    341                 self.vl_ind = 0  
    342                       
     334                self.vl_ind = 0 
     335 
    343336    def cusor_line(self, event): 
    344337        """ 
     
    347340        if self.q_ctrl == None: 
    348341            return 
    349         #release a q range vline 
     342        # release a q range vline 
    350343        if self.ly != None and not self.leftdown: 
    351344            for ly in self.ly: 
     
    358351        end_drag = event.action != 'drag' and event.xdata != None 
    359352        nop = len(self.plots) 
    360         pos_x, pos_y = float(event.xdata), float(event.ydata) 
     353        pos_x, _ = float(event.xdata), float(event.ydata) 
    361354        try: 
    362355            ly = self.ly 
     
    370363            vl_ind = self.vl_ind 
    371364            x_data = self.plots[self.cursor_id].x 
    372             y_data = self.plots[self.cursor_id].y 
    373365            xmin = x_data.min() 
    374366            xmax = x_data.max() 
    375367            indx = self._find_nearest(x_data, pos_x) 
    376             #pos_x = self._find_nearest(x_data, pos_x) 
    377             #indx = int(numpy.searchsorted(x_data, [pos_x])[0]) 
    378368            # Need to hold LeftButton to drag 
    379369            if end_drag: 
    380370                if event.button: 
    381371                    self._check_line_positions(pos_x, nop) 
    382                 return    
     372                return 
    383373            if indx >= len(x_data): 
    384374                indx = len(x_data) - 1 
    385375            pos_x = x_data[indx] 
    386             pos_y = y_data[indx] 
    387376            if xmin == ly1x: 
    388377                vl_ind = 1 
     
    399388            self.q_ctrl[vl_ind].SetValue(str(pos_x)) 
    400389        except: 
    401             pass 
    402                 
     390            logging.error(sys.exc_value) 
     391 
    403392    def set_resizing(self, resizing=False): 
    404393        """ 
     
    406395        """ 
    407396        self.resizing = resizing 
    408         #self.canvas.set_resizing(resizing) 
    409      
    410     def schedule_full_draw(self, func='append'):     
     397        # self.canvas.set_resizing(resizing) 
     398 
     399    def schedule_full_draw(self, func='append'): 
    411400        """ 
    412401        Put self in schedule to full redraw list 
     
    414403        # append/del this panel in the schedule list 
    415404        self.parent.set_schedule_full_draw(self, func) 
    416          
    417405 
    418406    def remove_data_by_id(self, id): 
     
    421409        """ 
    422410        if id in self.plots.keys(): 
    423             data =  self.plots[id] 
     411            data = self.plots[id] 
    424412            self.graph.delete(data) 
    425413            data_manager = self._manager.parent.get_data_manager() 
    426414            data_list, theory_list = data_manager.get_by_id(id_list=[id]) 
    427              
     415 
    428416            if id in data_list.keys(): 
    429417                data = data_list[id] 
    430418            if id in theory_list.keys(): 
    431419                data = theory_list[id] 
    432                  
     420 
    433421            del self.plots[id] 
    434422            self.graph.render(self) 
    435             self.subplot.figure.canvas.draw_idle()     
     423            self.subplot.figure.canvas.draw_idle() 
    436424            if len(self.graph.plottables) == 0: 
    437                 #onRemove: graph is empty must be the panel must be destroyed 
     425                # onRemove: graph is empty must be the panel must be destroyed 
    438426                self.parent.delete_panel(self.uid) 
    439          
     427 
    440428    def plot_data(self, data): 
    441429        """ 
    442430        Data is ready to be displayed 
    443          
     431 
    444432        :param event: data event 
    445433        """ 
     
    448436        plot_keys = self.plots.keys() 
    449437        if data.id in plot_keys: 
    450             #Recover panel prop.s 
     438            # Recover panel prop.s 
    451439            xlo, xhi = self.subplot.get_xlim() 
    452440            ylo, yhi = self.subplot.get_ylim() 
     
    466454                self._onEVT_FUNC_PROPERTY() 
    467455            except Exception, exc: 
    468                 wx.PostEvent(self.parent, StatusEvent(status=\ 
    469                     "Plotting Error: %s"% str(exc), info="error")) 
     456                wx.PostEvent(self.parent, 
     457                             StatusEvent(status="Plotting Error: %s" % str(exc), info="error")) 
    470458            if self.is_zoomed: 
    471459                # Recover the x,y limits 
    472                 self.subplot.set_xlim((xlo, xhi))      
    473                 self.subplot.set_ylim((ylo, yhi))   
     460                self.subplot.set_xlim((xlo, xhi)) 
     461                self.subplot.set_ylim((ylo, yhi)) 
    474462        else: 
    475463            self.plots[data.id] = data 
    476             self.graph.add(self.plots[data.id])  
     464            self.graph.add(self.plots[data.id]) 
    477465            data.zorder = len(plot_keys) 
    478466            ## Set the view scale for all plots 
     
    482470                    # MAC: forcing to plot 2D avg 
    483471                    self.canvas._onDrawIdle() 
    484             except Exception,exc: 
     472            except Exception, exc: 
    485473                wx.PostEvent(self.parent, StatusEvent(status=\ 
    486                     "Plotting Error: %s"% str(exc), info="error")) 
     474                    "Plotting Error: %s" % str(exc), info="error")) 
    487475            self.toolbar.update() 
    488476            self.is_zoomed = False 
    489              
     477 
    490478    def draw_plot(self): 
    491479        """ 
    492480        Draw plot 
    493481        """ 
    494         self.draw()   
    495  
    496     def onLeftDown(self,event):  
    497         """  
     482        self.draw() 
     483 
     484    def onLeftDown(self, event): 
     485        """ 
    498486        left button down and ready to drag 
    499487        Display the position of the mouse on the statusbar 
    500488        """ 
    501         #self.parent.set_plot_unfocus()  
     489        # self.parent.set_plot_unfocus() 
    502490        self._get_cusor_lines(event) 
    503491        ax = event.inaxes 
     
    505493        if ax != None: 
    506494            try: 
    507                 pos_x = float(event.xdata)# / size_x 
    508                 pos_y = float(event.ydata)# / size_y 
    509                 pos_x = "%8.3g"% pos_x 
    510                 pos_y = "%8.3g"% pos_y 
     495                pos_x = float(event.xdata)  # / size_x 
     496                pos_y = float(event.ydata)  # / size_y 
     497                pos_x = "%8.3g" % pos_x 
     498                pos_y = "%8.3g" % pos_y 
    511499                self.position = str(pos_x), str(pos_y) 
    512500                wx.PostEvent(self.parent, StatusEvent(status=self.position)) 
    513501            except: 
    514                 self.position = None   
     502                self.position = None 
    515503        # unfocus all 
    516         self.parent.set_plot_unfocus()   
    517         #post nd event to notify guiframe that this panel is on focus 
     504        self.parent.set_plot_unfocus() 
     505        # post nd event to notify guiframe that this panel is on focus 
    518506        wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self)) 
    519507 
    520          
     508 
    521509    def _ontoggle_hide_error(self, event): 
    522510        """ 
     
    524512        """ 
    525513        menu = event.GetEventObject() 
    526         id = event.GetId() 
    527         self.set_selected_from_menu(menu, id) 
     514        event_id = event.GetId() 
     515        self.set_selected_from_menu(menu, event_id) 
    528516        # Check zoom 
    529517        xlo, xhi = self.subplot.get_xlim() 
     
    537525        ## increment graph color 
    538526        self.graph.render(self) 
    539         self.subplot.figure.canvas.draw_idle()   
     527        self.subplot.figure.canvas.draw_idle() 
    540528        if self.is_zoomed: 
    541529            # Recover the x,y limits 
    542             self.subplot.set_xlim((xlo, xhi))      
    543             self.subplot.set_ylim((ylo, yhi))  
    544  
    545            
     530            self.subplot.set_xlim((xlo, xhi)) 
     531            self.subplot.set_ylim((ylo, yhi)) 
     532 
     533 
    546534    def _onRemove(self, event): 
    547535        """ 
    548         Remove a plottable from the graph and render the graph  
    549          
     536        Remove a plottable from the graph and render the graph 
     537 
    550538        :param event: Menu event 
    551          
     539 
    552540        """ 
    553541        menu = event.GetEventObject() 
    554         id = event.GetId() 
    555         self.set_selected_from_menu(menu, id) 
     542        event_id = event.GetId() 
     543        self.set_selected_from_menu(menu, event_id) 
    556544        ## Check if there is a selected graph to remove 
    557545        if self.graph.selected_plottable in self.plots.keys(): 
    558             selected_plot = self.plots[self.graph.selected_plottable] 
    559             id = self.graph.selected_plottable 
    560             self.remove_data_by_id(id) 
    561              
     546            graph_id = self.graph.selected_plottable 
     547            self.remove_data_by_id(graph_id) 
     548 
    562549    def onContextMenu(self, event): 
    563550        """ 
    564551        1D plot context menu 
    565          
     552 
    566553        :param event: wx context event 
    567          
     554 
    568555        """ 
    569556        self._slicerpop = PanelMenu() 
    570557        self._slicerpop.set_plots(self.plots) 
    571         self._slicerpop.set_graph(self.graph)    
    572         if not self.graph.selected_plottable in self.plots:   
     558        self._slicerpop.set_graph(self.graph) 
     559        if not self.graph.selected_plottable in self.plots: 
    573560            # Various plot options 
    574             id = wx.NewId() 
    575             self._slicerpop.Append(id, '&Save Image', 'Save image as PNG') 
    576             wx.EVT_MENU(self, id, self.onSaveImage) 
    577             id = wx.NewId() 
    578             self._slicerpop.Append(id, '&Print Image', 'Print image ') 
    579             wx.EVT_MENU(self, id, self.onPrint) 
    580             id = wx.NewId() 
    581             self._slicerpop.Append(id, '&Print Preview', 'Print preview') 
    582             wx.EVT_MENU(self, id, self.onPrinterPreview) 
    583              
    584             id = wx.NewId() 
    585             self._slicerpop.Append(id, '&Copy to Clipboard',  
     561            wx_id = wx.NewId() 
     562            self._slicerpop.Append(wx_id, '&Save Image', 'Save image as PNG') 
     563            wx.EVT_MENU(self, wx_id, self.onSaveImage) 
     564            wx_id = wx.NewId() 
     565            self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 
     566            wx.EVT_MENU(self, wx_id, self.onPrint) 
     567            wx_id = wx.NewId() 
     568            self._slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 
     569            wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 
     570 
     571            wx_id = wx.NewId() 
     572            self._slicerpop.Append(wx_id, '&Copy to Clipboard', 
    586573                                   'Copy to the clipboard') 
    587             wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 
    588                      
     574            wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 
     575 
    589576            self._slicerpop.AppendSeparator() 
    590577 
    591578        for plot in self.plots.values(): 
    592             #title = plot.title 
     579            # title = plot.title 
    593580            name = plot.name 
    594581            plot_menu = wx.Menu() 
     
    598585                if plot != self.plots[self.graph.selected_plottable]: 
    599586                    continue 
    600                  
    601             id = wx.NewId() 
    602             plot_menu.Append(id, "&DataInfo", name) 
    603             wx.EVT_MENU(self, id, self. _onDataShow) 
    604             id = wx.NewId() 
    605             plot_menu.Append(id, "&Save Points as a File", name) 
    606             wx.EVT_MENU(self, id, self._onSave) 
     587 
     588            wx_id = wx.NewId() 
     589            plot_menu.Append(wx_id, "&DataInfo", name) 
     590            wx.EVT_MENU(self, wx_id, self. _onDataShow) 
     591            wx_id = wx.NewId() 
     592            plot_menu.Append(wx_id, "&Save Points as a File", name) 
     593            wx.EVT_MENU(self, wx_id, self._onSave) 
    607594            plot_menu.AppendSeparator() 
    608              
    609             #add menu of other plugins 
     595 
     596            # add menu of other plugins 
    610597            item_list = self.parent.get_current_context_menu(self) 
    611                
     598 
    612599            if (not item_list == None) and (not len(item_list) == 0): 
    613600                for item in item_list: 
    614601 
    615602                    try: 
    616                         id = wx.NewId() 
    617                         plot_menu.Append(id, item[0], name) 
    618                         wx.EVT_MENU(self, id, item[2]) 
     603                        wx_id = wx.NewId() 
     604                        plot_menu.Append(wx_id, item[0], name) 
     605                        wx.EVT_MENU(self, wx_id, item[2]) 
    619606                    except: 
    620607                        msg = "ModelPanel1D.onContextMenu: " 
    621608                        msg += "bad menu item  %s" % sys.exc_value 
    622609                        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    623                         pass 
    624610                plot_menu.AppendSeparator() 
    625              
    626             if self.parent.ClassName.count('wxDialog') == 0:  
    627                 id = wx.NewId() 
    628                 plot_menu.Append(id, '&Linear Fit', name) 
    629                 wx.EVT_MENU(self, id, self.onFitting) 
     611 
     612            if self.parent.ClassName.count('wxDialog') == 0: 
     613                wx_id = wx.NewId() 
     614                plot_menu.Append(wx_id, '&Linear Fit', name) 
     615                wx.EVT_MENU(self, wx_id, self.onFitting) 
    630616                plot_menu.AppendSeparator() 
    631      
    632                 id = wx.NewId() 
    633                 plot_menu.Append(id, "Remove", name) 
    634                 wx.EVT_MENU(self, id, self._onRemove) 
     617 
     618                wx_id = wx.NewId() 
     619                plot_menu.Append(wx_id, "Remove", name) 
     620                wx.EVT_MENU(self, wx_id, self._onRemove) 
    635621                if not plot.is_data: 
    636                     id = wx.NewId() 
    637                     plot_menu.Append(id, '&Freeze', name) 
    638                     wx.EVT_MENU(self, id, self.onFreeze) 
    639                 plot_menu.AppendSeparator()     
    640                 symbol_menu = wx.Menu() 
    641                  
     622                    wx_id = wx.NewId() 
     623                    plot_menu.Append(wx_id, '&Freeze', name) 
     624                    wx.EVT_MENU(self, wx_id, self.onFreeze) 
     625                plot_menu.AppendSeparator() 
     626 
    642627                if plot.is_data: 
    643                     id = wx.NewId() 
    644                     self.hide_menu = plot_menu.Append(id,  
    645                                                     "Hide Error Bar", name) 
    646          
     628                    wx_id = wx.NewId() 
     629                    self.hide_menu = plot_menu.Append(wx_id, "Hide Error Bar", name) 
     630 
    647631                    if plot.dy is not None and plot.dy != []: 
    648                         if plot.hide_error : 
     632                        if plot.hide_error: 
    649633                            self.hide_menu.SetText('Show Error Bar') 
    650634                        else: 
     
    652636                    else: 
    653637                        self.hide_menu.Enable(False) 
    654                     wx.EVT_MENU(self, id, self._ontoggle_hide_error) 
    655                  
     638                    wx.EVT_MENU(self, wx_id, self._ontoggle_hide_error) 
     639 
    656640                    plot_menu.AppendSeparator() 
    657641 
    658                 id = wx.NewId() 
    659                 plot_menu.Append(id, '&Modify Plot Property', name) 
    660                 wx.EVT_MENU(self, id, self.createAppDialog) 
    661  
    662  
    663  
    664             id = wx.NewId() 
    665             #plot_menu.SetTitle(name) 
    666             self._slicerpop.AppendMenu(id, '&%s'% name, plot_menu) 
     642                wx_id = wx.NewId() 
     643                plot_menu.Append(wx_id, '&Modify Plot Property', name) 
     644                wx.EVT_MENU(self, wx_id, self.createAppDialog) 
     645            wx_id = wx.NewId() 
     646            # plot_menu.SetTitle(name) 
     647            self._slicerpop.AppendMenu(wx_id, '&%s' % name, plot_menu) 
    667648            # Option to hide 
    668             #TODO: implement functionality to hide a plottable (legend click) 
    669         if not self.graph.selected_plottable in self.plots:   
     649            # TODO: implement functionality to hide a plottable (legend click) 
     650        if not self.graph.selected_plottable in self.plots: 
    670651            self._slicerpop.AppendSeparator() 
    671652            loc_menu = wx.Menu() 
    672653            for label in self._loc_labels: 
    673                 id = wx.NewId() 
    674                 loc_menu.Append(id, str(label), str(label)) 
    675                 wx.EVT_MENU(self, id, self.onChangeLegendLoc) 
    676              
    677             id = wx.NewId() 
    678             self._slicerpop.Append(id, '&Modify Graph Appearance', 
     654                wx_id = wx.NewId() 
     655                loc_menu.Append(wx_id, str(label), str(label)) 
     656                wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 
     657 
     658            wx_id = wx.NewId() 
     659            self._slicerpop.Append(wx_id, '&Modify Graph Appearance', 
    679660                                   'Modify graph appearance') 
    680             wx.EVT_MENU(self, id, self.modifyGraphAppearance) 
     661            wx.EVT_MENU(self, wx_id, self.modifyGraphAppearance) 
    681662            self._slicerpop.AppendSeparator() 
    682663 
    683              
     664 
    684665            if self.position != None: 
    685                 id = wx.NewId() 
    686                 self._slicerpop.Append(id, '&Add Text') 
    687                 wx.EVT_MENU(self, id, self._on_addtext) 
    688                 id = wx.NewId() 
    689                 self._slicerpop.Append(id, '&Remove Text') 
    690                 wx.EVT_MENU(self, id, self._on_removetext) 
     666                wx_id = wx.NewId() 
     667                self._slicerpop.Append(wx_id, '&Add Text') 
     668                wx.EVT_MENU(self, wx_id, self._on_addtext) 
     669                wx_id = wx.NewId() 
     670                self._slicerpop.Append(wx_id, '&Remove Text') 
     671                wx.EVT_MENU(self, wx_id, self._on_removetext) 
    691672                self._slicerpop.AppendSeparator() 
    692             id = wx.NewId() 
    693             self._slicerpop.Append(id, '&Change Scale') 
    694             wx.EVT_MENU(self, id, self._onProperties) 
     673            wx_id = wx.NewId() 
     674            self._slicerpop.Append(wx_id, '&Change Scale') 
     675            wx.EVT_MENU(self, wx_id, self._onProperties) 
    695676            self._slicerpop.AppendSeparator() 
    696             id = wx.NewId() 
    697             self._slicerpop.Append(id, '&Reset Graph Range') 
    698             wx.EVT_MENU(self, id, self.onResetGraph)   
    699              
    700             if self.parent.ClassName.count('wxDialog') == 0:     
     677            wx_id = wx.NewId() 
     678            self._slicerpop.Append(wx_id, '&Reset Graph Range') 
     679            wx.EVT_MENU(self, wx_id, self.onResetGraph) 
     680 
     681            if self.parent.ClassName.count('wxDialog') == 0: 
    701682                self._slicerpop.AppendSeparator() 
    702                 id = wx.NewId() 
    703                 self._slicerpop.Append(id, '&Window Title') 
    704                 wx.EVT_MENU(self, id, self.onChangeCaption) 
     683                wx_id = wx.NewId() 
     684                self._slicerpop.Append(wx_id, '&Window Title') 
     685                wx.EVT_MENU(self, wx_id, self.onChangeCaption) 
    705686        try: 
    706687            pos_evt = event.GetPosition() 
     
    710691            pos = (pos_x, pos_y + 5) 
    711692        self.PopupMenu(self._slicerpop, pos) 
    712              
     693 
    713694    def onFreeze(self, event): 
    714695        """ 
     
    716697        """ 
    717698        menu = event.GetEventObject() 
    718         id = event.GetId() 
    719         self.set_selected_from_menu(menu, id) 
     699        wx_id = event.GetId() 
     700        self.set_selected_from_menu(menu, wx_id) 
    720701        plot = self.plots[self.graph.selected_plottable] 
    721702        self.parent.onfreeze([plot.id]) 
    722          
    723                         
     703 
    724704    def _onSave(self, evt): 
    725705        """ 
    726706        Save a data set to a text file 
    727          
     707 
    728708        :param evt: Menu event 
    729          
     709 
    730710        """ 
    731711        menu = evt.GetEventObject() 
    732         id = evt.GetId() 
    733         self.set_selected_from_menu(menu, id) 
     712        event_id = evt.GetId() 
     713        self.set_selected_from_menu(menu, event_id) 
    734714        data = self.plots[self.graph.selected_plottable] 
    735715        default_name = data.label 
     
    740720            self.parent.save_data1d(data, default_name) 
    741721 
    742                         
    743722    def _onDataShow(self, evt): 
    744723        """ 
    745724        Show the data set in text 
    746          
     725 
    747726        :param evt: Menu event 
    748          
     727 
    749728        """ 
    750729        menu = evt.GetEventObject() 
    751         id = evt.GetId() 
    752         self.set_selected_from_menu(menu, id) 
     730        event_id = evt.GetId() 
     731        self.set_selected_from_menu(menu, event_id) 
    753732        data = self.plots[self.graph.selected_plottable] 
    754733        default_name = data.label 
    755734        if default_name.count('.') > 0: 
    756735            default_name = default_name.split('.')[0] 
    757         #default_name += "_out" 
     736        # default_name += "_out" 
    758737        if self.parent != None: 
    759738            self.parent.show_data1d(data, default_name) 
    760              
    761     def _add_more_tool(self): 
    762         """ 
    763         Add refresh, add/hide button in the tool bar 
    764         """ 
    765         return 
    766         if self.parent.__class__.__name__ != 'ViewerFrame': 
    767             return 
    768         self.toolbar.AddSeparator() 
    769         id_hide = wx.NewId() 
    770         hide = wx.Bitmap(GUIFRAME_ICON.HIDE_ID_PATH, wx.BITMAP_TYPE_PNG) 
    771         self.toolbar.AddSimpleTool(id_hide, hide, 'Hide', 'Hide') 
    772         self.toolbar.Realize() 
    773         wx.EVT_TOOL(self, id_hide,  self._on_hide) 
    774          
     739 
    775740    def _on_hide(self, event): 
    776741        """ 
    777742        Hides the plot when button is pressed 
    778         """      
     743        """ 
    779744        if self.parent is not None: 
    780745            self.parent.hide_panel(self.uid) 
     
    786751        ID = self.uid 
    787752        self.parent.delete_panel(ID) 
    788      
     753 
    789754    def createAppDialog(self, event): 
    790755        """ 
     
    792757        """ 
    793758        menu = event.GetEventObject() 
    794         id = event.GetId() 
    795         self.set_selected_from_menu(menu, id) 
     759        event_id = event.GetId() 
     760        self.set_selected_from_menu(menu, event_id) 
    796761        self.appearance_selected_plot = \ 
    797762                        self.plots[self.graph.selected_plottable] 
     
    809774        icon = self.parent.GetIcon() 
    810775        self.appD.SetIcon(icon) 
    811         self.appD.set_defaults(float(curr_size), int(curr_color),  
    812                     str(appearanceDialog.find_key(self.get_symbol_label(),  
    813                     int(curr_symbol))), curr_label) 
    814         self.appD.Bind(wx.EVT_CLOSE, self.on_AppDialog_close)     
     776        self.appD.set_defaults(float(curr_size), int(curr_color), 
     777                               str(appearanceDialog.find_key(self.get_symbol_label(), 
     778                                                             int(curr_symbol))), curr_label) 
     779        self.appD.Bind(wx.EVT_CLOSE, self.on_AppDialog_close) 
    815780 
    816781    def on_AppDialog_close(self, event): 
     
    818783        on_Modify Plot Property_close 
    819784        """ 
    820         if(self.appD.okay_clicked == True): 
    821             # returns (size,color,symbol,datalabel) 
    822             info = self.appD.get_current_values()  
     785        if self.appD.okay_clicked == True: 
     786            info = self.appD.get_current_values() 
    823787            self.appearance_selected_plot.custom_color = \ 
    824788                        self._color_labels[info[1].encode('ascii', 'ignore')] 
     
    826790            self.appearance_selected_plot.markersize = float(info[0]) 
    827791            self.appearance_selected_plot.symbol = \ 
    828                         self.get_symbol_label()[info[2]]  
     792                        self.get_symbol_label()[info[2]] 
    829793            self.appearance_selected_plot.label = str(info[3]) 
    830794        self.appD.Destroy() 
     
    833797    def modifyGraphAppearance(self, event): 
    834798        """ 
    835         On Modify Graph Appearance  
     799        On Modify Graph Appearance 
    836800        """ 
    837801        self.graphApp = graphAppearance(self, 'Modify Graph Appearance') 
    838802        icon = self.parent.GetIcon() 
    839803        self.graphApp.SetIcon(icon) 
    840         self.graphApp.setDefaults(self.grid_on, self.legend_on,  
    841                                   self.xaxis_label, self.yaxis_label,  
    842                                   self.xaxis_unit, self.yaxis_unit,  
    843                                   self.xaxis_font, self.yaxis_font,  
    844                                   find_key(self.get_loc_label(),  
    845                                   self.legendLoc),  
    846                                   self.xcolor, self.ycolor,  
     804        self.graphApp.setDefaults(self.grid_on, self.legend_on, 
     805                                  self.xaxis_label, self.yaxis_label, 
     806                                  self.xaxis_unit, self.yaxis_unit, 
     807                                  self.xaxis_font, self.yaxis_font, 
     808                                  find_key(self.get_loc_label(), self.legendLoc), 
     809                                  self.xcolor, self.ycolor, 
    847810                                  self.is_xtick, self.is_ytick) 
    848811        self.graphApp.Bind(wx.EVT_CLOSE, self.on_graphApp_close) 
     
    857820        legend_loc = graph_app.get_legend_loc() 
    858821        toggle_legend = graph_app.get_togglelegend() 
    859          
    860         self.onGridOnOff(toggle_grid ) 
     822 
     823        self.onGridOnOff(toggle_grid) 
    861824        self.ChangeLegendLoc(legend_loc) 
    862825        self.onLegend(toggle_legend) 
     
    868831        self.xaxis_font = graph_app.get_xfont() 
    869832        self.yaxis_font = graph_app.get_yfont() 
    870         self.is_xtick =  graph_app.get_xtick_check() 
    871         self.is_ytick =  graph_app.get_ytick_check() 
     833        self.is_xtick = graph_app.get_xtick_check() 
     834        self.is_ytick = graph_app.get_ytick_check() 
    872835        if self.is_xtick: 
    873836            self.xaxis_tick = self.xaxis_font 
     
    875838            self.yaxis_tick = self.yaxis_font 
    876839 
    877         self.xaxis(self.xaxis_label, self.xaxis_unit,  
    878                    graph_app.get_xfont(), graph_app.get_xcolor(),  
     840        self.xaxis(self.xaxis_label, self.xaxis_unit, 
     841                   graph_app.get_xfont(), graph_app.get_xcolor(), 
    879842                   self.xaxis_tick) 
    880         self.yaxis(self.yaxis_label, self.yaxis_unit,  
     843        self.yaxis(self.yaxis_label, self.yaxis_unit, 
    881844                   graph_app.get_yfont(), graph_app.get_ycolor(), 
    882845                   self.yaxis_tick) 
  • src/sas/guiframe/local_perspectives/plotting/profile_dialog.py

    r79492222 r090e07e  
    270270        pass 
    271271     
    272     def _add_more_tool(self): 
    273         """ 
    274         Not implemented 
    275         """ 
    276         pass  
    277      
    278272    def onChangeCaption(self, event): 
    279273        """ 
Note: See TracChangeset for help on using the changeset viewer.