Changeset 0cd8612 in sasview for src/sas/qtgui
- Timestamp:
- Jul 8, 2016 10:13:41 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:
- a95260d
- Parents:
- e540cd2
- Location:
- src/sas/qtgui
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/DataExplorer.py
re540cd2 r0cd8612 13 13 14 14 # SAS 15 from GuiUtils import * 15 import GuiUtils 16 16 from Plotter import Plotter 17 17 from sas.sascalc.dataloader.loader import Loader … … 307 307 """ 308 308 309 plots = plotsFromCheckedItems(self.model)309 plots = GuiUtils.plotsFromCheckedItems(self.model) 310 310 311 311 # Call show on requested plots … … 334 334 paths = [str(f) for f in paths] 335 335 336 if type(paths) is not list:336 if not isinstance(paths, list): 337 337 paths = [paths] 338 338 … … 358 358 basename = os.path.basename(p_file) 359 359 _, extension = os.path.splitext(basename) 360 if extension.lower() in EXTENSIONS:360 if extension.lower() in GuiUtils.EXTENSIONS: 361 361 any_error = True 362 362 log_msg = "Data Loader cannot " … … 430 430 431 431 if any_error or error_message: 432 self.communicator.statusBarUpdateSignal.emit(error_message) 432 logging.error(error_message) 433 status_bar_message = "Errors occurred while loading %s" % format(basename) 434 self.communicator.statusBarUpdateSignal.emit(status_bar_message) 433 435 434 436 else: 435 437 message = "Loading Data Complete! " 436 438 message += log_msg 439 # Notify the progress bar that the updates are over. 437 440 self.communicator.progressBarUpdateSignal.emit(-1) 438 441 … … 485 488 486 489 try: 487 is1D = type(item.child(0).data().toPyObject()) is Data1D490 is1D = isinstance(item.child(0).data().toPyObject(), Data1D) 488 491 except AttributeError: 489 492 msg = "Bad structure of the data model." … … 499 502 500 503 try: 501 is1D = type(item.child(0).data().toPyObject()) is Data1D504 is1D = isinstance(item.child(0).data().toPyObject(), Data1D) 502 505 except AttributeError: 503 506 msg = "Bad structure of the data model." … … 513 516 item.setCheckState(QtCore.Qt.Unchecked) 514 517 try: 515 is2D = type(item.child(0).data().toPyObject()) is Data2D518 is2D = isinstance(item.child(0).data().toPyObject(), Data2D) 516 519 except AttributeError: 517 520 msg = "Bad structure of the data model." … … 527 530 528 531 try: 529 is2D = type(item.child(0).data().toPyObject()) is Data2D532 is2D = isinstance(item.child(0).data().toPyObject(), Data2D) 530 533 except AttributeError: 531 534 msg = "Bad structure of the data model." … … 602 605 603 606 # Add rows for display in the view 604 info_item = infoFromData(data)607 info_item = GuiUtils.infoFromData(data) 605 608 606 609 # Set info_item as the only child … … 616 619 """ 617 620 # Assert the correct type 618 if type(model_item) != QtGui.QStandardItem:621 if not isinstance(model_item, QtGui.QStandardItem): 619 622 msg = "Wrong data type returned from calculations." 620 623 raise AttributeError, msg -
src/sas/qtgui/GuiManager.py
re540cd2 r0cd8612 1 1 import sys 2 import os 2 3 import subprocess 3 4 import logging … … 15 16 from sas.sasgui.guiframe.proxy import Connection 16 17 18 from SasviewLogger import XStream 19 17 20 import LocalConfig 18 from GuiUtils import * 21 import GuiUtils 19 22 from UI.AcknowledgementsUI import Acknowledgements 20 23 from AboutBox import AboutBox … … 34 37 """ 35 38 """ 36 37 39 self._workspace = mainWindow 38 40 self._parent = parent … … 58 60 # Widgets 59 61 # 60 # Add FileDialog widget as docked61 self.filesWidget = DataExplorerWindow(parent, self) 62 63 self.dockedFilesWidget = QtGui.QDockWidget("Data explorer", self._workspace)64 self.dockedFilesWidget.setWidget(self.filesWidget)65 self.dockedFilesWidget.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) 66 self._workspace.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockedFilesWidget)67 68 self.ackWidget = Acknowledgements()69 self.aboutWidget = AboutBox()62 self.addWidgets() 63 64 # Fork off logging messages to the Log Window 65 XStream.stdout().messageWritten.connect( self.listWidget.insertPlainText ) 66 XStream.stderr().messageWritten.connect( self.listWidget.insertPlainText ) 67 68 # Log the start of the session 69 logging.info(" --- SasView session started ---") 70 # Log the python version 71 logging.info("Python: %s" % sys.version) 70 72 71 73 # Set up the status bar … … 94 96 # Default perspective 95 97 self._current_perspective = self.invariantWidget 98 99 def addWidgets(self): 100 """ 101 Populate the main window with widgets 102 103 TODO: overwrite close() on Log and DR widgets so they can be hidden/shown 104 on request 105 """ 106 # Add FileDialog widget as docked 107 self.filesWidget = DataExplorerWindow(self._parent, self) 108 109 self.dockedFilesWidget = QtGui.QDockWidget("Data Explorer", self._workspace) 110 self.dockedFilesWidget.setWidget(self.filesWidget) 111 # Disable maximize/minimize and close buttons 112 self.dockedFilesWidget.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) 113 self._workspace.addDockWidget(QtCore.Qt.LeftDockWidgetArea, 114 self.dockedFilesWidget) 115 116 # Add the console window as another docked widget 117 self.logDockWidget = QtGui.QDockWidget("Log Explorer", self._workspace) 118 self.logDockWidget.setObjectName("LogDockWidget") 119 self.listWidget = QtGui.QTextBrowser() 120 self.logDockWidget.setWidget(self.listWidget) 121 self._workspace.addDockWidget(QtCore.Qt.BottomDockWidgetArea, 122 self.logDockWidget) 123 124 # Add other, minor widgets 125 self.ackWidget = Acknowledgements() 126 self.aboutWidget = AboutBox() 96 127 97 128 def statusBarSetup(self): … … 266 297 Method defining all signal connections for the gui manager 267 298 """ 268 self.communicate = Communicate()299 self.communicate = GuiUtils.Communicate() 269 300 self.communicate.fileDataReceivedSignal.connect(self.fileRead) 270 301 self.communicate.statusBarUpdateSignal.connect(self.updateStatusBar) … … 411 442 """ 412 443 """ 413 print("actionReset TRIGGERED") 444 logging.warning(" *** actionOpen_Analysis logging *******") 445 print("actionReset print TRIGGERED") 446 sys.stderr.write("STDERR - TRIGGERED") 414 447 pass 415 448 -
src/sas/qtgui/MainWindow.py
re540cd2 r0cd8612 8 8 # Local UI 9 9 from UI.MainWindowUI import MainWindow 10 11 # Initialize logging 12 import SasviewLogger 10 13 11 14 class MainSasViewWindow(MainWindow): … … 54 57 # Show the main SV window 55 58 mainwindow = MainSasViewWindow(reactor) 56 mainwindow.show() 59 #mainwindow.show() 60 mainwindow.showMaximized() 57 61 58 62 # no more splash screen -
src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py
re540cd2 r0cd8612 12 12 from sas.sascalc.invariant import invariant 13 13 from sas.sasgui.guiframe.dataFitting import Data1D 14 # from sas.qtgui.GuiUtils import * 15 from GuiUtils import * 14 import GuiUtils 16 15 17 16 # local … … 67 66 self._high_power_value = False 68 67 69 self.communicate = Communicate()68 self.communicate = GuiUtils.Communicate() 70 69 71 70 # Mask file selector … … 278 277 279 278 # This needs to run in the main thread 280 reactor.callFromThread( updateModelItem, self._model_item, variant_item, title)279 reactor.callFromThread(GuiUtils.updateModelItem, self._model_item, variant_item, title) 281 280 282 281 if self._high_extrapolate: -
src/sas/qtgui/UI/MainWindowUI.py
re540cd2 r0cd8612 56 56 MainWindow.setMenuBar(self.menubar) 57 57 self.statusbar = QtGui.QStatusBar(MainWindow) 58 sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) 59 sizePolicy.setHorizontalStretch(0) 60 sizePolicy.setVerticalStretch(0) 61 sizePolicy.setHeightForWidth(self.statusbar.sizePolicy().hasHeightForWidth()) 62 self.statusbar.setSizePolicy(sizePolicy) 58 63 self.statusbar.setObjectName(_fromUtf8("statusbar")) 59 64 MainWindow.setStatusBar(self.statusbar) -
src/sas/qtgui/UI/MainWindowUI.ui
re540cd2 r0cd8612 149 149 <addaction name="menuHelp"/> 150 150 </widget> 151 <widget class="QStatusBar" name="statusbar"/> 151 <widget class="QStatusBar" name="statusbar"> 152 <property name="sizePolicy"> 153 <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> 154 <horstretch>0</horstretch> 155 <verstretch>0</verstretch> 156 </sizepolicy> 157 </property> 158 </widget> 152 159 <widget class="QToolBar" name="toolBar"> 153 160 <property name="windowTitle"> -
src/sas/qtgui/UnitTesting/DataExplorerTest.py
re540cd2 r0cd8612 95 95 """ 96 96 Test if all required widgets got added 97 """ 97 """ 98 98 def testLoadButton(self): 99 99 loadButton = self.form.cmdLoad -
src/sas/qtgui/UnitTesting/GuiManagerTest.py
re540cd2 r0cd8612 48 48 self.assertIsInstance(self.manager.filesWidget, DataExplorerWindow) 49 49 self.assertIsInstance(self.manager.dockedFilesWidget, QDockWidget) 50 self.assertIsInstance(self.manager.dockedFilesWidget.widget(), DataExplorerWindow) 50 51 self.assertEqual(self.manager.dockedFilesWidget.features(), QDockWidget.NoDockWidgetFeatures) 51 52 self.assertEqual(self.manager._workspace.dockWidgetArea(self.manager.dockedFilesWidget), Qt.LeftDockWidgetArea) 53 54 self.assertIsInstance(self.manager.logDockWidget, QDockWidget) 55 self.assertIsInstance(self.manager.logDockWidget.widget(), QTextBrowser) 56 self.assertEqual(self.manager._workspace.dockWidgetArea(self.manager.logDockWidget), Qt.BottomDockWidgetArea) 57 52 58 self.assertIsInstance(self.manager.ackWidget, Acknowledgements) 53 59 self.assertIsInstance(self.manager.aboutWidget, AboutBox) 54 60 self.assertIsInstance(self.manager.welcomePanel, WelcomePanel) 61 62 def testLogging(self): 63 """ 64 Test logging of stdout, stderr and log messages 65 """ 66 # See if the log window is empty 67 self.assertEqual(self.manager.logDockWidget.widget().toPlainText(), "") 68 69 # Now, send some message to stdout. 70 # We are in the MainWindow scope, so simple 'print' will work 71 message = "from stdout" 72 print message 73 self.assertIn(message, self.manager.logDockWidget.widget().toPlainText()) 74 75 # Send some message to stderr 76 message = "from stderr" 77 sys.stderr.write(message) 78 self.assertIn(message, self.manager.logDockWidget.widget().toPlainText()) 79 80 # And finally, send a log message 81 import logging 82 message = "from logging" 83 message_logged = "ERROR: " + message 84 logging.error(message) 85 self.assertIn(message_logged, self.manager.logDockWidget.widget().toPlainText()) 55 86 56 87 def testUpdatePerspective(self): -
src/sas/qtgui/run_tests.sh
rf82ab8c r0cd8612 7 7 python -m UnitTesting.AboutBoxTest 8 8 python -m UnitTesting.DroppableDataLoadWidgetTest 9 python -m UnitTesting.SasviewLoggerTest
Note: See TracChangeset
for help on using the changeset viewer.