Changeset 976604d in sasview


Ignore:
Timestamp:
Mar 25, 2011 10:05:47 AM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
84e5533
Parents:
dd1718e
Message:

working on load data from command line

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/gui_manager.py

    r4c01978 r976604d  
    10281028                self._data_panel.load_data_list(data_state) 
    10291029                self._mgr.GetPane(self._data_panel.window_name).Show(True) 
    1030                       
     1030       
     1031    def load_from_cmd(self,  path):    
     1032        """ 
     1033        """  
     1034        print "load_from_cmd", path 
     1035        if path is  None: 
     1036            return 
     1037        else: 
     1038            path = os.path.abspath(path) 
     1039            if not os.path.isfile(path): 
     1040               print "return abs path", path 
     1041               return 
     1042              
     1043            print "find a path -->", path 
     1044 
     1045        basename  = os.path.basename(path) 
     1046        root, extension = os.path.splitext(basename) 
     1047        if extension.lower() not in EXTENSIONS: 
     1048            self.load_data(path) 
     1049            print "load data" 
     1050        else: 
     1051            self.load_state(path) 
     1052            "load state" 
     1053         
    10311054    def load_state(self, path):    
    10321055        """ 
    10331056        """ 
    1034         if path and os.path.isfile(path): 
     1057        if path and (path is not None) and os.path.isfile(path): 
    10351058            basename  = os.path.basename(path) 
    10361059            if APPLICATION_STATE_EXTENSION is not None \ 
     
    17841807                                 gui_style = DEFAULT_STYLE, 
    17851808                                 size=size)  
    1786         #try to load file at the start 
    1787         #try: 
    1788         #    self.open_file() 
    1789         #except: 
    1790         #    raise 
    17911809        self.s_screen = None 
    17921810        # Display a splash screen on top of the frame. 
     
    18091827            self.frame.special.SetCurrent() 
    18101828        self.SetTopWindow(self.frame) 
    1811         import time 
    1812          
     1829        self.input_file = None 
     1830        self.dir = None 
     1831        print "sys.argv", sys.argv 
     1832        if len(sys.argv) >= 2: 
     1833            print "sys.argv 0", sys.argv[0] 
     1834            cmd = sys.argv[0].lower() 
     1835            if os.path.isfile(cmd): 
     1836                basename  = os.path.basename(cmd) 
     1837                self.dir = os.path.dirname(cmd) 
     1838                print "basename", basename 
     1839                if basename in ['sansview.py', 'sansview.exe']: 
     1840                    print "sys.argv 1", sys.argv[1] 
     1841                    self.input_file = sys.argv[1] 
    18131842        return True 
    1814      
    1815     def load(self, path): 
    1816         """ 
    1817         """ 
     1843 
     1844    def open_file(self): 
     1845        """ 
     1846        open a state file at the start of the application 
     1847        """ 
     1848         
    18181849        if self.frame is not None: 
    1819             self.frame.load(path) 
    1820              
    1821     def open_file(self): 
    1822         """ 
    1823         open a state file at the start of the application 
    1824         """ 
    1825         if len(sys.argv) >= 2: 
    1826             if sys.argv[0].lower() in ['sansview.py', 'sansview.exe']: 
    1827                 path = sys.argv[1] 
    1828                 if os.path.isfile(path): 
    1829                     self.load(path) 
    1830                 else: 
    1831                     print "SansView cannot read this file: %s" % str(path) 
     1850            self.frame.load_from_cmd(path=self.input_file) 
     1851          
    18321852             
    18331853    def set_manager(self, manager): 
     
    18441864        self.frame.build_gui() 
    18451865        self.frame.post_init() 
     1866        #try to load file at the start 
     1867        try: 
     1868            self.open_file() 
     1869        except: 
     1870            raise 
    18461871        if self.s_screen is not None and self.s_screen.IsShown(): 
    18471872            self.s_screen.Close() 
Note: See TracChangeset for help on using the changeset viewer.