Changeset 091e71a2 in sasview


Ignore:
Timestamp:
Mar 4, 2015 11:41:18 AM (9 years ago)
Author:
Doucet, Mathieu <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
3350ad6
Parents:
1128bd31
Message:

Every time I look at this code I want to cry…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/guiframe/gui_manager.py

    r064723b r091e71a2  
    55#This software was developed by the University of Tennessee as part of the 
    66#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    7 #project funded by the US National Science Foundation.  
     7#project funded by the US National Science Foundation. 
    88# 
    99#See the license text in license.txtz 
     
    5858        logging.info("Using application path: %s", app_path) 
    5959        return app_path 
    60      
     60 
    6161    # Next, try the current working directory 
    6262    if os.path.isfile(os.path.join(os.getcwd(), "custom_config.py")): 
    6363        logging.info("Using application path: %s", os.getcwd()) 
    6464        return os.path.abspath(os.getcwd()) 
    65      
     65 
    6666    # Finally, try the directory of the sasview module 
    6767    #TODO: gui_manager will have to know about sasview until we 
     
    7979        Returns the user's home directory 
    8080    """ 
    81     userdir = os.path.join(os.path.expanduser("~"),".sasview") 
     81    userdir = os.path.join(os.path.expanduser("~"), ".sasview") 
    8282    if not os.path.isdir(userdir): 
    8383        os.makedirs(userdir) 
    8484    return userdir 
    85      
     85 
    8686def _find_local_config(file, path): 
    8787    """ 
    8888        Find configuration file for the current application 
    89     """     
     89    """ 
    9090    config_module = None 
    9191    fObj = None 
    9292    try: 
    9393        fObj, path_config, descr = imp.find_module(file, [path]) 
    94         config_module = imp.load_module(file, fObj, path_config, descr)  
     94        config_module = imp.load_module(file, fObj, path_config, descr) 
    9595    except: 
    9696        logging.error("Error loading %s/%s: %s" % (path, file, sys.exc_value)) 
     
    102102 
    103103# Get APP folder 
    104 PATH_APP = get_app_dir()  
     104PATH_APP = get_app_dir() 
    105105DATAPATH = PATH_APP 
    106106 
    107 # GUI always starts from the App folder  
     107# GUI always starts from the App folder 
    108108#os.chdir(PATH_APP) 
    109109# Read in the local config, which can either be with the main 
     
    113113    config = _find_local_config('local_config', os.getcwd()) 
    114114    if config is None: 
    115         # Didn't find local config, load the default  
     115        # Didn't find local config, load the default 
    116116        import sas.guiframe.config as config 
    117         logging.info("using default local_config")         
     117        logging.info("using default local_config") 
    118118    else: 
    119         logging.info("found local_config in %s" % os.getcwd())   
     119        logging.info("found local_config in %s" % os.getcwd()) 
    120120else: 
    121     logging.info("found local_config in %s" % PATH_APP)      
    122             
     121    logging.info("found local_config in %s" % PATH_APP) 
     122 
    123123from sas.guiframe.customdir  import SetupCustom 
    124124c_conf_dir = SetupCustom().setup_dir(PATH_APP) 
     
    154154    PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH 
    155155    DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH 
    156     GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH  
     156    GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH 
    157157    GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT 
    158     CONTROL_WIDTH = custom_config.CONTROL_WIDTH  
     158    CONTROL_WIDTH = custom_config.CONTROL_WIDTH 
    159159    CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT 
    160160    DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE 
     
    173173    PLOPANEL_WIDTH = config.PLOPANEL_WIDTH 
    174174    DATAPANEL_WIDTH = config.DATAPANEL_WIDTH 
    175     GUIFRAME_WIDTH = config.GUIFRAME_WIDTH  
     175    GUIFRAME_WIDTH = config.GUIFRAME_WIDTH 
    176176    GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT 
    177     CONTROL_WIDTH = -1  
     177    CONTROL_WIDTH = -1 
    178178    CONTROL_HEIGHT = -1 
    179179    DEFAULT_PERSPECTIVE = None 
     
    183183DEFAULT_STYLE = config.DEFAULT_STYLE 
    184184 
    185 PLUGIN_STATE_EXTENSIONS =  config.PLUGIN_STATE_EXTENSIONS 
     185PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 
    186186OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU 
    187187VIEW_MENU = config.VIEW_MENU 
     
    214214        PARENT_FRAME = wx.Frame 
    215215        CHILD_FRAME = wx.Frame 
    216      
     216 
    217217class ViewerFrame(PARENT_FRAME): 
    218218    """ 
    219219    Main application frame 
    220220    """ 
    221      
    222     def __init__(self, parent, title,  
     221 
     222    def __init__(self, parent, title, 
    223223                 size=(GUIFRAME_WIDTH, GUIFRAME_HEIGHT), 
    224                  gui_style=DEFAULT_STYLE,  
     224                 gui_style=DEFAULT_STYLE, 
    225225                 style=wx.DEFAULT_FRAME_STYLE, 
    226226                 pos=wx.DefaultPosition): 
     
    232232        # title 
    233233        self.title = title 
    234         self.__gui_style = gui_style        
     234        self.__gui_style = gui_style 
    235235        path = os.path.dirname(__file__) 
    236         temp_path = os.path.join(path,'images') 
    237         ico_file = os.path.join(temp_path,'ball.ico') 
     236        temp_path = os.path.join(path, 'images') 
     237        ico_file = os.path.join(temp_path, 'ball.ico') 
    238238        if os.path.isfile(ico_file): 
    239239            self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO)) 
    240240        else: 
    241             temp_path = os.path.join(os.getcwd(),'images') 
    242             ico_file = os.path.join(temp_path,'ball.ico') 
     241            temp_path = os.path.join(os.getcwd(), 'images') 
     242            ico_file = os.path.join(temp_path, 'ball.ico') 
    243243            if os.path.isfile(ico_file): 
    244244                self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO)) 
    245245            else: 
    246246                ico_file = os.path.join(os.path.dirname(os.path.sys.path[0]), 
    247                              'images', 'ball.ico') 
     247                                        'images', 'ball.ico') 
    248248                if os.path.isfile(ico_file): 
    249249                    self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO)) 
    250250        self.path = PATH_APP 
    251         self.application_name = APPLICATION_NAME  
     251        self.application_name = APPLICATION_NAME 
    252252        ## Application manager 
    253253        self._input_file = None 
     
    294294 
    295295        # Default locations 
    296         self._default_save_location = DEFAULT_OPEN_FOLDER        
     296        self._default_save_location = DEFAULT_OPEN_FOLDER 
    297297        # Welcome panel 
    298298        self.defaultPanel = None 
     
    303303        self.cpanel_on_focus = None 
    304304 
    305         self.loader = Loader()    
     305        self.loader = Loader() 
    306306        #data manager 
    307307        self.batch_on = False 
     
    310310        self._data_panel = None#DataPanel(parent=self) 
    311311        if self.panel_on_focus is not None: 
    312             self._data_panel.set_panel_on_focus( 
    313                                 self.panel_on_focus.window_caption) 
     312            self._data_panel.set_panel_on_focus(self.panel_on_focus.window_caption) 
    314313        # list of plot panels in schedule to full redraw 
    315314        self.schedule = False 
     
    318317        self.schedule_full_draw_list = [] 
    319318        self.idletimer = wx.CallLater(TIME_FACTOR, self._onDrawIdle) 
    320          
     319 
    321320        self.batch_frame = GridFrame(parent=self) 
    322321        self.batch_frame.Hide() 
    323322        self.on_batch_selection(event=None) 
    324323        self.add_icon() 
    325          
     324 
    326325        # Register the close event so it calls our own method 
    327326        wx.EVT_CLOSE(self, self.WindowClose) 
     
    338337        # Preferred window size 
    339338        self._window_width, self._window_height = size 
    340          
     339 
    341340    def add_icon(self): 
    342341        """ 
    343         get list of child and attempt to add the default icon  
    344         """ 
    345          
    346         list_children = self.GetChildren()  
     342        get list of child and attempt to add the default icon 
     343        """ 
     344 
     345        list_children = self.GetChildren() 
    347346        for frame in list_children: 
    348347            self.put_icon(frame) 
    349          
    350     def put_icon(self, frame):  
     348 
     349    def put_icon(self, frame): 
    351350        """ 
    352351        Put icon on the tap of a panel 
     
    358357                    frame.SetIcon(icon) 
    359358                except: 
    360                     pass   
    361                  
     359                    pass 
     360 
    362361    def get_client_size(self): 
    363362        """ 
     
    370369        if toolbar != None: 
    371370            _, tb_h = toolbar.GetSizeTuple() 
    372             height -= tb_h  
     371            height -= tb_h 
    373372        return width, height 
    374      
     373 
    375374    def on_change_categories(self, evt): 
    376375        # ILL 
     
    382381 
    383382        if fitpanel != None: 
    384             for i in range(0,fitpanel.GetPageCount()): 
     383            for i in range(0, fitpanel.GetPageCount()): 
    385384                fitpanel.GetPage(i)._populate_listbox() 
    386385 
    387  
    388  
    389386    def on_set_batch_result(self, data_outputs, data_inputs=None, 
    390                              plugin_name=""): 
     387                            plugin_name=""): 
    391388        """ 
    392389        Display data into a grid in batch mode and show the grid 
     
    395392        time_str = time.strftime("%b %d %H;%M of %Y", t) 
    396393        details = "File Generated by %s : %s" % (APPLICATION_NAME, 
    397                                                      str(plugin_name)) 
    398         details += "on %s.\n" % time_str  
     394                                                 str(plugin_name)) 
     395        details += "on %s.\n" % time_str 
    399396        ext = ".csv" 
    400         file_name = "Batch_" + str(plugin_name)+ "_" + time_str + ext 
     397        file_name = "Batch_" + str(plugin_name) + "_" + time_str + ext 
    401398        file_name = self._default_save_location + str(file_name) 
    402          
     399 
    403400        self.open_with_localapp(file_name=file_name, 
    404401                                details=details, 
    405402                                data_inputs=data_inputs, 
    406                                     data_outputs=data_outputs) 
    407       
    408      
     403                                data_outputs=data_outputs) 
     404 
    409405    def open_with_localapp(self, data_inputs=None, details="", file_name=None, 
    410406                           data_outputs=None): 
     
    413409        :param data: dictionary of string and list of items 
    414410        """ 
    415         self.batch_frame.set_data(data_inputs=data_inputs,  
     411        self.batch_frame.set_data(data_inputs=data_inputs, 
    416412                                  data_outputs=data_outputs, 
    417413                                  details=details, 
    418414                                  file_name=file_name) 
    419415        self.show_batch_frame(None) 
    420          
     416 
    421417    def on_read_batch_tofile(self, base): 
    422418        """ 
     
    428424            self._default_save_location = os.getcwd() 
    429425        wildcard = "(*.csv; *.txt)|*.csv; *.txt" 
    430         dlg = wx.FileDialog(base,  
    431                             "Choose a file",  
     426        dlg = wx.FileDialog(base, 
     427                            "Choose a file", 
    432428                            self._default_save_location, "", 
    433                              wildcard) 
     429                            wildcard) 
    434430        if dlg.ShowModal() == wx.ID_OK: 
    435431            path = dlg.GetPath() 
     
    440436            self.read_batch_tofile(file_name=path) 
    441437        except: 
    442             msg = "Error occurred when reading the file; %s\n"% path 
    443             msg += "%s\n"% sys.exc_value 
     438            msg = "Error occurred when reading the file; %s\n" % path 
     439            msg += "%s\n" % sys.exc_value 
    444440            wx.PostEvent(self, StatusEvent(status=msg, 
    445                                              info="error")) 
    446              
     441                                           info="error")) 
     442 
    447443    def read_batch_tofile(self, file_name): 
    448444        """ 
     
    457453        if ext.lower() == ".csv": 
    458454            separator = "," 
    459         buffer = fd.read() 
    460         lines = buffer.split('\n') 
     455        fd_buffer = fd.read() 
     456        lines = fd_buffer.split('\n') 
    461457        fd.close() 
    462         column_names_line  = "" 
     458        column_names_line = "" 
    463459        index = None 
    464460        details = "" 
     
    487483            if count >= 2: 
    488484                column_names_line = line 
    489                 break  
    490             
     485                break 
     486 
    491487        if column_names_line.strip() == "" or index is None: 
    492             return  
     488            return 
    493489 
    494490        col_name_toks = column_names_line.split(separator) 
     
    500496                try: 
    501497                    float(c_name) 
    502                     col_name = "Column %s"% str(col_index + 1) 
     498                    col_name = "Column %s" % str(col_index + 1) 
    503499                    index_min = index 
    504500                except: 
    505501                    col_name = c_name 
    506502                    index_min = index + 1 
    507                 data[col_name] = [ lines[row].split(separator)[c_index] 
    508                                 for row in range(index_min, len(lines)-1)] 
     503                data[col_name] = [lines[row].split(separator)[c_index] 
     504                                  for row in range(index_min, len(lines) - 1)] 
    509505                c_index += 1 
    510                  
     506 
    511507        self.open_with_localapp(data_outputs=data, data_inputs=None, 
    512508                                file_name=file_name, details=details) 
    513          
     509 
    514510    def write_batch_tofile(self, data, file_name, details=""): 
    515511        """ 
     
    541537        max_index = max(max_list) 
    542538        index = 0 
    543         while(index < max_index): 
     539        while index < max_index: 
    544540            for value_list in data.values(): 
    545541                if index < len(value_list): 
     
    552548            index += 1 
    553549        fd.close() 
    554              
     550 
    555551    def open_with_externalapp(self, data, file_name, details=""): 
    556552        """ 
     
    559555        if not os.path.exists(file_name): 
    560556            self.write_batch_tofile(data=data, file_name=file_name, 
    561                                                details=details) 
     557                                    details=details) 
    562558        try: 
    563559            from win32com.client import Dispatch 
    564             excel_app = Dispatch('Excel.Application')      
    565             wb = excel_app.Workbooks.Open(file_name)  
     560            excel_app = Dispatch('Excel.Application') 
     561            excel_app.Workbooks.Open(file_name) 
    566562            excel_app.Visible = 1 
    567563        except: 
     
    570566            msg += "check that %s really exists.\n" % str(file_name) 
    571567            wx.PostEvent(self, StatusEvent(status=msg, 
    572                                              info="error")) 
    573              
    574           
     568                                           info="error")) 
     569 
    575570    def on_batch_selection(self, event=None): 
    576571        """ 
     
    583578        for plug in self.plugins: 
    584579            plug.set_batch_selection(self.batch_on) 
    585              
     580 
    586581    def on_color_selection(self, event): 
    587582        """ 
    588583        :param event: contains parameters for id and color 
    589         """  
    590         color, id = event.color, event.id 
     584        """ 
     585        color, event_id = event.color, event.id 
    591586        for plug in self.plugins: 
    592             plug.add_color(color, id) 
    593          
    594          
     587            plug.add_color(color, event_id) 
     588 
    595589    def setup_custom_conf(self): 
    596590        """ 
     
    599593        if custom_config == None: 
    600594            return 
    601          
     595 
    602596        if not FIXED_PANEL: 
    603597            self.__gui_style &= (~GUIFRAME.FIXED_PANEL) 
     
    611605 
    612606        if WELCOME_PANEL_SHOW: 
    613             self.__gui_style |= GUIFRAME.WELCOME_PANEL_ON    
    614               
     607            self.__gui_style |= GUIFRAME.WELCOME_PANEL_ON 
     608 
    615609    def set_custom_default_perspective(self): 
    616610        """ 
     
    622616            try: 
    623617                if plugin.sub_menu == DEFAULT_PERSPECTIVE: 
    624                      
     618 
    625619                    plugin.on_perspective(event=None) 
    626620                    frame = plugin.get_frame() 
     
    629623                else: 
    630624                    frame = plugin.get_frame() 
    631                     frame.Show(False)  
     625                    frame.Show(False) 
    632626            except: 
    633                 pass   
    634         return           
    635                  
     627                pass 
     628        return 
     629 
    636630    def on_load_data(self, event): 
    637631        """ 
     
    640634        if self._data_plugin is not None: 
    641635            self._data_plugin.load_data(event) 
    642              
     636 
    643637    def get_current_perspective(self): 
    644638        """ 
     
    652646        """ 
    653647        return self._default_save_location 
    654      
     648 
    655649    def set_input_file(self, input_file): 
    656650        """ 
     
    658652        """ 
    659653        self._input_file = input_file 
    660          
     654 
    661655    def get_data_manager(self): 
    662656        """ 
     
    664658        """ 
    665659        return self._data_manager 
    666      
     660 
    667661    def get_toolbar(self): 
    668662        """ 
     
    670664        """ 
    671665        return self._toolbar 
    672      
     666 
    673667    def set_panel_on_focus(self, event): 
    674668        """ 
     
    698692                self.enable_edit_menu() 
    699693 
    700     def disable_app_menu(self, p_panel=None):   
     694    def disable_app_menu(self, p_panel=None): 
    701695        """ 
    702696        Disables all menus in the menubar 
    703697        """ 
    704698        return 
    705      
    706     def send_focus_to_datapanel(self, name):   
     699 
     700    def send_focus_to_datapanel(self, name): 
    707701        """ 
    708702        Send focusing on ID to data explorer 
     
    710704        if self._data_panel != None: 
    711705            self._data_panel.set_panel_on_focus(name) 
    712              
     706 
    713707    def set_panel_on_focus_helper(self): 
    714708        """ 
     
    722716            combo_title = str(self.panel_on_focus.window_caption) 
    723717            combo.SetStringSelection(combo_title) 
    724             combo.SetToolTip( wx.ToolTip(combo_title ))  
     718            combo.SetToolTip(wx.ToolTip(combo_title)) 
    725719        elif self.panel_on_focus != self._data_panel: 
    726720            cpanel = self.panel_on_focus 
     
    728722                cpanel.on_tap_focus() 
    729723                self.cpanel_on_focus = self.panel_on_focus 
    730        
     724 
    731725    def reset_bookmark_menu(self, panel): 
    732726        """ 
    733727        Reset Bookmark menu list 
    734          
     728 
    735729        : param panel: a control panel or tap where the bookmark is 
    736730        """ 
     
    745739                if pos < 3: 
    746740                    continue 
    747                 id =  bitem.GetId() 
     741                id = bitem.GetId() 
    748742                label = bitem.GetLabel() 
    749743                self._toolbar.append_bookmark_item(id, label) 
    750744                wx.EVT_MENU(self, id, cpanel._back_to_bookmark) 
    751745            self._toolbar.Realize() 
    752               
     746 
    753747 
    754748    def build_gui(self): 
     
    771765        self._setup_layout() 
    772766        self._add_menu_application() 
    773          
     767 
    774768        # Set up the menu 
    775769        self._add_current_plugin_menu() 
     
    781775        if not wx.VERSION_STRING >= '3.0.0.0': 
    782776            self.SetMenuBar(self._menubar) 
    783          
     777 
    784778        try: 
    785779            self.load_from_cmd(self._input_file) 
    786780        except: 
    787             msg = "%s Cannot load file %s\n" %(str(APPLICATION_NAME),  
    788                                              str(self._input_file)) 
     781            msg = "%s Cannot load file %s\n" % (str(APPLICATION_NAME), 
     782                                                str(self._input_file)) 
    789783            msg += str(sys.exc_value) + '\n' 
    790784            logging.error(msg) 
     
    798792        self._check_update(None) 
    799793 
    800     def _setup_extra_custom(self):   
     794    def _setup_extra_custom(self): 
    801795        """ 
    802796        Set up toolbar and welcome view if needed 
     
    804798        style = self.__gui_style & GUIFRAME.TOOLBAR_ON 
    805799        if (style == GUIFRAME.TOOLBAR_ON) & (not self._toolbar.IsShown()): 
    806             self._on_toggle_toolbar()  
    807          
     800            self._on_toggle_toolbar() 
     801 
    808802        # Set Custom deafult start page 
    809803        welcome_style = self.__gui_style & GUIFRAME.WELCOME_PANEL_ON 
    810804        if welcome_style == GUIFRAME.WELCOME_PANEL_ON: 
    811805            self.show_welcome_panel(None) 
    812        
     806 
    813807    def _setup_layout(self): 
    814808        """ 
     
    822816        self._load_panels() 
    823817        self.set_default_perspective() 
    824          
     818 
    825819    def SetStatusText(self, *args, **kwds): 
    826820        """ 
     
    828822        number = self.sb.get_msg_position() 
    829823        wx.Frame.SetStatusText(self, number=number, *args, **kwds) 
    830          
     824 
    831825    def PopStatusText(self, *args, **kwds): 
    832826        """ 
     
    834828        field = self.sb.get_msg_position() 
    835829        wx.Frame.PopStatusText(self, field=field) 
    836          
     830 
    837831    def PushStatusText(self, *args, **kwds): 
    838832        """ 
    839             FIXME: No message is passed. What is this supposed to do?  
     833            FIXME: No message is passed. What is this supposed to do? 
    840834        """ 
    841835        field = self.sb.get_msg_position() 
    842         wx.Frame.PushStatusText(self, field=field,  
    843                         string="FIXME: PushStatusText called without text") 
     836        wx.Frame.PushStatusText(self, field=field, 
     837                                string="FIXME: PushStatusText called without text") 
    844838 
    845839    def add_perspective(self, plugin): 
     
    855849                msg = "Plugin %s already loaded" % plugin.sub_menu 
    856850                logging.info(msg) 
    857                 is_loaded = True   
     851                is_loaded = True 
    858852        if not is_loaded: 
    859             self.plugins.append(plugin)   
     853            self.plugins.append(plugin) 
    860854            msg = "Plugin %s appended" % plugin.sub_menu 
    861855            logging.info(msg) 
    862        
     856 
    863857    def _get_local_plugins(self): 
    864858        """ 
    865         get plugins local to guiframe and others  
     859        get plugins local to guiframe and others 
    866860        """ 
    867861        plugins = [] 
     
    888882                msg += "cannot import plotting plugin.\n %s" % sys.exc_value 
    889883                logging.error(msg) 
    890       
     884 
    891885        return plugins 
    892      
     886 
    893887    def _find_plugins(self, dir="perspectives"): 
    894888        """ 
    895889        Find available perspective plug-ins 
    896          
     890 
    897891        :param dir: directory in which to look for plug-ins 
    898          
     892 
    899893        :return: list of plug-ins 
    900          
     894 
    901895        """ 
    902896        plugins = [] 
    903897        # Go through files in panels directory 
    904898        try: 
    905             list = os.listdir(dir) 
     899            file_list = os.listdir(dir) 
    906900            ## the default panel is the panel is the last plugin added 
    907             for item in list: 
     901            for item in file_list: 
    908902                toks = os.path.splitext(os.path.basename(item)) 
    909903                name = '' 
     
    924918                        else: 
    925919                            (file, path, info) = imp.find_module(name, path) 
    926                             module = imp.load_module( name, file, item, info) 
     920                            module = imp.load_module(name, file, item, info) 
    927921                        if hasattr(module, "PLUGIN_ID"): 
    928                             try:  
     922                            try: 
    929923                                plug = module.Plugin() 
    930924                                if plug.set_default_perspective(): 
    931925                                    self._current_perspective = plug 
    932926                                plugins.append(plug) 
    933                                  
     927 
    934928                                msg = "Found plug-in: %s" % module.PLUGIN_ID 
    935929                                logging.info(msg) 
     
    947941            # Should raise and catch at a higher level and  
    948942            # display error on status bar 
    949             pass   
     943            logging.error(sys.exc_value) 
    950944 
    951945        return plugins 
     
    963957            panel_width = DATAPANEL_WIDTH 
    964958        panel_height = int(self._window_height) 
    965         style = self.__gui_style & (GUIFRAME.MANAGER_ON) 
    966959        if self._data_panel is not None  and (p == self._data_panel): 
    967960            return panel_width, panel_height 
     
    976969            return self._window_width, panel_height 
    977970        return panel_width, panel_height 
    978      
     971 
    979972    def _load_panels(self): 
    980973        """ 
     
    991984                ps = item.get_panels(self) 
    992985                panels.extend(ps) 
    993          
     986 
    994987        # Set up welcome panel 
    995988        #TODO: this needs serious simplification 
     
    1000993            self.defaultPanel.set_frame(welcome_panel) 
    1001994            welcome_panel.Show(False) 
    1002          
     995 
    1003996        self.panels["default"] = self.defaultPanel 
    1004997        size_t_bar = 70 
     
    10121005                frame.SetPosition((0, mac_pos_y + size_t_bar)) 
    10131006            frame.Show(True) 
    1014         #add data panel  
     1007        #add data panel 
    10151008        win = MDIFrame(self, None, 'None', (100, 200)) 
    1016         data_panel = DataPanel(parent=win,  id=-1) 
     1009        data_panel = DataPanel(parent=win, id=-1) 
    10171010        win.set_panel(data_panel) 
    10181011        self.panels["data_panel"] = data_panel 
     
    10291022        for panel_class in panels: 
    10301023            frame = panel_class.get_frame() 
    1031             id = wx.NewId() 
     1024            wx_id = wx.NewId() 
    10321025            # Check whether we need to put this panel in the center pane 
    10331026            if hasattr(panel_class, "CENTER_PANE") and panel_class.CENTER_PANE: 
    10341027                w, h = self._get_panels_size(panel_class) 
    10351028                if panel_class.CENTER_PANE: 
    1036                     self.panels[str(id)] = panel_class 
     1029                    self.panels[str(wx_id)] = panel_class 
    10371030                    _, pos_y = frame.GetPositionTuple() 
    10381031                    frame.SetPosition((d_panel_width + 1, pos_y)) 
     
    10431036                continue 
    10441037            else: 
    1045                 self.panels[str(id)] = panel_class 
     1038                self.panels[str(wx_id)] = panel_class 
    10461039                frame.SetSize((w, h)) 
    10471040                frame.Show(False) 
     
    10611054            else: 
    10621055                self.SetSize((self._window_width, win_height)) 
    1063          
     1056 
    10641057    def update_data(self, prev_data, new_data): 
    10651058        """ 
    10661059        Update the data. 
    10671060        """ 
    1068         prev_id, data_state = self._data_manager.update_data( 
     1061        prev_id, data_state = self._data_manager.update_data( \ 
    10691062                              prev_data=prev_data, new_data=new_data) 
    1070          
     1063 
    10711064        self._data_panel.remove_by_id(prev_id) 
    10721065        self._data_panel.load_data_list(data_state) 
    1073          
     1066 
    10741067    def update_theory(self, data_id, theory, state=None): 
    10751068        """ 
    10761069        Update the theory 
    1077         """  
    1078         data_state = self._data_manager.update_theory(data_id=data_id,  
    1079                                          theory=theory, 
    1080                                          state=state)   
     1070        """ 
     1071        data_state = self._data_manager.update_theory(data_id=data_id, 
     1072                                                      theory=theory, 
     1073                                                      state=state) 
    10811074        wx.CallAfter(self._data_panel.load_data_list, data_state) 
    1082          
     1075 
    10831076    def onfreeze(self, theory_id): 
    10841077        """ 
     
    10881081        for data_state in data_state_list.values(): 
    10891082            new_plot = data_state.get_data() 
    1090              
     1083 
    10911084            wx.PostEvent(self, NewPlotEvent(plot=new_plot, 
    1092                                              title=new_plot.title)) 
    1093          
     1085                                            title=new_plot.title)) 
     1086 
    10941087    def freeze(self, data_id, theory_id): 
    10951088        """ 
    10961089        """ 
    1097         data_state_list = self._data_manager.freeze_theory(data_id=data_id,  
    1098                                                 theory_id=theory_id) 
     1090        data_state_list = self._data_manager.freeze_theory(data_id=data_id, 
     1091                                                           theory_id=theory_id) 
    10991092        self._data_panel.load_data_list(list=data_state_list) 
    11001093        for data_state in data_state_list.values(): 
    11011094            new_plot = data_state.get_data() 
    11021095            wx.PostEvent(self, NewPlotEvent(plot=new_plot, 
    1103                                              title=new_plot.title)) 
    1104          
     1096                                            title=new_plot.title)) 
     1097 
    11051098    def delete_data(self, data): 
    11061099        """ 
     
    11081101        """ 
    11091102        self._current_perspective.delete_data(data) 
    1110          
    1111      
     1103 
     1104 
    11121105    def get_context_menu(self, plotpanel=None): 
    11131106        """ 
    1114         Get the context menu items made available  
    1115         by the different plug-ins.  
     1107        Get the context menu items made available 
     1108        by the different plug-ins. 
    11161109        This function is used by the plotting module 
    11171110        """ 
     
    11221115            menu_list.extend(item.get_context_menu(plotpanel=plotpanel)) 
    11231116        return menu_list 
    1124          
     1117 
    11251118    def get_current_context_menu(self, plotpanel=None): 
    11261119        """ 
    1127         Get the context menu items made available  
    1128         by the current plug-in.  
     1120        Get the context menu items made available 
     1121        by the current plug-in. 
    11291122        This function is used by the plotting module 
    11301123        """ 
     
    11361129            menu_list.extend(item.get_context_menu(plotpanel=plotpanel)) 
    11371130        return menu_list 
    1138              
     1131 
    11391132    def on_panel_close(self, event): 
    11401133        """ 
     
    11501143                break 
    11511144        self.cpanel_on_focus.SetFocus() 
    1152      
    1153      
     1145 
     1146 
    11541147    def popup_panel(self, p): 
    11551148        """ 
    11561149        Add a panel object to the AUI manager 
    1157          
     1150 
    11581151        :param p: panel object to add to the AUI manager 
    1159          
     1152 
    11601153        :return: ID of the event associated with the new panel [int] 
    1161          
     1154 
    11621155        """ 
    11631156        ID = wx.NewId() 
     
    11791172        # Append nummber 
    11801173        captions = self._get_plotpanel_captions() 
     1174        #FIXME: Fix this aweful loop 
    11811175        while (1): 
    1182             caption = windowcaption + '%s'% str(self.graph_num) 
     1176            caption = windowcaption + '%s' % str(self.graph_num) 
    11831177            if caption not in captions: 
    11841178                break 
     
    11881182                break 
    11891183        if p.window_caption.split()[0] not in NOT_SO_GRAPH_LIST: 
    1190             p.window_caption = caption  
     1184            p.window_caption = caption 
    11911185        p.window_name = windowname + str(self.graph_num) 
    1192          
     1186 
    11931187        p.frame.SetTitle(p.window_caption) 
    11941188        p.frame.name = p.window_name 
     
    12141208                    self._data_panel.cb_plotpanel.Append(str(caption), p) 
    12151209        return ID 
    1216      
     1210 
    12171211    def _get_plotpanel_captions(self): 
    12181212        """ 
    12191213        Get all the plotpanel cations 
    1220          
     1214 
    12211215        : return: list of captions 
    12221216        """ 
     
    12241218        for Id in self.plot_panels.keys(): 
    12251219            captions.append(self.plot_panels[Id].window_caption) 
    1226          
     1220 
    12271221        return captions 
    1228          
     1222 
    12291223    def _setup_tool_bar(self): 
    12301224        """ 
     
    12421236        self._update_toolbar_helper() 
    12431237        self._on_toggle_toolbar(event=None) 
    1244      
     1238 
    12451239    def _update_toolbar_helper(self): 
    12461240        """ 
     
    12491243        application_name = 'No Selected Analysis' 
    12501244        panel_name = 'No Panel on Focus' 
    1251         c_panel = self.cpanel_on_focus         
     1245        c_panel = self.cpanel_on_focus 
    12521246        if self._toolbar is  None: 
    12531247            return 
     
    12621256                c_panel_state = None 
    12631257        self._toolbar.update_toolbar(c_panel_state) 
    1264         self._toolbar.update_button(application_name=application_name,  
    1265                                         panel_name=panel_name) 
     1258        self._toolbar.update_button(application_name=application_name, 
     1259                                    panel_name=panel_name) 
    12661260        self._toolbar.Realize() 
    1267          
     1261 
    12681262    def _add_menu_tool(self): 
    12691263        """ 
     
    12871281            if self._tool_menu is not None: 
    12881282                self._menubar.Append(self._tool_menu, '&Tool') 
    1289                  
     1283 
    12901284    def _add_current_plugin_menu(self): 
    12911285        """ 
    12921286        add current plugin menu 
    12931287        Look for plug-in menus 
    1294         Add available plug-in sub-menus.  
     1288        Add available plug-in sub-menus. 
    12951289        """ 
    12961290        if self._menubar is None or self._current_perspective is None \ 
    1297             or self._menubar.GetMenuCount()==0: 
     1291            or self._menubar.GetMenuCount() == 0: 
    12981292            return 
    12991293        #replace or add a new menu for the current plugin 
    1300         
     1294 
    13011295        pos = self._menubar.FindMenu(str(self._applications_menu_name)) 
    13021296        if pos != -1: 
     
    13041298            if menu_list: 
    13051299                for (menu, name) in menu_list: 
    1306                     hidden_menu = self._menubar.Replace(pos, menu, name)  
    1307                     self._applications_menu_name = name  
    1308                 #self._applications_menu_pos = pos 
     1300                    self._menubar.Replace(pos, menu, name) 
     1301                    self._applications_menu_name = name 
    13091302            else: 
    1310                 hidden_menu = self._menubar.Remove(pos) 
     1303                self._menubar.Remove(pos) 
    13111304                self._applications_menu_name = None 
    13121305            #get the position of the menu when it first added 
    1313             self._applications_menu_pos = pos  
    1314              
     1306            self._applications_menu_pos = pos 
     1307 
    13151308        else: 
    13161309            menu_list = self._current_perspective.populate_menu(self) 
     
    13201313                        self._menubar.Append(menu, name) 
    13211314                    else: 
    1322                         self._menubar.Insert(self._applications_menu_pos,  
     1315                        self._menubar.Insert(self._applications_menu_pos, 
    13231316                                             menu, name) 
    13241317                    self._applications_menu_name = name 
    1325                    
     1318 
    13261319    def _add_help_menu(self): 
    13271320        """ 
    13281321        add help menu to menu bar.  Includes welcome page, about page, 
    1329         tutorial PDF and documentation pages.  
     1322        tutorial PDF and documentation pages. 
    13301323        """ 
    13311324        # Help menu 
     
    13361329            # add the welcome panel menu item 
    13371330            if config.WELCOME_PANEL_ON and self.defaultPanel is not None: 
    1338                 id = wx.NewId() 
    1339                 self._help_menu.Append(id, '&Welcome', '') 
    1340                 wx.EVT_MENU(self, id, self.show_welcome_panel) 
     1331                wx_id = wx.NewId() 
     1332                self._help_menu.Append(wx_id, '&Welcome', '') 
     1333                wx.EVT_MENU(self, wx_id, self.show_welcome_panel) 
    13411334 
    13421335        self._help_menu.AppendSeparator() 
    1343         id = wx.NewId() 
    1344         self._help_menu.Append(id, '&Documentation', '') 
    1345         wx.EVT_MENU(self, id, self._onSphinxDocs) 
    1346  
    1347         if config._do_tutorial and (IS_WIN or sys.platform =='darwin'): 
     1336        wx_id = wx.NewId() 
     1337        self._help_menu.Append(wx_id, '&Documentation', '') 
     1338        wx.EVT_MENU(self, wx_id, self._onSphinxDocs) 
     1339 
     1340        if config._do_tutorial and (IS_WIN or sys.platform == 'darwin'): 
    13481341            self._help_menu.AppendSeparator() 
    1349             id = wx.NewId() 
    1350             self._help_menu.Append(id, '&Tutorial', 'Software tutorial') 
    1351             wx.EVT_MENU(self, id, self._onTutorial) 
    1352              
     1342            wx_id = wx.NewId() 
     1343            self._help_menu.Append(wx_id, '&Tutorial', 'Software tutorial') 
     1344            wx.EVT_MENU(self, wx_id, self._onTutorial) 
     1345 
    13531346        if config._do_acknowledge: 
    13541347            self._help_menu.AppendSeparator() 
    1355             id = wx.NewId() 
    1356             self._help_menu.Append(id, '&Acknowledge', 'Acknowledging SasView') 
    1357             wx.EVT_MENU(self, id, self._onAcknowledge) 
    1358          
     1348            wx_id = wx.NewId() 
     1349            self._help_menu.Append(wx_id, '&Acknowledge', 'Acknowledging SasView') 
     1350            wx.EVT_MENU(self, wx_id, self._onAcknowledge) 
     1351 
    13591352        if config._do_aboutbox: 
    13601353            self._help_menu.AppendSeparator() 
    13611354            self._help_menu.Append(wx.ID_ABOUT, '&About', 'Software information') 
    13621355            wx.EVT_MENU(self, wx.ID_ABOUT, self._onAbout) 
    1363          
     1356 
    13641357        # Checking for updates 
    1365         id = wx.NewId() 
    1366         self._help_menu.Append(id,'&Check for update',  
    1367          'Check for the latest version of %s' % config.__appname__) 
    1368         wx.EVT_MENU(self, id, self._check_update) 
     1358        wx_id = wx.NewId() 
     1359        self._help_menu.Append(wx_id, '&Check for update', 
     1360                               'Check for the latest version of %s' % config.__appname__) 
     1361        wx.EVT_MENU(self, wx_id, self._check_update) 
    13691362        self._menubar.Append(self._help_menu, '&Help') 
    1370              
     1363 
    13711364    def _add_menu_view(self): 
    13721365        """ 
     
    13761369            return 
    13771370        self._view_menu = wx.Menu() 
    1378          
    1379         id = wx.NewId() 
     1371 
     1372        wx_id = wx.NewId() 
    13801373        hint = "Display the Grid Window for batch results etc." 
    1381         self._view_menu.Append(id, '&Show Grid Window', hint)  
    1382         wx.EVT_MENU(self, id, self.show_batch_frame) 
    1383          
     1374        self._view_menu.Append(wx_id, '&Show Grid Window', hint) 
     1375        wx.EVT_MENU(self, wx_id, self.show_batch_frame) 
     1376 
    13841377        self._view_menu.AppendSeparator() 
    13851378        style = self.__gui_style & GUIFRAME.MANAGER_ON 
    1386         id = wx.NewId() 
    1387         self._data_panel_menu = self._view_menu.Append(id, 
    1388                                                 '&Show Data Explorer', '') 
    1389         wx.EVT_MENU(self, id, self.show_data_panel) 
     1379        wx_id = wx.NewId() 
     1380        self._data_panel_menu = self._view_menu.Append(wx_id, 
     1381                                                       '&Show Data Explorer', '') 
     1382        wx.EVT_MENU(self, wx_id, self.show_data_panel) 
    13901383        if style == GUIFRAME.MANAGER_ON: 
    13911384            self._data_panel_menu.SetText('Hide Data Explorer') 
    13921385        else: 
    13931386            self._data_panel_menu.SetText('Show Data Explorer') 
    1394    
     1387 
    13951388        self._view_menu.AppendSeparator() 
    1396         id = wx.NewId() 
     1389        wx_id = wx.NewId() 
    13971390        style1 = self.__gui_style & GUIFRAME.TOOLBAR_ON 
    13981391        if style1 == GUIFRAME.TOOLBAR_ON: 
    1399             self._toolbar_menu = self._view_menu.Append(id, '&Hide Toolbar', '') 
     1392            self._toolbar_menu = self._view_menu.Append(wx_id, '&Hide Toolbar', '') 
    14001393        else: 
    1401             self._toolbar_menu = self._view_menu.Append(id, '&Show Toolbar', '') 
    1402         wx.EVT_MENU(self, id, self._on_toggle_toolbar) 
     1394            self._toolbar_menu = self._view_menu.Append(wx_id, '&Show Toolbar', '') 
     1395        wx.EVT_MENU(self, wx_id, self._on_toggle_toolbar) 
    14031396 
    14041397        if custom_config != None: 
    14051398            self._view_menu.AppendSeparator() 
    1406             id = wx.NewId() 
     1399            wx_id = wx.NewId() 
    14071400            hint_ss = "Select the current/default configuration " 
    14081401            hint_ss += "as a startup setting" 
    1409             preference_menu = self._view_menu.Append(id, 'Startup Setting',  
     1402            preference_menu = self._view_menu.Append(wx_id, 'Startup Setting', 
    14101403                                                     hint_ss) 
    1411             wx.EVT_MENU(self, id, self._on_preference_menu) 
    1412              
    1413         id = wx.NewId() 
     1404            wx.EVT_MENU(self, wx_id, self._on_preference_menu) 
     1405 
     1406        wx_id = wx.NewId() 
    14141407        self._view_menu.AppendSeparator() 
    1415         self._view_menu.Append(id, 'Category Manager', 'Edit model categories') 
    1416         wx.EVT_MENU(self, id, self._on_category_manager) 
    1417  
    1418         self._menubar.Append(self._view_menu, '&View')    
    1419           
     1408        self._view_menu.Append(wx_id, 'Category Manager', 'Edit model categories') 
     1409        wx.EVT_MENU(self, wx_id, self._on_category_manager) 
     1410 
     1411        self._menubar.Append(self._view_menu, '&View') 
     1412 
    14201413    def show_batch_frame(self, event=None): 
    14211414        """ 
     
    14251418        self.batch_frame.Show(False) 
    14261419        self.batch_frame.Show(True) 
    1427      
    1428     def  on_category_panel(self, event):   
     1420 
     1421    def  on_category_panel(self, event): 
    14291422        """ 
    14301423        On cat panel 
    14311424        """ 
    14321425        self._on_category_manager(event) 
    1433            
     1426 
    14341427    def _on_category_manager(self, event): 
    14351428        """ 
     
    14401433        frame.SetIcon(icon) 
    14411434 
    1442     def _on_preference_menu(self, event):      
     1435    def _on_preference_menu(self, event): 
    14431436        """ 
    14441437        Build a panel to allow to edit Mask 
     
    14461439        from sas.guiframe.startup_configuration \ 
    14471440        import StartupConfiguration as ConfDialog 
    1448          
     1441 
    14491442        dialog = ConfDialog(parent=self, gui=self.__gui_style) 
    14501443        result = dialog.ShowModal() 
     
    14541447            wx.PostEvent(self, StatusEvent(status="Wrote custom configuration", info='info')) 
    14551448        dialog.Destroy() 
    1456          
     1449 
    14571450    def _add_menu_application(self): 
    14581451        """ 
     
    14611454        add menu application 
    14621455        """ 
    1463         if self._num_perspectives  > 1: 
     1456        if self._num_perspectives > 1: 
    14641457            plug_data_count = False 
    14651458            plug_no_data_count = False 
     
    14711464                    id = wx.NewId() 
    14721465                    if plug.use_data(): 
    1473                          
    1474                         self._applications_menu.InsertCheckItem(pos, id, plug.sub_menu, 
    1475                                       "Switch to analysis: %s" % plug.sub_menu) 
     1466                        self._applications_menu.InsertCheckItem(pos, id, plug.sub_menu, \ 
     1467                            "Switch to analysis: %s" % plug.sub_menu) 
    14761468                        plug_data_count = True 
    14771469                        pos += 1 
    14781470                    else: 
    14791471                        plug_no_data_count = True 
    1480                         self._applications_menu.AppendCheckItem(id, plug.sub_menu, 
    1481                                       "Switch to analysis: %s" % plug.sub_menu) 
     1472                        self._applications_menu.AppendCheckItem(id, plug.sub_menu, \ 
     1473                            "Switch to analysis: %s" % plug.sub_menu) 
    14821474                    wx.EVT_MENU(self, id, plug.on_perspective) 
    14831475 
    1484             if (not plug_data_count or not plug_no_data_count): 
     1476            if not plug_data_count or not plug_no_data_count: 
    14851477                self._applications_menu.RemoveItem(separator) 
    14861478            self._menubar.Append(self._applications_menu, '&Analysis') 
    14871479            self._check_applications_menu() 
    1488              
     1480 
    14891481    def _populate_file_menu(self): 
    14901482        """ 
     
    14991491                    wx.EVT_MENU(self, id, m_handler) 
    15001492                self._file_menu.AppendSeparator() 
    1501                  
     1493 
    15021494        style1 = self.__gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 
    15031495        if OPEN_SAVE_MENU: 
    15041496            id = wx.NewId() 
    15051497            hint_load_file = "read all analysis states saved previously" 
    1506             self._save_appl_menu = self._file_menu.Append(id,  
    1507                                     '&Open Project', hint_load_file) 
     1498            self._save_appl_menu = self._file_menu.Append(id, '&Open Project', hint_load_file) 
    15081499            wx.EVT_MENU(self, id, self._on_open_state_project) 
    1509              
     1500 
    15101501        if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 
    15111502            # some menu of plugin to be seen under file menu 
     
    15131504            hint_load_file += " them into the analysis" 
    15141505            id = wx.NewId() 
    1515             self._save_appl_menu = self._file_menu.Append(id,  
    1516                                     '&Open Analysis', hint_load_file) 
     1506            self._save_appl_menu = self._file_menu.Append(id, 
     1507                                                          '&Open Analysis', hint_load_file) 
    15171508            wx.EVT_MENU(self, id, self._on_open_state_application) 
    1518         if OPEN_SAVE_MENU:         
     1509        if OPEN_SAVE_MENU: 
    15191510            self._file_menu.AppendSeparator() 
    15201511            id = wx.NewId() 
    15211512            self._file_menu.Append(id, '&Save Project', 
    1522                                  'Save the state of the whole analysis') 
     1513                                   'Save the state of the whole analysis') 
    15231514            wx.EVT_MENU(self, id, self._on_save_project) 
    15241515        if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 
    15251516            id = wx.NewId() 
    1526             self._save_appl_menu = self._file_menu.Append(id,  
    1527                                                       '&Save Analysis', 
    1528                         'Save state of the current active analysis panel') 
     1517            self._save_appl_menu = self._file_menu.Append(id, \ 
     1518                '&Save Analysis', 'Save state of the current active analysis panel') 
    15291519            wx.EVT_MENU(self, id, self._on_save_application) 
    1530         if not sys.platform =='darwin': 
     1520        if not sys.platform == 'darwin': 
    15311521            self._file_menu.AppendSeparator() 
    15321522            id = wx.NewId() 
    1533             self._file_menu.Append(id, '&Quit', 'Exit')  
     1523            self._file_menu.Append(id, '&Quit', 'Exit') 
    15341524            wx.EVT_MENU(self, id, self.Close) 
    1535          
     1525 
    15361526    def _add_menu_file(self): 
    15371527        """ 
     
    15421532        # Add sub menus 
    15431533        self._menubar.Append(self._file_menu, '&File') 
    1544          
     1534 
    15451535    def _add_menu_edit(self): 
    15461536        """ 
     
    15511541        # Edit Menu 
    15521542        self._edit_menu = wx.Menu() 
    1553         self._edit_menu.Append(GUIFRAME_ID.UNDO_ID, '&Undo',  
     1543        self._edit_menu.Append(GUIFRAME_ID.UNDO_ID, '&Undo', 
    15541544                               'Undo the previous action') 
    15551545        wx.EVT_MENU(self, GUIFRAME_ID.UNDO_ID, self.on_undo_panel) 
    1556         self._edit_menu.Append(GUIFRAME_ID.REDO_ID, '&Redo',  
     1546        self._edit_menu.Append(GUIFRAME_ID.REDO_ID, '&Redo', 
    15571547                               'Redo the previous action') 
    15581548        wx.EVT_MENU(self, GUIFRAME_ID.REDO_ID, self.on_redo_panel) 
    15591549        self._edit_menu.AppendSeparator() 
    1560         self._edit_menu.Append(GUIFRAME_ID.COPY_ID, '&Copy Params',  
     1550        self._edit_menu.Append(GUIFRAME_ID.COPY_ID, '&Copy Params', 
    15611551                               'Copy parameter values') 
    15621552        wx.EVT_MENU(self, GUIFRAME_ID.COPY_ID, self.on_copy_panel) 
    1563         self._edit_menu.Append(GUIFRAME_ID.PASTE_ID, '&Paste Params',  
     1553        self._edit_menu.Append(GUIFRAME_ID.PASTE_ID, '&Paste Params', 
    15641554                               'Paste parameter values') 
    15651555        wx.EVT_MENU(self, GUIFRAME_ID.PASTE_ID, self.on_paste_panel) 
     
    15701560        #Sub menu for Copy As... 
    15711561        self._edit_menu_copyas.Append(GUIFRAME_ID.COPYEX_ID, 'Copy current tab to Excel', 
    1572                                'Copy parameter values in tabular format') 
     1562                                      'Copy parameter values in tabular format') 
    15731563        wx.EVT_MENU(self, GUIFRAME_ID.COPYEX_ID, self.on_copy_panel) 
    15741564 
    15751565        self._edit_menu_copyas.Append(GUIFRAME_ID.COPYLAT_ID, 'Copy current tab to LaTeX', 
    1576                                'Copy parameter values in tabular format') 
     1566                                      'Copy parameter values in tabular format') 
    15771567        wx.EVT_MENU(self, GUIFRAME_ID.COPYLAT_ID, self.on_copy_panel) 
    15781568 
    15791569 
    1580         self._edit_menu.AppendMenu(GUIFRAME_ID.COPYAS_ID, 'Copy Params as...', self._edit_menu_copyas, 
    1581                                'Copy parameter values in various formats') 
    1582  
     1570        self._edit_menu.AppendMenu(GUIFRAME_ID.COPYAS_ID, 'Copy Params as...', 
     1571                                   self._edit_menu_copyas, 
     1572                                   'Copy parameter values in various formats') 
    15831573 
    15841574        self._edit_menu.AppendSeparator() 
    1585          
     1575 
    15861576        self._edit_menu.Append(GUIFRAME_ID.PREVIEW_ID, '&Report Results', 
    15871577                               'Preview current panel') 
    15881578        wx.EVT_MENU(self, GUIFRAME_ID.PREVIEW_ID, self.on_preview_panel) 
    15891579 
    1590         self._edit_menu.Append(GUIFRAME_ID.RESET_ID, '&Reset Page',  
     1580        self._edit_menu.Append(GUIFRAME_ID.RESET_ID, '&Reset Page', 
    15911581                               'Reset current panel') 
    15921582        wx.EVT_MENU(self, GUIFRAME_ID.RESET_ID, self.on_reset_panel) 
    1593      
    1594         self._menubar.Append(self._edit_menu,  '&Edit') 
     1583 
     1584        self._menubar.Append(self._edit_menu, '&Edit') 
    15951585        self.enable_edit_menu() 
    1596          
     1586 
    15971587    def get_style(self): 
    15981588        """ 
     
    16001590        """ 
    16011591        return  self.__gui_style 
    1602      
     1592 
    16031593    def _add_menu_data(self): 
    16041594        """ 
     
    16101600                for (menu, name) in menu_list: 
    16111601                    self._menubar.Append(menu, name) 
    1612          
    1613                          
     1602 
    16141603    def _on_toggle_toolbar(self, event=None): 
    16151604        """ 
     
    16271616            self._toolbar.Show() 
    16281617        self._toolbar.Realize() 
    1629          
     1618 
    16301619    def _on_status_event(self, evt): 
    16311620        """ 
     
    16341623        # This CallAfter fixes many crashes on MAC. 
    16351624        wx.CallAfter(self.sb.set_status, evt) 
    1636         
     1625 
    16371626    def on_view(self, evt): 
    16381627        """ 
    16391628        A panel was selected to be shown. If it's not already 
    16401629        shown, display it. 
    1641          
     1630 
    16421631        :param evt: menu event 
    1643          
     1632 
    16441633        """ 
    16451634        panel_id = str(evt.GetId()) 
    16461635        self.on_set_plot_focus(self.panels[panel_id]) 
    1647         wx.CallLater(5*TIME_FACTOR, self.set_schedule(True)) 
     1636        wx.CallLater(5 * TIME_FACTOR, self.set_schedule(True)) 
    16481637        self.set_plot_unfocus() 
    1649   
     1638 
    16501639    def show_welcome_panel(self, event): 
    1651         """     
     1640        """ 
    16521641        Display the welcome panel 
    16531642        """ 
    16541643        if self.defaultPanel is None: 
    1655             return  
     1644            return 
    16561645        frame = self.panels['default'].get_frame() 
    16571646        if frame == None: 
     
    16601649        if not frame.IsShown(): 
    16611650            frame.Show(True) 
    1662              
     1651 
    16631652    def on_close_welcome_panel(self): 
    16641653        """ 
     
    16661655        """ 
    16671656        if self.defaultPanel is None: 
    1668             return  
     1657            return 
    16691658        default_panel = self.panels["default"].frame 
    16701659        if default_panel.IsShown(): 
    1671             default_panel.Show(False)  
    1672                  
     1660            default_panel.Show(False) 
     1661 
    16731662    def delete_panel(self, uid): 
    16741663        """ 
     
    16771666        ID = str(uid) 
    16781667        config.printEVT("delete_panel: %s" % ID) 
    1679         try: 
    1680             caption = self.panels[ID].window_caption 
    1681         except: 
    1682             logging.error("delete_panel: No such plot id as %s" % ID) 
    1683             return 
    16841668        if ID in self.panels.keys(): 
    16851669            self.panel_on_focus = None 
     
    16911675 
    16921676            if panel in self.schedule_full_draw_list: 
    1693                 self.schedule_full_draw_list.remove(panel)  
    1694              
     1677                self.schedule_full_draw_list.remove(panel) 
     1678 
    16951679            #delete uid number not str(uid) 
    16961680            if ID in self.plot_panels.keys(): 
     
    16981682            if ID in self.panels.keys(): 
    16991683                del self.panels[ID] 
    1700             return  
    1701              
     1684        else: 
     1685            logging.error("delete_panel: No such plot id as %s" % ID) 
     1686 
    17021687    def create_gui_data(self, data, path=None): 
    17031688        """ 
    17041689        """ 
    17051690        return self._data_manager.create_gui_data(data, path) 
    1706      
     1691 
    17071692    def get_data(self, path): 
    17081693        """ 
     
    17121697        output = [] 
    17131698        error_message = "" 
    1714         basename  = os.path.basename(path) 
     1699        basename = os.path.basename(path) 
    17151700        root, extension = os.path.splitext(basename) 
    17161701        if extension.lower() not in EXTENSIONS: 
     
    17201705            logging.error(log_msg) 
    17211706            return 
    1722          
     1707 
    17231708        #reading a state file 
    17241709        for plug in self.plugins: 
     
    17341719                    except: 
    17351720                        msg = "DataLoader Error: Encounted Non-ASCII character" 
    1736                         msg += "\n(%s)"% sys.exc_value 
    1737                         wx.PostEvent(self, StatusEvent(status=msg,  
    1738                                                 info="error", type="stop")) 
     1721                        msg += "\n(%s)" % sys.exc_value 
     1722                        wx.PostEvent(self, StatusEvent(status=msg, 
     1723                                                       info="error", type="stop")) 
    17391724                        return 
    1740          
     1725 
    17411726        style = self.__gui_style & GUIFRAME.MANAGER_ON 
    17421727        if style == GUIFRAME.MANAGER_ON: 
    17431728            if self._data_panel is not None: 
    17441729                self._data_panel.frame.Show(True) 
    1745        
    1746     def load_from_cmd(self,  path):    
     1730 
     1731    def load_from_cmd(self, path): 
    17471732        """ 
    17481733        load data from cmd or application 
    1749         """  
     1734        """ 
    17501735        if path is None: 
    17511736            return 
     
    17541739            if not os.path.isfile(path) and not os.path.isdir(path): 
    17551740                return 
    1756              
     1741 
    17571742            if os.path.isdir(path): 
    17581743                self.load_folder(path) 
    17591744                return 
    17601745 
    1761         basename  = os.path.basename(path) 
    1762         root, extension = os.path.splitext(basename) 
     1746        basename = os.path.basename(path) 
     1747        _, extension = os.path.splitext(basename) 
    17631748        if extension.lower() not in EXTENSIONS: 
    17641749            self.load_data(path) 
     
    17671752 
    17681753        self._default_save_location = os.path.dirname(path) 
    1769          
    1770     def load_state(self, path, is_project=False):    
     1754 
     1755    def load_state(self, path, is_project=False): 
    17711756        """ 
    17721757        load data from command line or application 
    17731758        """ 
    17741759        if path and (path is not None) and os.path.isfile(path): 
    1775             basename  = os.path.basename(path) 
     1760            basename = os.path.basename(path) 
    17761761            if APPLICATION_STATE_EXTENSION is not None \ 
    17771762                and basename.endswith(APPLICATION_STATE_EXTENSION): 
     
    17841769        else: 
    17851770            wx.PostEvent(self, StatusEvent(status=" ")) 
    1786              
     1771 
    17871772    def load_data(self, path): 
    17881773        """ 
     
    17911776        if not os.path.isfile(path): 
    17921777            return 
    1793         basename  = os.path.basename(path) 
    1794         root, extension = os.path.splitext(basename) 
     1778        basename = os.path.basename(path) 
     1779        _, extension = os.path.splitext(basename) 
    17951780        if extension.lower() in EXTENSIONS: 
    17961781            log_msg = "Data Loader cannot " 
     
    18041789        try: 
    18051790            logging.info("Loading Data...:\n" + str(path) + "\n") 
    1806             temp =  self.loader.load(path) 
     1791            temp = self.loader.load(path) 
    18071792            if temp.__class__.__name__ == "list": 
    18081793                for item in temp: 
     
    18121797                data = self.create_gui_data(temp, path) 
    18131798                output[data.id] = data 
    1814              
     1799 
    18151800            self.add_data(data_list=output) 
    18161801        except: 
     
    18191804            error_message += str(sys.exc_value) + "\n" 
    18201805            logging.error(error_message) 
    1821   
     1806 
    18221807    def load_folder(self, path): 
    18231808        """ 
    18241809        Load entire folder 
    1825         """    
     1810        """ 
    18261811        if not os.path.isdir(path): 
    18271812            return 
     
    18341819                self._data_plugin.get_data(file_list) 
    18351820            else: 
    1836                 return  
     1821                return 
    18371822        except: 
    18381823            error_message = "Error while loading" 
     
    18401825            error_message += str(sys.exc_value) + "\n" 
    18411826            logging.error(error_message) 
    1842              
     1827 
    18431828    def _on_open_state_application(self, event): 
    18441829        """ 
     
    18491834        wx.PostEvent(self, StatusEvent(status="Loading Analysis file...")) 
    18501835        plug_wlist = self._on_open_state_app_helper() 
    1851         dlg = wx.FileDialog(self,  
    1852                             "Choose a file",  
     1836        dlg = wx.FileDialog(self, 
     1837                            "Choose a file", 
    18531838                            self._default_save_location, "", 
    18541839                            plug_wlist) 
     
    18581843                self._default_save_location = os.path.dirname(path) 
    18591844        dlg.Destroy() 
    1860         self.load_state(path=path)   
    1861      
     1845        self.load_state(path=path) 
     1846 
    18621847    def _on_open_state_app_helper(self): 
    18631848        """ 
    1864         Helps '_on_open_state_application()' to find the extension of  
     1849        Helps '_on_open_state_application()' to find the extension of 
    18651850        the current perspective/application 
    18661851        """ 
    18671852        # No current perspective or no extension attr 
    18681853        if self._current_perspective is None: 
    1869             return PLUGINS_WLIST  
     1854            return PLUGINS_WLIST 
    18701855        try: 
    1871             # Find the extension of the perspective  
     1856            # Find the extension of the perspective 
    18721857            # and get that as 1st item in list 
    18731858            ind = None 
     
    18881873 
    18891874        except: 
    1890             plug_wlist = PLUGINS_WLIST  
    1891              
     1875            plug_wlist = PLUGINS_WLIST 
     1876 
    18921877        return plug_wlist 
    1893              
     1878 
    18941879    def _on_open_state_project(self, event): 
    18951880        """ 
     
    18991884            self._default_save_location = os.getcwd() 
    19001885        wx.PostEvent(self, StatusEvent(status="Loading Project file...")) 
    1901         dlg = wx.FileDialog(self,  
    1902                             "Choose a file",  
     1886        dlg = wx.FileDialog(self, 
     1887                            "Choose a file", 
    19031888                            self._default_save_location, "", 
    1904                              APPLICATION_WLIST) 
     1889                            APPLICATION_WLIST) 
    19051890        if dlg.ShowModal() == wx.ID_OK: 
    19061891            path = dlg.GetPath() 
     
    19081893                self._default_save_location = os.path.dirname(path) 
    19091894        dlg.Destroy() 
    1910          
     1895 
    19111896        self.load_state(path=path, is_project=True) 
    1912          
     1897 
    19131898    def _on_save_application(self, event): 
    19141899        """ 
     
    19171902        if self.cpanel_on_focus is not None: 
    19181903            try: 
    1919                 wx.PostEvent(self,  
     1904                wx.PostEvent(self, 
    19201905                             StatusEvent(status="Saving Analysis file...")) 
    19211906                self.cpanel_on_focus.on_save(event) 
    1922                 wx.PostEvent(self,  
     1907                wx.PostEvent(self, 
    19231908                             StatusEvent(status="Completed saving.")) 
    19241909            except: 
    19251910                msg = "Error occurred while saving: " 
    19261911                msg += "To save, the application panel should have a data set.." 
    1927                 wx.PostEvent(self, StatusEvent(status=msg))   
    1928              
     1912                wx.PostEvent(self, StatusEvent(status=msg)) 
     1913 
    19291914    def _on_save_project(self, event): 
    19301915        """ 
     
    19341919            return 
    19351920        wx.PostEvent(self, StatusEvent(status="Saving Project file...")) 
    1936         reader, ext = self._current_perspective.get_extensions() 
    19371921        path = None 
    19381922        extension = '*' + APPLICATION_STATE_EXTENSION 
    19391923        dlg = wx.FileDialog(self, "Save Project file", 
    19401924                            self._default_save_location, "sasview_proj", 
    1941                              extension,  
    1942                              wx.SAVE) 
     1925                            extension, 
     1926                            wx.SAVE) 
    19431927        if dlg.ShowModal() == wx.ID_OK: 
    19441928            path = dlg.GetPath() 
     
    19561940                if temp is not None: 
    19571941                    doc = temp 
    1958              
     1942 
    19591943            # Write the XML document 
    19601944            extens = APPLICATION_STATE_EXTENSION 
     
    19721956                msg += "No project was saved to %s" % (str(path)) 
    19731957                logging.error(msg) 
    1974                 wx.PostEvent(self,StatusEvent(status=msg)) 
     1958                wx.PostEvent(self, StatusEvent(status=msg)) 
    19751959        except: 
    19761960            msg = "Error occurred while saving: " 
    19771961            msg += "To save, at least one application panel " 
    19781962            msg += "should have a data set.." 
    1979             wx.PostEvent(self, StatusEvent(status=msg))     
    1980                      
     1963            wx.PostEvent(self, StatusEvent(status=msg)) 
     1964 
    19811965    def on_save_helper(self, doc, reader, panel, path): 
    19821966        """ 
    19831967        Save state into a file 
    19841968        """ 
    1985         try: 
    1986             if reader is not None: 
    1987                 # case of a panel with multi-pages 
    1988                 if hasattr(panel, "opened_pages"): 
    1989                     for uid, page in panel.opened_pages.iteritems(): 
    1990                         data = page.get_data() 
    1991                         # state must be cloned 
    1992                         state = page.get_state().clone() 
    1993                         if data is not None: 
    1994                             new_doc = reader.write_toXML(data, state) 
    1995                             if doc != None and hasattr(doc, "firstChild"): 
    1996                                 child = new_doc.firstChild.firstChild 
    1997                                 doc.firstChild.appendChild(child)   
    1998                             else: 
    1999                                 doc = new_doc  
    2000                 # case of only a panel 
    2001                 else: 
    2002                     data = panel.get_data() 
    2003                     state = panel.get_state() 
     1969        if reader is not None: 
     1970            # case of a panel with multi-pages 
     1971            if hasattr(panel, "opened_pages"): 
     1972                for _, page in panel.opened_pages.iteritems(): 
     1973                    data = page.get_data() 
     1974                    # state must be cloned 
     1975                    state = page.get_state().clone() 
    20041976                    if data is not None: 
    20051977                        new_doc = reader.write_toXML(data, state) 
    20061978                        if doc != None and hasattr(doc, "firstChild"): 
    20071979                            child = new_doc.firstChild.firstChild 
    2008                             doc.firstChild.appendChild(child)   
     1980                            doc.firstChild.appendChild(child) 
    20091981                        else: 
    2010                             doc = new_doc  
    2011         except:  
    2012             raise 
    2013             #pass 
    2014  
     1982                            doc = new_doc 
     1983            # case of only a panel 
     1984            else: 
     1985                data = panel.get_data() 
     1986                state = panel.get_state() 
     1987                if data is not None: 
     1988                    new_doc = reader.write_toXML(data, state) 
     1989                    if doc != None and hasattr(doc, "firstChild"): 
     1990                        child = new_doc.firstChild.firstChild 
     1991                        doc.firstChild.appendChild(child) 
     1992                    else: 
     1993                        doc = new_doc 
    20151994        return doc 
    20161995 
     
    20212000        message = "\nDo you really want to exit this application?        \n\n" 
    20222001        dial = wx.MessageDialog(self, message, 'Confirm Exit', 
    2023                            wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION) 
     2002                                wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) 
    20242003        if dial.ShowModal() == wx.ID_YES: 
    20252004            return True 
    20262005        else: 
    2027             return False     
    2028          
     2006            return False 
     2007 
    20292008    def WindowClose(self, event=None): 
    20302009        """ 
     
    20352014            _pylab_helpers.Gcf.figs = {} 
    20362015            self.Close() 
    2037              
     2016 
    20382017    def Close(self, event=None): 
    20392018        """ 
     
    20422021        wx.Exit() 
    20432022        sys.exit() 
    2044              
    2045     def _check_update(self, event=None):  
     2023 
     2024    def _check_update(self, event=None): 
    20462025        """ 
    20472026        Check with the deployment server whether a new version 
     
    20512030        """ 
    20522031        try: 
    2053             conn = httplib.HTTPConnection(config.__update_URL__[0],  
    2054                               timeout=3.0) 
     2032            conn = httplib.HTTPConnection(config.__update_URL__[0], 
     2033                                          timeout=3.0) 
    20552034            conn.request("GET", config.__update_URL__[1]) 
    20562035            res = conn.getresponse() 
     
    20592038        except: 
    20602039            content = "0.0.0" 
    2061         
     2040 
    20622041        version = content.strip() 
    20632042        if len(re.findall('\d+\.\d+\.\d+$', version)) < 0: 
    20642043            content = "0.0.0" 
    2065         self._process_version(content, standalone=event==None) 
    2066      
     2044        self._process_version(content, standalone=event == None) 
     2045 
    20672046    def _process_version(self, version, standalone=True): 
    20682047        """ 
     
    20712050        version number has been obtained. If the check is being done in the 
    20722051        background, the user will not be notified unless there's an update. 
    2073          
     2052 
    20742053        :param version: version string 
    2075         :param standalone: True of the update is being checked in  
     2054        :param standalone: True of the update is being checked in 
    20762055           the background, False otherwise. 
    2077             
     2056 
    20782057        """ 
    20792058        try: 
     
    20882067                    webbrowser.open(config.__download_page__) 
    20892068                else: 
    2090                     msg +=  "See the help menu to download it."  
     2069                    msg += "See the help menu to download it." 
    20912070                self.SetStatusText(msg) 
    20922071            else: 
     
    21032082                msg += " Please try again later." 
    21042083                self.SetStatusText(msg) 
    2105                      
     2084 
    21062085    def _onAcknowledge(self, evt): 
    21072086        """ 
    21082087        Pop up the acknowledge dialog 
    2109          
     2088 
    21102089        :param evt: menu event 
    2111          
     2090 
    21122091        """ 
    21132092        if config._do_acknowledge: 
     
    21152094            dialog = AcknowledgeBox.DialogAcknowledge(None, -1, "") 
    21162095            dialog.ShowModal() 
    2117                       
     2096 
    21182097    def _onAbout(self, evt): 
    21192098        """ 
    21202099        Pop up the about dialog 
    2121          
     2100 
    21222101        :param evt: menu event 
    2123          
     2102 
    21242103        """ 
    21252104        if config._do_aboutbox: 
    21262105            import sas.guiframe.aboutbox as AboutBox 
    21272106            dialog = AboutBox.DialogAbout(None, -1, "") 
    2128             dialog.ShowModal()    
    2129                       
     2107            dialog.ShowModal() 
     2108 
    21302109    def _onTutorial(self, evt): 
    21312110        """ 
    21322111        Pop up the tutorial dialog 
    2133          
     2112 
    21342113        :param evt: menu event 
    2135          
    2136         """ 
    2137         if config._do_tutorial:    
     2114 
     2115        """ 
     2116        if config._do_tutorial: 
    21382117            path = config.TUTORIAL_PATH 
    21392118            if IS_WIN: 
     
    21422121                    dialog = PDFFrame(None, -1, "Tutorial", path) 
    21432122                    # put icon 
    2144                     self.put_icon(dialog)   
    2145                     dialog.Show(True)  
     2123                    self.put_icon(dialog) 
     2124                    dialog.Show(True) 
    21462125                except: 
    21472126                    logging.error("Error in _onTutorial: %s" % sys.exc_value) 
     
    21752154        'documentation' is clicked. Calls DocumentationWindow with the top 
    21762155        level path of "index.html" 
    2177          
     2156 
    21782157        :param evt: menu event 
    21792158        """ 
     
    21812160        # different place than they would otherwise. 
    21822161        from documentation_window import DocumentationWindow 
    2183          
    2184         sphinx_doc_viewer = DocumentationWindow(self, -1, "index.html", \ 
    2185                                                 "General Help") 
     2162        DocumentationWindow(self, -1, "index.html", "General Help") 
    21862163 
    21872164    def set_manager(self, manager): 
    21882165        """ 
    21892166        Sets the application manager for this frame 
    2190          
     2167 
    21912168        :param manager: frame manager 
    21922169        """ 
    21932170        self.app_manager = manager 
    2194          
     2171 
    21952172    def post_init(self): 
    21962173        """ 
    2197         This initialization method is called after the GUI  
     2174        This initialization method is called after the GUI 
    21982175        has been created and all plug-ins loaded. It calls 
    21992176        the post_init() method of each plug-in (if it exists) 
     
    22032180            if hasattr(item, "post_init"): 
    22042181                item.post_init() 
    2205          
     2182 
    22062183    def set_default_perspective(self): 
    22072184        """ 
    2208         Choose among the plugin the first plug-in that has  
     2185        Choose among the plugin the first plug-in that has 
    22092186        "set_default_perspective" method and its return value is True will be 
    22102187        as a default perspective when the welcome page is closed 
     
    22142191                if item.set_default_perspective(): 
    22152192                    item.on_perspective(event=None) 
    2216                     return  
    2217          
     2193                    return 
     2194 
    22182195    def set_perspective(self, panels): 
    22192196        """ 
     
    22212198        Opens all the panels in the list, and closes 
    22222199        all the others. 
    2223          
     2200 
    22242201        :param panels: list of panels 
    22252202        """ 
     
    22282205            if hasattr(self.panels[item], "ALWAYS_ON"): 
    22292206                if self.panels[item].ALWAYS_ON: 
    2230                     continue  
     2207                    continue 
    22312208            if self.panels[item] == None: 
    22322209                continue 
     
    22522229                    if frame.IsShown(): 
    22532230                        frame.Show(False) 
    2254          
     2231 
    22552232    def show_data_panel(self, event=None, action=True): 
    22562233        """ 
     
    22632240        frame = pane.get_frame() 
    22642241        if label == 'Show Data Explorer': 
    2265             if action:  
     2242            if action: 
    22662243                frame.Show(True) 
    22672244            self.__gui_style = self.__gui_style | GUIFRAME.MANAGER_ON 
     
    22782255        if self._data_manager is not None: 
    22792256            self._data_manager.add_data(data_list) 
    2280          
     2257 
    22812258    def add_data(self, data_list): 
    22822259        """ 
    22832260        receive a dictionary of data from loader 
    22842261        store them its data manager if possible 
    2285         send to data the current active perspective if the data panel  
    2286         is not active.  
     2262        send to data the current active perspective if the data panel 
     2263        is not active. 
    22872264        :param data_list: dictionary of data's ID and value Data 
    22882265        """ 
     
    22932270            data_state = self._data_manager.get_data_state(data_list.keys()) 
    22942271            self._data_panel.load_data_list(data_state) 
    2295         #if the data panel is shown wait for the user to press a button  
     2272        #if the data panel is shown wait for the user to press a button 
    22962273        #to send data to the current perspective. if the panel is not 
    22972274        #show  automatically send the data to the current perspective 
    22982275        style = self.__gui_style & GUIFRAME.MANAGER_ON 
    22992276        if style == GUIFRAME.MANAGER_ON: 
    2300             #wait for button press from the data panel to set_data  
     2277            #wait for button press from the data panel to set_data 
    23012278            if self._data_panel is not None: 
    23022279                self._data_panel.frame.Show(True) 
     
    23042281            #automatically send that to the current perspective 
    23052282            self.set_data(data_id=data_list.keys()) 
    2306         
    2307     def set_data(self, data_id, theory_id=None):  
     2283 
     2284    def set_data(self, data_id, theory_id=None): 
    23082285        """ 
    23092286        set data to current perspective 
     
    23162293            msg = "Guiframe does not have a current perspective" 
    23172294            logging.info(msg) 
    2318              
     2295 
    23192296    def set_theory(self, state_id, theory_id=None): 
    23202297        """ 
     
    23312308            msg = "Guiframe does not have a current perspective" 
    23322309            logging.info(msg) 
    2333              
    2334     def plot_data(self,  state_id, data_id=None, 
     2310 
     2311    def plot_data(self, state_id, data_id=None, 
    23352312                  theory_id=None, append=False): 
    23362313        """ 
    23372314        send a list of data to plot 
    23382315        """ 
    2339         total_plot_list = [] 
    23402316        data_list, _ = self._data_manager.get_by_id(data_id) 
    23412317        _, temp_list_theory = self._data_manager.get_by_id(theory_id) 
     
    23502326                    message = "cannot append plot. No plot panel on focus!" 
    23512327                    message += "please click on any available plot to set focus" 
    2352                     wx.PostEvent(self, StatusEvent(status=message,  
     2328                    wx.PostEvent(self, StatusEvent(status=message, 
    23532329                                                   info='warning')) 
    2354                     return  
     2330                    return 
    23552331                else: 
    23562332                    if self.enable_add_data(new_plot): 
     
    23592335                        message = "Only 1D Data can be append to" 
    23602336                        message += " plot panel containing 1D data.\n" 
    2361                         message += "%s not be appended.\n" %str(new_plot.name) 
     2337                        message += "%s not be appended.\n" % str(new_plot.name) 
    23622338                        message += "try new plot option.\n" 
    2363                         wx.PostEvent(self, StatusEvent(status=message,  
    2364                                                    info='warning')) 
     2339                        wx.PostEvent(self, StatusEvent(status=message, 
     2340                                                       info='warning')) 
    23652341            else: 
    23662342                #if not append then new plot 
     
    23742350            title = "PLOT " + str(new_plot.title) 
    23752351            wx.PostEvent(self, NewPlotEvent(plot=new_plot, 
    2376                                                   title=title, 
    2377                                                   group_id = new_plot.group_id)) 
    2378              
     2352                                            title=title, 
     2353                                            group_id=new_plot.group_id)) 
     2354 
    23792355    def remove_data(self, data_id, theory_id=None): 
    23802356        """ 
     
    23872363        for plug in self.plugins: 
    23882364            plug.delete_data(temp) 
    2389         total_plot_list = [] 
    23902365        data_list, _ = self._data_manager.get_by_id(data_id) 
    23912366        _, temp_list_theory = self._data_manager.get_by_id(theory_id) 
     
    23982373            for group_id in new_plot.list_group_id: 
    23992374                wx.PostEvent(self, NewPlotEvent(id=id, 
    2400                                                    group_id=group_id, 
    2401                                                    action='remove')) 
     2375                                                group_id=group_id, 
     2376                                                action='remove')) 
    24022377                #remove res plot: Todo: improve 
    24032378                wx.CallAfter(self._remove_res_plot, id) 
    2404         self._data_manager.delete_data(data_id=data_id,  
     2379        self._data_manager.delete_data(data_id=data_id, 
    24052380                                       theory_id=theory_id) 
    2406          
     2381 
    24072382    def _remove_res_plot(self, id): 
    24082383        """ 
    24092384        Try to remove corresponding res plot 
    2410          
     2385 
    24112386        : param id: id of the data 
    24122387        """ 
    24132388        try: 
    2414             wx.PostEvent(self, NewPlotEvent(id=("res"+str(id)), 
    2415                                            group_id=("res"+str(id)), 
    2416                                            action='remove')) 
     2389            wx.PostEvent(self, NewPlotEvent(id=("res" + str(id)), 
     2390                                            group_id=("res" + str(id)), 
     2391                                            action='remove')) 
    24172392        except: 
    2418             pass 
    2419      
     2393            logging.error(sys.exc_value) 
     2394 
    24202395    def save_data1d(self, data, fname): 
    24212396        """ 
     
    24242399        default_name = fname 
    24252400        wildcard = "Text files (*.txt)|*.txt|"\ 
    2426                     "CanSAS 1D files(*.xml)|*.xml"  
     2401                    "CanSAS 1D files(*.xml)|*.xml" 
    24272402        path = None 
    24282403        dlg = wx.FileDialog(self, "Choose a file", 
    24292404                            self._default_save_location, 
    2430                             default_name, wildcard , wx.SAVE) 
    2431         
     2405                            default_name, wildcard, wx.SAVE) 
     2406 
    24322407        if dlg.ShowModal() == wx.ID_OK: 
    24332408            path = dlg.GetPath() 
     
    24412416            path = os.path.splitext(path)[0] + format 
    24422417            mypath = os.path.basename(path) 
    2443              
    2444             #TODO: This is bad design. The DataLoader is designed  
    2445             #to recognize extensions. 
    2446             # It should be a simple matter of calling the . 
    2447             #save(file, data, '.xml') method 
    2448             # of the sas.dataloader.loader.Loader class. 
    2449             from sas.dataloader.loader import  Loader 
    2450             #Instantiate a loader  
    2451             loader = Loader()  
     2418 
     2419            #Instantiate a loader 
     2420            loader = Loader() 
    24522421            format = ".txt" 
    24532422            if os.path.splitext(mypath)[1].lower() == format: 
     
    24652434                self._default_save_location = os.path.dirname(path) 
    24662435            except: 
    2467                 pass     
     2436                pass 
    24682437        dlg.Destroy() 
    2469          
    2470          
     2438 
     2439 
    24712440    def _onsaveTXT(self, data, path): 
    24722441        """ 
    2473         Save file as txt   
     2442        Save file as txt 
    24742443        :TODO: Refactor and remove this method. See TODO in _onSave. 
    24752444        """ 
     
    24932462            else: 
    24942463                out.write("<X>   <Y>\n") 
    2495                  
     2464 
    24962465            for i in range(len(data.x)): 
    24972466                if has_errors: 
    24982467                    if data.dx != None and data.dx != []: 
    24992468                        if  data.dx[i] != None: 
    2500                             out.write("%g  %g  %g  %g\n" % (data.x[i],  
    2501                                                         data.y[i], 
    2502                                                         data.dy[i], 
    2503                                                         data.dx[i])) 
     2469                            out.write("%g  %g  %g  %g\n" % (data.x[i], 
     2470                                                            data.y[i], 
     2471                                                            data.dy[i], 
     2472                                                            data.dx[i])) 
    25042473                        else: 
    2505                             out.write("%g  %g  %g\n" % (data.x[i],  
     2474                            out.write("%g  %g  %g\n" % (data.x[i], 
    25062475                                                        data.y[i], 
    25072476                                                        data.dy[i])) 
    25082477                    else: 
    2509                         out.write("%g  %g  %g\n" % (data.x[i],  
     2478                        out.write("%g  %g  %g\n" % (data.x[i], 
    25102479                                                    data.y[i], 
    25112480                                                    data.dy[i])) 
    25122481                else: 
    2513                     out.write("%g  %g\n" % (data.x[i],  
     2482                    out.write("%g  %g\n" % (data.x[i], 
    25142483                                            data.y[i])) 
    2515             out.close()   
    2516                               
     2484            out.close() 
     2485 
    25172486    def show_data1d(self, data, name): 
    25182487        """ 
    25192488        Show data dialog 
    2520         """    
     2489        """ 
    25212490        try: 
    25222491            xmin = min(data.x) 
    25232492            ymin = min(data.y) 
    25242493        except: 
    2525             msg = "Unable to find min/max of \n data named %s"% \ 
    2526                         data.filename   
     2494            msg = "Unable to find min/max of \n data named %s" % \ 
     2495                        data.filename 
    25272496            wx.PostEvent(self, StatusEvent(status=msg, 
    2528                                        info="error")) 
     2497                                           info="error")) 
    25292498            raise ValueError, msg 
    25302499        ## text = str(data) 
    25312500        text = data.__str__() 
    25322501        text += 'Data Min Max:\n' 
    2533         text += 'X_min = %s:  X_max = %s\n'% (xmin, max(data.x)) 
    2534         text += 'Y_min = %s:  Y_max = %s\n'% (ymin, max(data.y)) 
     2502        text += 'X_min = %s:  X_max = %s\n' % (xmin, max(data.x)) 
     2503        text += 'Y_min = %s:  Y_max = %s\n' % (ymin, max(data.y)) 
    25352504        if data.dy != None: 
    2536             text += 'dY_min = %s:  dY_max = %s\n'% (min(data.dy), max(data.dy)) 
     2505            text += 'dY_min = %s:  dY_max = %s\n' % (min(data.dy), max(data.dy)) 
    25372506        text += '\nData Points:\n' 
    25382507        x_st = "X" 
     
    25472516                dx_val = 0.0 
    25482517            if data.dxl != None and len(data.dxl) > index: 
    2549                 if index == 0:  
     2518                if index == 0: 
    25502519                    x_st = "Xl" 
    25512520                dx_val = data.dxl[index] 
    25522521            elif data.dxw != None and len(data.dxw) > index: 
    2553                 if index == 0:  
     2522                if index == 0: 
    25542523                    x_st = "Xw" 
    25552524                dx_val = data.dxw[index] 
    2556              
     2525 
    25572526            if index == 0: 
    2558                 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n"% x_st 
     2527                text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 
    25592528            text += "%s \t%s \t%s \t%s \t%s\n" % (index, 
    2560                                             data.x[index],  
    2561                                             data.y[index], 
    2562                                             dy_val, 
    2563                                             dx_val) 
     2529                                                  data.x[index], 
     2530                                                  data.y[index], 
     2531                                                  dy_val, 
     2532                                                  dx_val) 
    25642533        from pdfview import TextFrame 
    2565         frame = TextFrame(None, -1, "Data Info: %s"% data.name, text)  
     2534        frame = TextFrame(None, -1, "Data Info: %s" % data.name, text) 
    25662535        # put icon 
    2567         self.put_icon(frame)  
    2568         frame.Show(True)  
    2569              
    2570     def save_data2d(self, data, fname):     
     2536        self.put_icon(frame) 
     2537        frame.Show(True) 
     2538 
     2539    def save_data2d(self, data, fname): 
    25712540        """ 
    25722541        Save data2d dialog 
     
    25762545        dlg = wx.FileDialog(self, "Choose a file", 
    25772546                            self._default_save_location, 
    2578                             default_name, wildcard , wx.SAVE) 
    2579         
     2547                            default_name, wildcard, wx.SAVE) 
     2548 
    25802549        if dlg.ShowModal() == wx.ID_OK: 
    25812550            path = dlg.GetPath() 
     
    25892558            path = os.path.splitext(path)[0] + format 
    25902559            mypath = os.path.basename(path) 
    2591              
    2592             #TODO: This is bad design. The DataLoader is designed  
    2593             #to recognize extensions. 
    2594             # It should be a simple matter of calling the . 
    2595             #save(file, data, '.xml') method 
    2596             # of the DataLoader.loader.Loader class. 
    2597             from sas.dataloader.loader import  Loader 
    2598             #Instantiate a loader  
    2599             loader = Loader()  
     2560 
     2561            #Instantiate a loader 
     2562            loader = Loader() 
    26002563 
    26012564            format = ".dat" 
     
    26082571                self._default_save_location = os.path.dirname(path) 
    26092572            except: 
    2610                 pass     
    2611         dlg.Destroy()  
    2612                               
     2573                pass 
     2574        dlg.Destroy() 
     2575 
    26132576    def show_data2d(self, data, name): 
    26142577        """ 
    26152578        Show data dialog 
    2616         """    
    2617  
    2618         wx.PostEvent(self, StatusEvent(status = "Gathering Data2D Info.",  
    2619                                        type = 'start' )) 
    2620         text = data.__str__()  
     2579        """ 
     2580        wx.PostEvent(self, StatusEvent(status="Gathering Data2D Info.", 
     2581                                       type='start')) 
     2582        text = data.__str__() 
    26212583        text += 'Data Min Max:\n' 
    2622         text += 'I_min = %s\n'% min(data.data) 
    2623         text += 'I_max = %s\n\n'% max(data.data) 
     2584        text += 'I_min = %s\n' % min(data.data) 
     2585        text += 'I_max = %s\n\n' % max(data.data) 
    26242586        text += 'Data (First 2501) Points:\n' 
    26252587        text += 'Data columns include err(I).\n' 
     
    26292591        dx_val = 0.0 
    26302592        dy_val = 0.0 
    2631         #mask_val = True 
    26322593        len_data = len(data.qx_data) 
    26332594        for index in xrange(0, len_data): 
     
    26352596            y_val = data.qy_data[index] 
    26362597            i_val = data.data[index] 
    2637             if data.err_data != None:  
     2598            if data.err_data != None: 
    26382599                di_val = data.err_data[index] 
    2639             if data.dqx_data != None:  
     2600            if data.dqx_data != None: 
    26402601                dx_val = data.dqx_data[index] 
    2641             if data.dqy_data != None:  
     2602            if data.dqy_data != None: 
    26422603                dy_val = data.dqy_data[index] 
    2643    
     2604 
    26442605            text += "%s \t%s \t%s \t%s \t%s \t%s \t%s\n" % (index, 
    2645                                             x_val,  
    2646                                             y_val, 
    2647                                             i_val, 
    2648                                             di_val, 
    2649                                             dx_val, 
    2650                                             dy_val) 
     2606                                                            x_val, 
     2607                                                            y_val, 
     2608                                                            i_val, 
     2609                                                            di_val, 
     2610                                                            dx_val, 
     2611                                                            dy_val) 
    26512612            # Takes too long time for typical data2d: Break here 
    26522613            if index >= 2500: 
     
    26552616 
    26562617        from pdfview import TextFrame 
    2657         frame = TextFrame(None, -1, "Data Info: %s"% data.name, text)  
     2618        frame = TextFrame(None, -1, "Data Info: %s" % data.name, text) 
    26582619        # put icon 
    26592620        self.put_icon(frame) 
    2660         frame.Show(True)  
    2661         wx.PostEvent(self, StatusEvent(status = "Data2D Info Displayed",  
    2662                                        type = 'stop' )) 
    2663                                    
     2621        frame.Show(True) 
     2622        wx.PostEvent(self, StatusEvent(status="Data2D Info Displayed", 
     2623                                       type='stop')) 
     2624 
    26642625    def set_current_perspective(self, perspective): 
    26652626        """ 
    2666         set the current active perspective  
     2627        set the current active perspective 
    26672628        """ 
    26682629        self._current_perspective = perspective 
     
    26802641                            else: 
    26812642                                frame.Show(False) 
    2682                             #break                
    26832643            name = self._current_perspective.sub_menu 
    26842644            if self._data_panel is not None: 
     
    26872647            #Set the SasView title 
    26882648            self._set_title_name(name) 
    2689              
     2649 
    26902650    def _set_title_name(self, name): 
    26912651        """ 
    26922652        Set the SasView title w/ the current application name 
    2693          
     2653 
    26942654        : param name: application name [string] 
    26952655        """ 
     
    26972657        title = self.title + "  - " + name + " -" 
    26982658        self.SetTitle(title) 
    2699              
     2659 
    27002660    def _check_applications_menu(self): 
    27012661        """ 
     
    27102670                            menu.Check(True) 
    27112671                        else: 
    2712                             menu.Check(False)  
    2713              
     2672                            menu.Check(False) 
     2673 
    27142674    def enable_add_data(self, new_plot): 
    27152675        """ 
     
    27212681        is_theory = len(self.panel_on_focus.plots) <= 1 and \ 
    27222682            self.panel_on_focus.plots.values()[0].__class__.__name__ == "Theory1D" 
    2723              
     2683 
    27242684        is_data2d = hasattr(new_plot, 'data') 
    2725          
     2685 
    27262686        is_data1d = self.panel_on_focus.__class__.__name__ == "ModelPanel1D"\ 
    27272687            and self.panel_on_focus.group_id is not None 
    27282688        has_meta_data = hasattr(new_plot, 'meta_data') 
    2729          
     2689 
    27302690        #disable_add_data if the data is being recovered from  a saved state file. 
    27312691        is_state_data = False 
    27322692        if has_meta_data: 
    2733             if 'invstate' in new_plot.meta_data:  
     2693            if 'invstate' in new_plot.meta_data: 
    27342694                is_state_data = True 
    2735             if  'prstate' in new_plot.meta_data:  
     2695            if  'prstate' in new_plot.meta_data: 
    27362696                is_state_data = True 
    2737             if  'fitstate' in new_plot.meta_data:  
     2697            if  'fitstate' in new_plot.meta_data: 
    27382698                is_state_data = True 
    2739      
     2699 
    27402700        return is_data1d and not is_data2d and not is_theory and not is_state_data 
    2741      
     2701 
    27422702    def check_multimode(self, perspective=None): 
    27432703        """ 
     
    27562716        self._data_panel.rb_single_mode.Enable(flag) 
    27572717        self._data_panel.rb_batch_mode.Enable(flag) 
    2758                  
    2759  
    2760      
     2718 
    27612719    def enable_edit_menu(self): 
    27622720        """ 
     
    27752733            #Copy menu 
    27762734            flag = self.cpanel_on_focus.get_copy_flag() 
    2777             #self._edit_menu.ENABLE(GUIFRAME_ID.COPYAS_ID,flag) 
    27782735            self._edit_menu_copyas.Enable(GUIFRAME_ID.COPYEX_ID, flag) 
    27792736            self._edit_menu_copyas.Enable(GUIFRAME_ID.COPYLAT_ID, flag) 
     
    27892746            self._edit_menu.Enable(GUIFRAME_ID.COPY_ID, flag) 
    27902747            self._edit_menu.Enable(GUIFRAME_ID.PASTE_ID, flag) 
    2791             #self._edit_menu.Enable(GUIFRAME_ID.COPYEX_ID, flag) 
    2792             #self._edit_menu.Enable(GUIFRAME_ID.COPYLAT_ID, flag) 
    2793             #self._edit_menu.Enable(GUIFRAME_ID.COPYAS_ID, flag) 
    27942748            self._edit_menu.Enable(GUIFRAME_ID.PREVIEW_ID, flag) 
    27952749            self._edit_menu.Enable(GUIFRAME_ID.RESET_ID, flag) 
    2796              
     2750 
    27972751    def on_undo_panel(self, event=None): 
    27982752        """ 
     
    28012755        if self.cpanel_on_focus is not None: 
    28022756            self.cpanel_on_focus.on_undo(event) 
    2803              
     2757 
    28042758    def on_redo_panel(self, event=None): 
    28052759        """ 
     
    28082762        if self.cpanel_on_focus is not None: 
    28092763            self.cpanel_on_focus.on_redo(event) 
    2810              
     2764 
    28112765    def on_copy_panel(self, event=None): 
    28122766        """ 
     
    28152769        if self.cpanel_on_focus is not None: 
    28162770            self.cpanel_on_focus.on_copy(event) 
    2817              
     2771 
    28182772    def on_paste_panel(self, event=None): 
    28192773        """ 
     
    28222776        if self.cpanel_on_focus is not None: 
    28232777            self.cpanel_on_focus.on_paste(event) 
    2824                      
     2778 
    28252779    def on_bookmark_panel(self, event=None): 
    28262780        """ 
     
    28292783        if self.cpanel_on_focus is not None: 
    28302784            self.cpanel_on_focus.on_bookmark(event) 
    2831              
     2785 
    28322786    def append_bookmark(self, event=None): 
    28332787        """ 
     
    28352789        """ 
    28362790        self._toolbar.append_bookmark(event) 
    2837              
     2791 
    28382792    def on_save_panel(self, event=None): 
    28392793        """ 
     
    28422796        if self.cpanel_on_focus is not None: 
    28432797            self.cpanel_on_focus.on_save(event) 
    2844              
     2798 
    28452799    def on_preview_panel(self, event=None): 
    28462800        """ 
     
    28492803        if self.cpanel_on_focus is not None: 
    28502804            self.cpanel_on_focus.on_preview(event) 
    2851              
     2805 
    28522806    def on_print_panel(self, event=None): 
    28532807        """ 
     
    28562810        if self.cpanel_on_focus is not None: 
    28572811            self.cpanel_on_focus.on_print(event) 
    2858              
     2812 
    28592813    def on_zoom_panel(self, event=None): 
    28602814        """ 
     
    28632817        if self.cpanel_on_focus is not None: 
    28642818            self.cpanel_on_focus.on_zoom(event) 
    2865              
     2819 
    28662820    def on_zoom_in_panel(self, event=None): 
    28672821        """ 
     
    28702824        if self.cpanel_on_focus is not None: 
    28712825            self.cpanel_on_focus.on_zoom_in(event) 
    2872              
     2826 
    28732827    def on_zoom_out_panel(self, event=None): 
    28742828        """ 
     
    28772831        if self.cpanel_on_focus is not None: 
    28782832            self.cpanel_on_focus.on_zoom_out(event) 
    2879              
     2833 
    28802834    def on_drag_panel(self, event=None): 
    28812835        """ 
     
    28842838        if self.cpanel_on_focus is not None: 
    28852839            self.cpanel_on_focus.on_drag(event) 
    2886              
     2840 
    28872841    def on_reset_panel(self, event=None): 
    28882842        """ 
     
    28912845        if self.cpanel_on_focus is not None: 
    28922846            self.cpanel_on_focus.on_reset(event) 
    2893              
    2894     def on_change_caption(self, name, old_caption, new_caption):      
     2847 
     2848    def on_change_caption(self, name, old_caption, new_caption): 
    28952849        """ 
    28962850        Change the panel caption 
    2897          
     2851 
    28982852        :param name: window_name of the pane 
    28992853        :param old_caption: current caption [string] 
     
    29012855        """ 
    29022856        # wx.aui.AuiPaneInfo 
    2903         pane_info = self.get_paneinfo(old_caption)  
     2857        pane_info = self.get_paneinfo(old_caption) 
    29042858        # update the data_panel.cb_plotpanel 
    29052859        if 'data_panel' in self.panels.keys(): 
     
    29092863                # Check if any panel has the same caption 
    29102864                has_newstring = data_panel.cb_plotpanel.FindString\ 
    2911                                                             (str(new_caption))  
     2865                                                            (str(new_caption)) 
    29122866                caption = new_caption 
    29132867                if has_newstring != wx.NOT_FOUND: 
     
    29152869                    # Append nummber 
    29162870                    inc = 1 
     2871                    #FIXME: fix this terrible loop 
    29172872                    while (1): 
    2918                         caption = new_caption + '_%s'% str(inc) 
     2873                        caption = new_caption + '_%s' % str(inc) 
    29192874                        if caption not in captions: 
    29202875                            break 
    29212876                        inc += 1 
    29222877                    # notify to users 
    2923                     msg = "Found Same Title: Added '_%s'"% str(inc) 
     2878                    msg = "Found Same Title: Added '_%s'" % str(inc) 
    29242879                    wx.PostEvent(self, StatusEvent(status=msg)) 
    29252880                # update data_panel cb 
    2926                 pos = data_panel.cb_plotpanel.FindString(str(old_caption))  
     2881                pos = data_panel.cb_plotpanel.FindString(str(old_caption)) 
    29272882                if pos != wx.NOT_FOUND: 
    29282883                    data_panel.cb_plotpanel.SetString(pos, caption) 
     
    29312886        pane_info.SetTitle(caption) 
    29322887        return caption 
    2933          
     2888 
    29342889    def get_paneinfo(self, name): 
    29352890        """ 
    29362891        Get pane Caption from window_name 
    2937          
     2892 
    29382893        :param name: window_name in AuiPaneInfo 
    29392894        : return: AuiPaneInfo of the name 
     
    29432898                return panel.frame 
    29442899        return None 
    2945      
     2900 
    29462901    def enable_undo(self): 
    29472902        """ 
     
    29502905        if self.cpanel_on_focus is not None: 
    29512906            self._toolbar.enable_undo(self.cpanel_on_focus) 
    2952              
     2907 
    29532908    def enable_redo(self): 
    29542909        """ 
    2955         enable redo  
     2910        enable redo 
    29562911        """ 
    29572912        if self.cpanel_on_focus is not None: 
    29582913            self._toolbar.enable_redo(self.cpanel_on_focus) 
    2959              
     2914 
    29602915    def enable_copy(self): 
    29612916        """ 
     
    29642919        if self.cpanel_on_focus is not None: 
    29652920            self._toolbar.enable_copy(self.cpanel_on_focus) 
    2966              
     2921 
    29672922    def enable_paste(self): 
    29682923        """ 
    2969         enable paste  
     2924        enable paste 
    29702925        """ 
    29712926        if self.cpanel_on_focus is not None: 
    29722927            self._toolbar.enable_paste(self.cpanel_on_focus) 
    2973                         
     2928 
    29742929    def enable_bookmark(self): 
    29752930        """ 
    2976         Bookmark  
     2931        Bookmark 
    29772932        """ 
    29782933        if self.cpanel_on_focus is not None: 
    29792934            self._toolbar.enable_bookmark(self.cpanel_on_focus) 
    2980              
     2935 
    29812936    def enable_save(self): 
    29822937        """ 
    2983         save  
     2938        save 
    29842939        """ 
    29852940        if self.cpanel_on_focus is not None: 
    29862941            self._toolbar.enable_save(self.cpanel_on_focus) 
    2987              
     2942 
    29882943    def enable_preview(self): 
    29892944        """ 
    2990         preview  
     2945        preview 
    29912946        """ 
    29922947        if self.cpanel_on_focus is not None: 
    29932948            self._toolbar.enable_preview(self.cpanel_on_focus) 
    2994              
     2949 
    29952950    def enable_print(self): 
    29962951        """ 
    2997         print  
     2952        print 
    29982953        """ 
    29992954        if self.cpanel_on_focus is not None: 
    30002955            self._toolbar.enable_print(self.cpanel_on_focus) 
    3001              
     2956 
    30022957    def enable_zoom(self): 
    30032958        """ 
    3004         zoom  
     2959        zoom 
    30052960        """ 
    30062961        if self.cpanel_on_focus is not None: 
    30072962            self._toolbar.enable_zoom(self.panel_on_focus) 
    3008              
     2963 
    30092964    def enable_zoom_in(self): 
    30102965        """ 
    3011         zoom in  
     2966        zoom in 
    30122967        """ 
    30132968        if self.cpanel_on_focus is not None: 
    30142969            self._toolbar.enable_zoom_in(self.panel_on_focus) 
    3015              
     2970 
    30162971    def enable_zoom_out(self): 
    30172972        """ 
    3018         zoom out  
     2973        zoom out 
    30192974        """ 
    30202975        if self.cpanel_on_focus is not None: 
    30212976            self._toolbar.enable_zoom_out(self.panel_on_focus) 
    3022              
     2977 
    30232978    def enable_drag(self, event=None): 
    30242979        """ 
    3025         drag  
     2980        drag 
    30262981        """ 
    30272982        #Not implemeted 
    3028              
     2983 
    30292984    def enable_reset(self): 
    30302985        """ 
     
    30332988        if self.cpanel_on_focus is not None: 
    30342989            self._toolbar.enable_reset(self.panel_on_focus) 
    3035              
     2990 
    30362991    def get_toolbar_height(self): 
    30372992        """ 
     
    30422997                _, size_y = self.GetToolBar().GetSizeTuple() 
    30432998        return size_y 
    3044      
     2999 
    30453000    def set_schedule_full_draw(self, panel=None, func='del'): 
    30463001        """ 
    30473002        Add/subtract the schedule full draw list with the panel given 
    3048          
     3003 
    30493004        :param panel: plot panel 
    30503005        :param func: append or del [string] 
     
    30543009        if func == 'append': 
    30553010            if not panel in self.schedule_full_draw_list: 
    3056                 self.schedule_full_draw_list.append(panel)  
     3011                self.schedule_full_draw_list.append(panel) 
    30573012        # remove this panel from schedule list 
    30583013        elif func == 'del': 
     
    30653020            self.schedule = False 
    30663021        else: 
    3067             self.schedule = True     
    3068          
     3022            self.schedule = True 
     3023 
    30693024    def full_draw(self): 
    30703025        """ 
    30713026        Draw the panels with axes in the schedule to full dwar list 
    30723027        """ 
    3073          
     3028 
    30743029        count = len(self.schedule_full_draw_list) 
    30753030        #if not self.schedule: 
     
    30973052                # while any panel is capture. 
    30983053                frame = panel.frame 
    3099                  
     3054 
    31003055                if not frame.GetCapture(): 
    31013056                    # draw if possible 
     
    31053060                # Check if the panel is not shown 
    31063061                flag = frame.IsShown() 
    3107                 frame.Show(flag)   
     3062                frame.Show(flag) 
    31083063            except: 
    31093064                pass 
    3110       
     3065 
    31113066        # Draw all panels  
    31123067        if count == 1: 
    3113             f_draw(self.schedule_full_draw_list[0])   
     3068            f_draw(self.schedule_full_draw_list[0]) 
    31143069        else: 
    31153070            map(f_draw, self.schedule_full_draw_list) 
     
    31193074        else: 
    31203075            self.set_schedule(True) 
    3121          
    3122     def set_schedule(self, schedule=False):   
     3076 
     3077    def set_schedule(self, schedule=False): 
    31233078        """ 
    31243079        Set schedule 
    31253080        """ 
    31263081        self.schedule = schedule 
    3127                  
    3128     def get_schedule(self):   
     3082 
     3083    def get_schedule(self): 
    31293084        """ 
    31303085        Get schedule 
    31313086        """ 
    31323087        return self.schedule 
    3133      
     3088 
    31343089    def on_set_plot_focus(self, panel): 
    31353090        """ 
     
    31393094            return 
    31403095        #self.set_plot_unfocus() 
    3141         panel.on_set_focus(None)   
     3096        panel.on_set_focus(None) 
    31423097        # set focusing panel 
    3143         self.panel_on_focus = panel   
     3098        self.panel_on_focus = panel 
    31443099        self.set_panel_on_focus(None) 
    31453100 
    3146     def set_plot_unfocus(self):  
     3101    def set_plot_unfocus(self): 
    31473102        """ 
    31483103        Un focus all plot panels 
     
    31503105        for plot in self.plot_panels.values(): 
    31513106            plot.on_kill_focus(None) 
    3152      
     3107 
    31533108    def get_window_size(self): 
    31543109        """ 
    3155         Get window size  
    3156          
     3110        Get window size 
     3111 
    31573112        :return size: tuple 
    31583113        """ 
     
    31633118                height -= 45 
    31643119        return (width, height) 
    3165              
     3120 
    31663121    def _onDrawIdle(self, *args, **kwargs): 
    31673122        """ 
     
    31753130        except: 
    31763131            pass 
    3177              
     3132 
    31783133        # restart idle         
    31793134        self._redraw_idle(*args, **kwargs) 
    31803135 
    3181              
     3136 
    31823137    def _redraw_idle(self, *args, **kwargs): 
    31833138        """ 
     
    31853140        """ 
    31863141        # restart idle    
    3187         self.idletimer.Restart(100*TIME_FACTOR, *args, **kwargs) 
    3188  
    3189          
     3142        self.idletimer.Restart(100 * TIME_FACTOR, *args, **kwargs) 
     3143 
     3144 
    31903145class DefaultPanel(wx.Panel, PanelBase): 
    31913146    """ 
     
    32023157        wx.Panel.__init__(self, parent, *args, **kwds) 
    32033158        PanelBase.__init__(self, parent) 
    3204      
     3159 
    32053160 
    32063161 
     
    32133168        When initialised 
    32143169        """ 
    3215         pos, size, self.is_max = self.window_placement((GUIFRAME_WIDTH,  
    3216                                            GUIFRAME_HEIGHT))      
    3217         self.frame = ViewerFrame(parent=None,  
    3218                              title=APPLICATION_NAME,  
    3219                              pos=pos,  
    3220                              gui_style = DEFAULT_STYLE, 
    3221                              size=size) 
     3170        pos, size, self.is_max = self.window_placement((GUIFRAME_WIDTH, 
     3171                                                        GUIFRAME_HEIGHT)) 
     3172        self.frame = ViewerFrame(parent=None, 
     3173                                 title=APPLICATION_NAME, 
     3174                                 pos=pos, 
     3175                                 gui_style=DEFAULT_STYLE, 
     3176                                 size=size) 
    32223177        self.frame.Hide() 
    32233178        if not IS_WIN: 
     
    32343189        try: 
    32353190            if os.path.isfile(SPLASH_SCREEN_PATH): 
    3236                 self.s_screen = self.display_splash_screen(parent=self.frame,  
    3237                                         path=SPLASH_SCREEN_PATH) 
     3191                self.s_screen = self.display_splash_screen(parent=self.frame, 
     3192                                                           path=SPLASH_SCREEN_PATH) 
    32383193            else: 
    3239                 self.frame.Show()    
     3194                self.frame.Show() 
    32403195        except: 
    32413196            if self.s_screen is not None: 
    32423197                self.s_screen.Close() 
    32433198            msg = "Cannot display splash screen\n" 
    3244             msg += str (sys.exc_value) 
     3199            msg += str(sys.exc_value) 
    32453200            logging.error(msg) 
    32463201            self.frame.Show() 
    32473202 
    32483203        self.SetTopWindow(self.frame) 
    3249    
     3204 
    32503205        return True 
    3251      
     3206 
    32523207    def maximize_win(self): 
    32533208        """ 
     
    32663221        if len(sys.argv) >= 2: 
    32673222            cmd = sys.argv[0].lower() 
    3268             basename  = os.path.basename(cmd) 
     3223            basename = os.path.basename(cmd) 
    32693224            app_base = str(APPLICATION_NAME).lower() 
    32703225            if os.path.isfile(cmd) or basename.lower() == app_base: 
     
    32743229                if basename.lower() in [app_py, app_exe, app_app, app_base]: 
    32753230                    data_base = sys.argv[1] 
    3276                     input_file = os.path.normpath(os.path.join(DATAPATH,  
     3231                    input_file = os.path.normpath(os.path.join(DATAPATH, 
    32773232                                                               data_base)) 
    32783233        if input_file is None: 
     
    32803235        if self.frame is not None: 
    32813236            self.frame.set_input_file(input_file=input_file) 
    3282           
    3283     def clean_plugin_models(self, path):  
     3237 
     3238    def clean_plugin_models(self, path): 
    32843239        """ 
    32853240        Delete plugin models  in app folder 
    3286          
     3241 
    32873242        :param path: path of the plugin_models folder in app 
    32883243        """ 
    32893244        # do it only the first time app loaded 
    3290         # delete unused model folder     
     3245        # delete unused model folder 
    32913246        model_folder = os.path.join(PATH_APP, path) 
    32923247        if os.path.exists(model_folder) and os.path.isdir(model_folder): 
     
    33003255                    logging.error("gui_manager.clean_plugin_models:\n  %s" \ 
    33013256                                  % sys.exc_value) 
    3302                
     3257 
    33033258    def set_manager(self, manager): 
    33043259        """ 
    33053260        Sets a reference to the application manager 
    3306         of the GUI manager (Frame)  
     3261        of the GUI manager (Frame) 
    33073262        """ 
    33083263        self.frame.set_manager(manager) 
    3309          
     3264 
    33103265    def build_gui(self): 
    33113266        """ 
     
    33183273            raise 
    33193274        self.frame.build_gui() 
    3320          
     3275 
    33213276    def set_welcome_panel(self, panel_class): 
    33223277        """ 
    33233278        Set the welcome panel 
    3324          
     3279 
    33253280        :param panel_class: class of the welcome panel to be instantiated 
    3326          
     3281 
    33273282        """ 
    33283283        self.frame.welcome_panel_class = panel_class 
    3329          
     3284 
    33303285    def add_perspective(self, perspective): 
    33313286        """ 
     
    33333288        """ 
    33343289        self.frame.add_perspective(perspective) 
    3335      
     3290 
    33363291    def window_placement(self, size): 
    33373292        """ 
     
    33503305                displayRect = screen.GetClientArea() 
    33513306                break 
    3352          
    3353         posX, posY, displayWidth, displayHeight = displayRect         
     3307 
     3308        posX, posY, displayWidth, displayHeight = displayRect 
    33543309        customWidth, customHeight = size 
    3355          
     3310 
    33563311        # If the custom size is default, set 90% of the screen size 
    33573312        if customWidth <= 0 and customHeight <= 0: 
     
    33673322            if customHeight > displayHeight: 
    33683323                customHeight = displayHeight 
    3369              
     3324 
    33703325        # Note that when running Linux and using an Xming (X11) server on a PC 
    33713326        # with a dual  monitor configuration, the reported display size may be 
     
    33743329        # screen 'too big'.  If so, we assume a smaller width which means the 
    33753330        # application will be placed towards the left hand side of the screen. 
    3376          
     3331 
    33773332        # If dual screen registered as 1 screen. Make width half. 
    33783333        # MAC just follows the default behavior of pos 
    33793334        if IS_WIN: 
    3380             if displayWidth > (displayHeight*2): 
    3381                 if (customWidth == displayWidth): 
    3382                     customWidth = displayWidth/2 
     3335            if displayWidth > (displayHeight * 2): 
     3336                if customWidth == displayWidth: 
     3337                    customWidth = displayWidth / 2 
    33833338                # and set the position to be the corner of the screen. 
    33843339                posX = 0 
    33853340                posY = 0 
    3386                  
     3341 
    33873342            # Make the position the middle of the screen. (Not 0,0) 
    33883343            else: 
    3389                 posX = (displayWidth - customWidth)/2 
    3390                 posY = (displayHeight - customHeight)/2 
    3391         # Return the suggested position and size for the application frame.     
     3344                posX = (displayWidth - customWidth) / 2 
     3345                posY = (displayHeight - customHeight) / 2 
     3346        # Return the suggested position and size for the application frame. 
    33923347        return (posX, posY), (customWidth, customHeight), is_maximized 
    33933348 
    3394      
    3395     def display_splash_screen(self, parent,  
     3349 
     3350    def display_splash_screen(self, parent, 
    33963351                              path=SPLASH_SCREEN_PATH): 
    33973352        """Displays the splash screen.  It will exactly cover the main frame.""" 
    3398         
     3353 
    33993354        # Prepare the picture.  On a 2GHz intel cpu, this takes about a second. 
    34003355        image = wx.Image(path, wx.BITMAP_TYPE_PNG) 
    3401         image.Rescale(SPLASH_SCREEN_WIDTH,  
     3356        image.Rescale(SPLASH_SCREEN_WIDTH, 
    34023357                      SPLASH_SCREEN_HEIGHT, wx.IMAGE_QUALITY_HIGH) 
    34033358        bm = image.ConvertToBitmap() 
     
    34133368        # case the splash screen disappears upon entering the event loop. 
    34143369        s_screen = wx.SplashScreen(bitmap=bm, 
    3415                                    splashStyle=(wx.SPLASH_TIMEOUT| 
     3370                                   splashStyle=(wx.SPLASH_TIMEOUT | 
    34163371                                                wx.SPLASH_CENTRE_ON_SCREEN), 
    3417                                    style=(wx.SIMPLE_BORDER| 
    3418                                           wx.FRAME_NO_TASKBAR| 
     3372                                   style=(wx.SIMPLE_BORDER | 
     3373                                          wx.FRAME_NO_TASKBAR | 
    34193374                                          wx.FRAME_FLOAT_ON_PARENT), 
    34203375                                   milliseconds=SS_MAX_DISPLAY_TIME, 
     
    34273382        s_screen.Show() 
    34283383        return s_screen 
    3429          
    3430          
     3384 
     3385 
    34313386    def on_close_splash_screen(self, event): 
    34323387        """ 
     
    34423397    Frame for panels 
    34433398    """ 
    3444     def __init__(self, parent, panel, title="Untitled", size=(300,200)): 
     3399    def __init__(self, parent, panel, title="Untitled", size=(300, 200)): 
    34453400        """ 
    34463401        comment 
     
    34563411            self.set_panel(panel) 
    34573412        self.Show(False) 
    3458      
     3413 
    34593414    def show_data_panel(self, action): 
    34603415        """ 
    34613416        """ 
    34623417        self.parent.show_data_panel(action) 
    3463          
     3418 
    34643419    def set_panel(self, panel): 
    34653420        """ 
     
    34713426        width, height = self.parent._get_panels_size(panel) 
    34723427        if hasattr(panel, "CENTER_PANE") and panel.CENTER_PANE: 
    3473             width *= 0.6   
     3428            width *= 0.6 
    34743429        self.SetSize((width, height)) 
    34753430        self.parent.put_icon(self) 
     
    34773432        self.Bind(wx.EVT_CLOSE, self.OnClose) 
    34783433        self.Show(False) 
    3479      
     3434 
    34803435    def set_panel_focus(self, event): 
    34813436        """ 
     
    34843439            self.panel.SetFocus() 
    34853440            self.parent.panel_on_focus = self.panel 
    3486          
     3441 
    34873442    def OnClose(self, event): 
    34883443        """ 
     
    34903445        """ 
    34913446        self.panel.on_close(event) 
    3492          
    3493 if __name__ == "__main__":  
     3447 
     3448if __name__ == "__main__": 
    34943449    app = ViewApp(0) 
    34953450    app.MainLoop() 
Note: See TracChangeset for help on using the changeset viewer.