Changeset 225aca8 in sasview for src/sas/guiframe/gui_manager.py


Ignore:
Timestamp:
Jul 28, 2015 10:14:38 AM (9 years ago)
Author:
mathieu
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:
a910c788
Parents:
ae2a197 (diff), d06c34c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge pull request #3 from SasView?/standalone_cleanup

Standalone cleanup

File:
1 edited

Legend:

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

    r957af0d r225aca8  
    235235        Initialize the Frame object 
    236236        """ 
    237  
    238237        PARENT_FRAME.__init__(self, parent=parent, title=title, pos=pos, size=size) 
    239238        # title 
     
    364363                    frame.SetIcon(icon) 
    365364                except: 
    366                     pass 
     365                    logging.error("ViewerFrame.put_icon: could not set icon") 
    367366 
    368367    def get_client_size(self): 
     
    752751            self._toolbar.Realize() 
    753752 
    754  
    755753    def build_gui(self): 
    756754        """ 
     
    778776        # Append item from plugin under menu file if necessary 
    779777        self._populate_file_menu() 
    780  
    781778 
    782779        if not wx.VERSION_STRING >= '3.0.0.0': 
     
    822819        # Load panels 
    823820        self._load_panels() 
    824         self.set_default_perspective() 
    825821 
    826822    def SetStatusText(self, *args, **kwds): 
     
    931927                        if hasattr(module, "PLUGIN_ID"): 
    932928                            try: 
    933                                 plug = module.Plugin() 
    934                                 if plug.set_default_perspective(): 
    935                                     self._current_perspective = plug 
    936                                 plugins.append(plug) 
    937  
     929                                plugins.append(module.Plugin()) 
    938930                                msg = "Found plug-in: %s" % module.PLUGIN_ID 
    939931                                logging.info(msg) 
     
    15111503                for item in plugin.populate_file_menu(): 
    15121504                    m_name, m_hint, m_handler = item 
    1513                     id = wx.NewId() 
    1514                     self._file_menu.Append(id, m_name, m_hint) 
    1515                     wx.EVT_MENU(self, id, m_handler) 
     1505                    wx_id = wx.NewId() 
     1506                    self._file_menu.Append(wx_id, m_name, m_hint) 
     1507                    wx.EVT_MENU(self, wx_id, m_handler) 
    15161508                self._file_menu.AppendSeparator() 
    15171509 
    15181510        style1 = self.__gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 
    15191511        if OPEN_SAVE_MENU: 
    1520             id = wx.NewId() 
     1512            wx_id = wx.NewId() 
    15211513            hint_load_file = "read all analysis states saved previously" 
    1522             self._save_appl_menu = self._file_menu.Append(id, '&Open Project', hint_load_file) 
    1523             wx.EVT_MENU(self, id, self._on_open_state_project) 
     1514            self._save_appl_menu = self._file_menu.Append(wx_id, '&Open Project', hint_load_file) 
     1515            wx.EVT_MENU(self, wx_id, self._on_open_state_project) 
    15241516 
    15251517        if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 
     
    15271519            hint_load_file = "Read a status files and load" 
    15281520            hint_load_file += " them into the analysis" 
    1529             id = wx.NewId() 
    1530             self._save_appl_menu = self._file_menu.Append(id, 
     1521            wx_id = wx.NewId() 
     1522            self._save_appl_menu = self._file_menu.Append(wx_id, 
    15311523                                                          '&Open Analysis', hint_load_file) 
    1532             wx.EVT_MENU(self, id, self._on_open_state_application) 
     1524            wx.EVT_MENU(self, wx_id, self._on_open_state_application) 
    15331525        if OPEN_SAVE_MENU: 
    15341526            self._file_menu.AppendSeparator() 
    1535             id = wx.NewId() 
    1536             self._file_menu.Append(id, '&Save Project', 
     1527            wx_id = wx.NewId() 
     1528            self._file_menu.Append(wx_id, '&Save Project', 
    15371529                                   'Save the state of the whole analysis') 
    1538             wx.EVT_MENU(self, id, self._on_save_project) 
     1530            wx.EVT_MENU(self, wx_id, self._on_save_project) 
    15391531        if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 
    1540             id = wx.NewId() 
    1541             self._save_appl_menu = self._file_menu.Append(id, \ 
     1532            wx_id = wx.NewId() 
     1533            self._save_appl_menu = self._file_menu.Append(wx_id, \ 
    15421534                '&Save Analysis', 'Save state of the current active analysis panel') 
    1543             wx.EVT_MENU(self, id, self._on_save_application) 
     1535            wx.EVT_MENU(self, wx_id, self._on_save_application) 
    15441536        if not sys.platform == 'darwin': 
    15451537            self._file_menu.AppendSeparator() 
    1546             id = wx.NewId() 
    1547             self._file_menu.Append(id, '&Quit', 'Exit') 
    1548             wx.EVT_MENU(self, id, self.Close) 
     1538            wx_id = wx.NewId() 
     1539            self._file_menu.Append(wx_id, '&Quit', 'Exit') 
     1540            wx.EVT_MENU(self, wx_id, self.Close) 
    15491541 
    15501542    def _add_menu_file(self): 
     
    17171709        """ 
    17181710        """ 
    1719         message = "" 
    17201711        log_msg = '' 
    1721         output = [] 
    1722         error_message = "" 
    17231712        basename = os.path.basename(path) 
    1724         root, extension = os.path.splitext(basename) 
     1713        _, extension = os.path.splitext(basename) 
    17251714        if extension.lower() not in EXTENSIONS: 
    17261715            log_msg = "File Loader cannot " 
     
    22242213            if hasattr(item, "post_init"): 
    22252214                item.post_init() 
    2226  
    2227     def set_default_perspective(self): 
    2228         """ 
    2229         Choose among the plugin the first plug-in that has 
    2230         "set_default_perspective" method and its return value is True will be 
    2231         as a default perspective when the welcome page is closed 
    2232         """ 
    2233         for item in self.plugins: 
    2234             if hasattr(item, "set_default_perspective"): 
    2235                 if item.set_default_perspective(): 
    2236                     item.on_perspective(event=None) 
    2237                     return 
    22382215 
    22392216    def set_perspective(self, panels): 
     
    24142391            total_plot_list.append(theory_data) 
    24152392        for new_plot in total_plot_list: 
    2416             id = new_plot.id 
    24172393            for group_id in new_plot.list_group_id: 
    2418                 wx.PostEvent(self, NewPlotEvent(id=id, 
     2394                wx.PostEvent(self, NewPlotEvent(id=new_plot.id, 
    24192395                                                group_id=group_id, 
    24202396                                                action='remove')) 
    24212397                #remove res plot: Todo: improve 
    2422                 wx.CallAfter(self._remove_res_plot, id) 
     2398                wx.CallAfter(self._remove_res_plot, new_plot.id) 
    24232399        self._data_manager.delete_data(data_id=data_id, 
    24242400                                       theory_id=theory_id) 
     
    24552431            ext_num = dlg.GetFilterIndex() 
    24562432            if ext_num == 0: 
    2457                 format = '.txt' 
     2433                ext_format = '.txt' 
    24582434            else: 
    2459                 format = '.xml' 
    2460             path = os.path.splitext(path)[0] + format 
     2435                ext_format = '.xml' 
     2436            path = os.path.splitext(path)[0] + ext_format 
    24612437            mypath = os.path.basename(path) 
    24622438 
    24632439            #Instantiate a loader 
    24642440            loader = Loader() 
    2465             format = ".txt" 
    2466             if os.path.splitext(mypath)[1].lower() == format: 
     2441            ext_format = ".txt" 
     2442            if os.path.splitext(mypath)[1].lower() == ext_format: 
    24672443                # Make sure the ext included in the file name 
    24682444                # especially on MAC 
    2469                 fName = os.path.splitext(path)[0] + format 
     2445                fName = os.path.splitext(path)[0] + ext_format 
    24702446                self._onsaveTXT(data, fName) 
    2471             format = ".xml" 
    2472             if os.path.splitext(mypath)[1].lower() == format: 
     2447            ext_format = ".xml" 
     2448            if os.path.splitext(mypath)[1].lower() == ext_format: 
    24732449                # Make sure the ext included in the file name 
    24742450                # especially on MAC 
    2475                 fName = os.path.splitext(path)[0] + format 
    2476                 loader.save(fName, data, format) 
     2451                fName = os.path.splitext(path)[0] + ext_format 
     2452                loader.save(fName, data, ext_format) 
    24772453            try: 
    24782454                self._default_save_location = os.path.dirname(path) 
     
    25982574            ext_num = dlg.GetFilterIndex() 
    25992575            if ext_num == 0: 
    2600                 format = '.dat' 
     2576                ext_format = '.dat' 
    26012577            else: 
    2602                 format = '' 
    2603             path = os.path.splitext(path)[0] + format 
     2578                ext_format = '' 
     2579            path = os.path.splitext(path)[0] + ext_format 
    26042580            mypath = os.path.basename(path) 
    26052581 
     
    26072583            loader = Loader() 
    26082584 
    2609             format = ".dat" 
    2610             if os.path.splitext(mypath)[1].lower() == format: 
     2585            ext_format = ".dat" 
     2586            if os.path.splitext(mypath)[1].lower() == ext_format: 
    26112587                # Make sure the ext included in the file name 
    26122588                # especially on MAC 
    2613                 fileName = os.path.splitext(path)[0] + format 
    2614                 loader.save(fileName, data, format) 
     2589                fileName = os.path.splitext(path)[0] + ext_format 
     2590                loader.save(fileName, data, ext_format) 
    26152591            try: 
    26162592                self._default_save_location = os.path.dirname(path) 
     
    32063182 
    32073183 
    3208 class ViewApp(wx.App): 
     3184class SasViewApp(wx.App): 
    32093185    """ 
    3210     Toy application to test this Frame 
     3186    SasView application 
    32113187    """ 
    32123188    def OnInit(self): 
     
    32943270            if len(os.listdir(model_folder)) > 0: 
    32953271                try: 
    3296                     for file in os.listdir(model_folder): 
    3297                         file_path = os.path.join(model_folder, file) 
     3272                    for filename in os.listdir(model_folder): 
     3273                        file_path = os.path.join(model_folder, filename) 
    32983274                        if os.path.isfile(file_path): 
    32993275                            os.remove(file_path) 
     
    33143290        """ 
    33153291        #try to load file at the start 
    3316         try: 
    3317             self.open_file() 
    3318         except: 
    3319             raise 
     3292        self.open_file() 
    33203293        self.frame.build_gui() 
    33213294 
Note: See TracChangeset for help on using the changeset viewer.