- Timestamp:
- Mar 22, 2018 4:13:40 PM (7 years ago)
- Branches:
- 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
- Children:
- bb57068
- Parents:
- 8ac3551
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Utilities/TabbedModelEditor.py
r8b480d27 r3790f7f 5 5 import numpy as np 6 6 import logging 7 import traceback 7 8 8 9 from PyQt5 import QtWidgets … … 75 76 # signals from tabs 76 77 self.editor_widget.modelModified.connect(self.editorModelModified) 77 self.plugin_widget. modelModified.connect(self.pluginModelModified)78 self.plugin_widget.txtName.editingFinished.connect(self.pluginTitleSet) 78 79 79 80 def setPluginActive(self, is_active=True): … … 169 170 self.is_modified = True 170 171 171 def pluginModelModified(self): 172 """ 173 User modified the model in the Plugin Editor. 174 Show that the model is changed. 172 def pluginTitleSet(self): 173 """ 174 User modified the model name. 175 Display the model name in the window title 176 and allow for model save. 175 177 """ 176 178 # Ensure plugin name is non-empty … … 179 181 self.setWindowTitle(self.window_title + " - " + model['filename']) 180 182 self.setTabEdited(True) 181 # Enable editor182 self.editor_widget.setEnabled(True)183 183 self.buttonBox.button(QtWidgets.QDialogButtonBox.Apply).setEnabled(True) 184 184 self.is_modified = True 185 185 else: 186 # the model name is empty - disable Apply and clear the editor 186 187 self.buttonBox.button(QtWidgets.QDialogButtonBox.Apply).setEnabled(False) 188 self.editor_widget.blockSignals(True) 189 self.editor_widget.txtEditor.setPlainText('') 190 self.editor_widget.blockSignals(False) 191 self.editor_widget.setEnabled(False) 187 192 188 193 def setTabEdited(self, is_edited): … … 228 233 model_str = self.generateModel(model, full_path) 229 234 self.writeFile(full_path, model_str) 230 # TODO: 231 # Temporarily disable model check - 232 # unittest.suite() gives weird results in qt5. 233 # needs investigating 234 #try: 235 # _, msg = self.checkModel(full_path), None 236 #except Exception as ex: 237 # result, msg = None, "Error building model: "+ str(ex) 235 236 # test the model 237 238 # Run the model test in sasmodels 239 try: 240 _ = self.checkModel(full_path) 241 except Exception as ex: 242 msg = "Error building model: "+ str(ex) 243 logging.error(msg) 244 #print three last lines of the stack trace 245 # this will point out the exact line failing 246 last_lines = traceback.format_exc().split('\n')[-4:] 247 traceback_to_show = '\n'.join(last_lines) 248 logging.error(traceback_to_show) 249 250 self.parent.communicate.statusBarUpdateSignal.emit("Model check failed") 251 return 252 253 self.editor_widget.setEnabled(True) 238 254 239 255 # Update the editor here. … … 248 264 # Notify listeners 249 265 self.parent.communicate.customModelDirectoryChanged.emit() 266 267 # Notify the user 268 msg = "Custom model "+filename + " successfully created." 269 self.parent.communicate.statusBarUpdateSignal.emit(msg) 270 logging.info(msg) 250 271 251 272 def updateFromEditor(self): … … 261 282 # Update the tab title 262 283 self.setTabEdited(False) 263 284 # notify the user 285 msg = self.filename + " successfully saved." 286 self.parent.communicate.statusBarUpdateSignal.emit(msg) 287 logging.info(msg) 288 264 289 def canWriteModel(self, model=None, full_path=""): 265 290 """ … … 395 420 # check the model's unit tests run 396 421 from sasmodels.model_test import run_one 422 # TestSuite module in Qt5 now deletes tests in the suite after running, 423 # so suite[0] in run_one() in sasmodels/model_test.py will contain [None] and 424 # test.info.tests will raise. 425 # Not sure how to change the behaviour here, most likely sasmodels will have to 426 # be modified 397 427 result = run_one(path) 398 428
Note: See TracChangeset
for help on using the changeset viewer.