Changeset e540cd2 in sasview for src/sas/qtgui/DataExplorer.py
- Timestamp:
- Jul 7, 2016 4:54:18 AM (8 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:
- 0cd8612
- Parents:
- f0f309d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/DataExplorer.py
r481ff26 re540cd2 2 2 import sys 3 3 import os 4 import time 4 5 import logging 5 6 … … 16 17 from sas.sascalc.dataloader.loader import Loader 17 18 from sas.sasgui.guiframe.data_manager import DataManager 19 from sas.sasgui.guiframe.dataFitting import Data1D 20 from sas.sasgui.guiframe.dataFitting import Data2D 18 21 19 22 from DroppableDataLoadWidget import DroppableDataLoadWidget … … 57 60 self._helpView = QtWebKit.QWebView() 58 61 62 # Context menu in the treeview 63 #self.treeView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) 64 #self.actionDataInfo.triggered.connect(self.contextDataInfo) 65 #self.treeView.addAction(self.actionDataInfo) 66 67 # Custom context menu 68 self.treeView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) 69 self.treeView.customContextMenuRequested.connect(self.onCustomContextMenu) 70 59 71 # Connect the comboboxes 60 72 self.cbSelect.currentIndexChanged.connect(self.selectData) … … 62 74 #self.closeEvent.connect(self.closeEvent) 63 75 # self.aboutToQuit.connect(self.closeEvent) 64 76 self.communicator = self.parent.communicator() 65 77 self.communicator.fileReadSignal.connect(self.loadFromURL) 66 78 … … 133 145 # get content of dir into a list 134 146 path_str = [os.path.join(os.path.abspath(folder), filename) 135 147 for filename in os.listdir(folder)] 136 148 137 149 self.loadFromURL(path_str) … … 144 156 delete_msg = "This operation will delete the checked data sets and all the dependents." +\ 145 157 "\nDo you want to continue?" 146 reply = QtGui.QMessageBox.question(self, 'Warning', delete_msg, 147 QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) 158 reply = QtGui.QMessageBox.question(self, 159 'Warning', 160 delete_msg, 161 QtGui.QMessageBox.Yes, 162 QtGui.QMessageBox.No) 148 163 149 164 if reply == QtGui.QMessageBox.No: … … 201 216 202 217 # Set the signal handlers 203 self.communicator = self._perspective.communicator()204 218 self.communicator.updateModelFromPerspectiveSignal.connect(self.updateModelFromPerspective) 205 219 … … 254 268 theories_copied += 1 255 269 new_item = self.recursivelyCloneItem(subitem) 270 # Append a "unique" descriptor to the name 271 time_bit = str(time.time())[7:-1].replace('.','') 272 new_name = new_item.text() + '_@' + time_bit 273 new_item.setText(new_name) 256 274 self.theory_model.appendRow(new_item) 257 275 self.theory_model.reset() … … 261 279 return 262 280 elif theories_copied == 1: 263 freeze_msg = "1 theory sent to Theory tab"281 freeze_msg = "1 theory copied to the Theory tab as a data set" 264 282 elif theories_copied > 1: 265 freeze_msg = "%i theories sent to Theory tab" % theories_copied283 freeze_msg = "%i theories copied to the Theory tab as data sets" % theories_copied 266 284 else: 267 285 freeze_msg = "Unexpected number of theories copied: %i" % theories_copied … … 313 331 return 314 332 315 #if type(paths) == QtCore.QStringList:316 333 if isinstance(paths, QtCore.QStringList): 317 334 paths = [str(f) for f in paths] 318 335 319 if paths.__class__.__name__ != "list":336 if type(paths) is not list: 320 337 paths = [paths] 321 338 … … 335 352 error_message = "" 336 353 337 for p_file in path: 354 number_of_files = len(path) 355 self.communicator.progressBarUpdateSignal.emit(0.0) 356 357 for index, p_file in enumerate(path): 338 358 basename = os.path.basename(p_file) 339 359 _, extension = os.path.splitext(basename) … … 406 426 info = "error" 407 427 428 current_percentage = int(100.0* index/number_of_files) 429 self.communicator.progressBarUpdateSignal.emit(current_percentage) 430 408 431 if any_error or error_message: 409 432 self.communicator.statusBarUpdateSignal.emit(error_message) … … 412 435 message = "Loading Data Complete! " 413 436 message += log_msg 437 self.communicator.progressBarUpdateSignal.emit(-1) 414 438 415 439 return output, message … … 461 485 462 486 try: 463 is1D = item.child(0).data().toPyObject().__class__.__name__ == 'Data1D'487 is1D = type(item.child(0).data().toPyObject()) is Data1D 464 488 except AttributeError: 465 489 msg = "Bad structure of the data model." … … 475 499 476 500 try: 477 is1D = item.child(0).data().toPyObject().__class__.__name__ == 'Data1D'501 is1D = type(item.child(0).data().toPyObject()) is Data1D 478 502 except AttributeError: 479 503 msg = "Bad structure of the data model." … … 489 513 item.setCheckState(QtCore.Qt.Unchecked) 490 514 try: 491 is2D = item.child(0).data().toPyObject().__class__.__name__ == 'Data2D'515 is2D = type(item.child(0).data().toPyObject()) is Data2D 492 516 except AttributeError: 493 517 msg = "Bad structure of the data model." … … 503 527 504 528 try: 505 is2D = item.child(0).data().toPyObject().__class__.__name__ == 'Data2D'529 is2D = type(item.child(0).data().toPyObject()) is Data2D 506 530 except AttributeError: 507 531 msg = "Bad structure of the data model." … … 516 540 raise Exception, msg 517 541 542 def contextDataInfo(self): 543 """ 544 """ 545 print("contextDataInfo TRIGGERED") 546 pass 547 548 def onCustomContextMenu(self, position): 549 """ 550 """ 551 print "onCustomContextMenu triggered at point ", position.x(), position.y() 552 index = self.treeView.indexAt(position) 553 if index.isValid(): 554 print "VALID CONTEXT MENU" 555 # self.context_menu.exec(self.treeView.mapToGlobal(position)) 556 pass 518 557 519 558 def loadComplete(self, output): … … 521 560 Post message to status bar and update the data manager 522 561 """ 562 assert type(output) == tuple 563 523 564 # Reset the model so the view gets updated. 524 565 self.model.reset() 525 assert type(output) == tuple566 self.communicator.progressBarUpdateSignal.emit(-1) 526 567 527 568 output_data = output[0]
Note: See TracChangeset
for help on using the changeset viewer.