Changeset c3f697e in sasview
- Timestamp:
- Mar 25, 2011 12:29:26 PM (14 years ago)
- 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:
- 56681bd
- Parents:
- ec1584e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/gui_manager.py
r976604d rc3f697e 299 299 for item in list: 300 300 toks = os.path.splitext(os.path.basename(item)) 301 name = None301 name = '' 302 302 if not toks[0] == '__init__': 303 303 … … 306 306 307 307 path = [os.path.abspath(dir)] 308 file = None308 file = '' 309 309 try: 310 310 if toks[1] == '': … … 1031 1031 def load_from_cmd(self, path): 1032 1032 """ 1033 load data from cmd or application 1033 1034 """ 1034 print "load_from_cmd", path 1035 if path is None: 1035 if path is None: 1036 1036 return 1037 1037 else: 1038 1038 path = os.path.abspath(path) 1039 1039 if not os.path.isfile(path): 1040 print "return abs path", path1041 1040 return 1042 1043 print "find a path -->", path1044 1045 1041 basename = os.path.basename(path) 1046 1042 root, extension = os.path.splitext(basename) 1047 1043 if extension.lower() not in EXTENSIONS: 1048 1044 self.load_data(path) 1049 print "load data"1050 1045 else: 1051 1046 self.load_state(path) 1052 "load state" 1053 1047 1054 1048 def load_state(self, path): 1055 1049 """ 1050 load data from command line or application 1056 1051 """ 1057 1052 if path and (path is not None) and os.path.isfile(path): … … 1073 1068 def load_data(self, path): 1074 1069 """ 1070 load data from command line 1075 1071 """ 1076 1072 if not os.path.isfile(path): … … 1084 1080 print log_msg 1085 1081 return 1086 1082 message = "" 1083 log_msg = '' 1084 output = {} 1085 error_message = "" 1087 1086 try: 1088 print "Loading Data... " + str(path) + "\n"1087 print "Loading Data...:\n" + str(path) + "\n" 1089 1088 temp = self.loader.load(path) 1090 1089 if temp.__class__.__name__ == "list": 1091 1090 for item in temp: 1092 data = self. parent.create_gui_data(item, path)1091 data = self.create_gui_data(item, path) 1093 1092 output[data.id] = data 1094 1093 else: 1095 data = self. parent.create_gui_data(temp, path)1094 data = self.create_gui_data(temp, path) 1096 1095 output[data.id] = data 1097 1096 1098 1097 self.add_data(data_list=output) 1099 1098 except: 1100 error_message = "Error while loading Data: %s\n" % str(path) 1099 error_message = "Error while loading" 1100 error_message += " Data from cmd:\n %s\n" % str(path) 1101 1101 error_message += str(sys.exc_value) + "\n" 1102 1102 print error_message … … 1827 1827 self.frame.special.SetCurrent() 1828 1828 self.SetTopWindow(self.frame) 1829 self.input_file = None 1830 self.dir = None 1831 print "sys.argv", sys.argv 1829 try: 1830 self.open_file() 1831 except: 1832 msg = "%s Could not load " % str(APPLICATION_NAME) 1833 msg += "input file from command line.\n" 1834 logging.error(msg) 1835 return True 1836 1837 def open_file(self): 1838 """ 1839 open a state file at the start of the application 1840 """ 1841 input_file = None 1832 1842 if len(sys.argv) >= 2: 1833 print "sys.argv 0", sys.argv[0]1834 1843 cmd = sys.argv[0].lower() 1835 1844 if os.path.isfile(cmd): 1836 1845 basename = os.path.basename(cmd) 1837 self.dir = os.path.dirname(cmd)1838 print "basename", basename1839 1846 if basename in ['sansview.py', 'sansview.exe']: 1840 print "sys.argv 1", sys.argv[1] 1841 self.input_file = sys.argv[1] 1842 return True 1843 1844 def open_file(self): 1845 """ 1846 open a state file at the start of the application 1847 """ 1848 1847 input_file = sys.argv[1] 1848 if input_file is None: 1849 return 1849 1850 if self.frame is not None: 1850 self.frame.load_from_cmd(path= self.input_file)1851 self.frame.load_from_cmd(path=input_file) 1851 1852 1852 1853 … … 1961 1962 event.Skip() 1962 1963 1963 1964 1965 1966 1967 1964 if __name__ == "__main__": 1968 1965 app = ViewApp(0)
Note: See TracChangeset
for help on using the changeset viewer.