Changeset 488c49d in sasview for src/sas/qtgui
- Timestamp:
- Jun 8, 2016 9:56:28 AM (9 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:
- 5032ea68
- Parents:
- f721030
- git-author:
- Piotr Rozyczko <piotr.rozyczko@…> (06/08/16 09:53:59)
- git-committer:
- Piotr Rozyczko <piotr.rozyczko@…> (06/08/16 09:56:28)
- Location:
- src/sas/qtgui
- Files:
-
- 2 added
- 12 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/DataExplorer.py
rf721030 r488c49d 15 15 16 16 # UI 17 #from UI.DataExplorerUI import DataExplorerUI18 17 from UI.TabbedFileLoadUI import DataLoadWidget 19 18 … … 39 38 self.cmdDelete.clicked.connect(self.deleteFile) 40 39 self.cmdSendTo.clicked.connect(self.sendData) 40 41 # Connect the comboboxes 42 self.cbSelect.currentIndexChanged.connect(self.selectData) 41 43 42 44 # Communicator for signal definitions … … 222 224 223 225 return wlist 224 226 227 def selectData(self, index): 228 """ 229 Callback method for modifying the TreeView on Selection Options change 230 """ 231 if not isinstance(index, int): 232 msg = "Incorrect type passed to DataExplorer.selectData()" 233 raise AttributeError, msg 234 235 # Respond appropriately 236 if index == 0: 237 # Select All 238 for index in range(self.model.rowCount()): 239 item = self.model.item(index) 240 if item.isCheckable() and item.checkState() == QtCore.Qt.Unchecked: 241 item.setCheckState(QtCore.Qt.Checked) 242 elif index == 1: 243 # De-select All 244 for index in range(self.model.rowCount()): 245 item = self.model.item(index) 246 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 247 item.setCheckState(QtCore.Qt.Unchecked) 248 249 elif index == 2: 250 # Select All 1-D 251 for index in range(self.model.rowCount()): 252 item = self.model.item(index) 253 item.setCheckState(QtCore.Qt.Unchecked) 254 255 try: 256 is1D = item.child(0).data().toPyObject().__class__.__name__ == 'Data1D' 257 except AttributeError: 258 msg = "Bad structure of the data model." 259 raise RuntimeError, msg 260 261 if is1D: 262 item.setCheckState(QtCore.Qt.Checked) 263 264 elif index == 3: 265 # Unselect All 1-D 266 for index in range(self.model.rowCount()): 267 item = self.model.item(index) 268 269 try: 270 is1D = item.child(0).data().toPyObject().__class__.__name__ == 'Data1D' 271 except AttributeError: 272 msg = "Bad structure of the data model." 273 raise RuntimeError, msg 274 275 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked and is1D: 276 item.setCheckState(QtCore.Qt.Unchecked) 277 278 elif index == 4: 279 # Select All 2-D 280 for index in range(self.model.rowCount()): 281 item = self.model.item(index) 282 item.setCheckState(QtCore.Qt.Unchecked) 283 try: 284 is2D = item.child(0).data().toPyObject().__class__.__name__ == 'Data2D' 285 except AttributeError: 286 msg = "Bad structure of the data model." 287 raise RuntimeError, msg 288 289 if is2D: 290 item.setCheckState(QtCore.Qt.Checked) 291 292 elif index == 5: 293 # Unselect All 2-D 294 for index in range(self.model.rowCount()): 295 item = self.model.item(index) 296 297 try: 298 is2D = item.child(0).data().toPyObject().__class__.__name__ == 'Data2D' 299 except AttributeError: 300 msg = "Bad structure of the data model." 301 raise RuntimeError, msg 302 303 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked and is2D: 304 item.setCheckState(QtCore.Qt.Unchecked) 305 306 else: 307 msg = "Incorrect value in the Selection Option" 308 # Change this to a proper logging action 309 raise Exception, msg 310 225 311 226 312 def loadComplete(self, output, message=""): … … 262 348 object_item.setData(QtCore.QVariant(data)) 263 349 350 checkbox_item.setChild(0, object_item) 351 264 352 # Add rows for display in the view 265 353 self.addExtraRows(info_item, data) 266 354 267 355 # Set info_item as the only child 268 checkbox_item.setChild( 0, info_item)356 checkbox_item.setChild(1, info_item) 269 357 270 358 # New row in the model -
src/sas/qtgui/Perspectives/Invariant/UI/InvariantDetailsUI.py
rf721030 r488c49d 1 1 # -*- coding: utf-8 -*- 2 2 3 # Form implementation generated from reading ui file 'InvariantDetails .ui'3 # Form implementation generated from reading ui file 'InvariantDetailsUI.ui' 4 4 # 5 5 # Created by: PyQt4 UI code generator 4.11.4 -
src/sas/qtgui/Perspectives/Invariant/UI/TabbedInvariantUI.py
rf721030 r488c49d 27 27 tabbedInvariantUI.setObjectName(_fromUtf8("tabbedInvariantUI")) 28 28 tabbedInvariantUI.resize(465, 408) 29 icon = QtGui.QIcon()30 icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/res/ball.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off)31 tabbedInvariantUI.setWindowIcon(icon)32 29 self.gridLayout_11 = QtGui.QGridLayout(tabbedInvariantUI) 33 30 self.gridLayout_11.setObjectName(_fromUtf8("gridLayout_11")) … … 315 312 316 313 self.retranslateUi(tabbedInvariantUI) 317 self.tabWidget.setCurrentIndex( 1)314 self.tabWidget.setCurrentIndex(0) 318 315 QtCore.QMetaObject.connectSlotsByName(tabbedInvariantUI) 319 316 … … 374 371 self.pushButton_3.setText(_translate("tabbedInvariantUI", "Help", None)) 375 372 376 import main_resources_rc377 373 378 374 class tabbedInvariantUI(QtGui.QDialog, Ui_tabbedInvariantUI): -
src/sas/qtgui/Perspectives/Invariant/UI/TabbedInvariantUI.ui
rf721030 r488c49d 13 13 <property name="windowTitle"> 14 14 <string>Dialog</string> 15 </property>16 <property name="windowIcon">17 <iconset resource="main_resources.qrc">18 <normaloff>:/res/ball.ico</normaloff>:/res/ball.ico</iconset>19 15 </property> 20 16 <layout class="QGridLayout" name="gridLayout_11"> … … 582 578 </layout> 583 579 </widget> 584 <resources>585 <include location="main_resources.qrc"/>586 </resources>587 580 <connections/> 588 581 </ui> -
src/sas/qtgui/UnitTesting/DataExplorerTest.py
rf721030 r488c49d 45 45 46 46 self.assertEqual(self.form.cbSelect.count(), 6) 47 self.assertEqual(self.form.cbSelect.currentIndex(), 0) 47 48 48 49 # Class is in the default state even without pressing OK … … 100 101 # Assure the model contains no items 101 102 103 def testDataSelection(self): 104 """ 105 Tests the functionality of the Selection Option combobox 106 """ 107 # Populate the model with 1d and 2d data 108 filename = ["cyl_400_20.txt", "Dec07031.ASC"] 109 self.form.readData(filename) 110 111 # Unselect all data 112 self.form.cbSelect.setCurrentIndex(1) 113 114 # Test the current selection 115 item1D = self.form.model.item(0) 116 item2D = self.form.model.item(1) 117 self.assertTrue(item1D.checkState() == QtCore.Qt.Unchecked) 118 self.assertTrue(item2D.checkState() == QtCore.Qt.Unchecked) 119 120 # Select all data 121 self.form.cbSelect.setCurrentIndex(0) 122 123 # Test the current selection 124 self.assertTrue(item1D.checkState() == QtCore.Qt.Checked) 125 self.assertTrue(item2D.checkState() == QtCore.Qt.Checked) 126 127 # select 1d data 128 self.form.cbSelect.setCurrentIndex(2) 129 130 # Test the current selection 131 self.assertTrue(item1D.checkState() == QtCore.Qt.Checked) 132 self.assertTrue(item2D.checkState() == QtCore.Qt.Unchecked) 133 134 # unselect 1d data 135 self.form.cbSelect.setCurrentIndex(3) 136 137 # Test the current selection 138 self.assertTrue(item1D.checkState() == QtCore.Qt.Unchecked) 139 self.assertTrue(item2D.checkState() == QtCore.Qt.Unchecked) 140 141 # select 2d data 142 self.form.cbSelect.setCurrentIndex(4) 143 144 # Test the current selection 145 self.assertTrue(item1D.checkState() == QtCore.Qt.Unchecked) 146 self.assertTrue(item2D.checkState() == QtCore.Qt.Checked) 147 148 # unselect 2d data 149 self.form.cbSelect.setCurrentIndex(5) 150 151 # Test the current selection 152 self.assertTrue(item1D.checkState() == QtCore.Qt.Unchecked) 153 self.assertTrue(item2D.checkState() == QtCore.Qt.Unchecked) 154 155 # choose impossible index and assure the code raises 156 #with self.assertRaises(Exception): 157 # self.form.cbSelect.setCurrentIndex(6) 158 102 159 def testReadData(self): 103 160 """ -
src/sas/qtgui/UnitTesting/GuiManagerTest.py
rf721030 r488c49d 1 import sys 2 import unittest 3 4 from PyQt4.QtGui import * 5 from PyQt4.QtTest import QTest 6 from PyQt4.QtCore import * 7 from mock import MagicMock 8 9 # Local 10 from GuiManager import GuiManager 11 12 #app = QApplication(sys.argv) 13 14 class GuiManagerTest(unittest.TestCase): 15 '''Test the WelcomePanel''' 16 def setUp(self): 17 '''Create the tested object''' 18 19 self.manager = GuiManager(None) 20 21 def tearDown(self): 22 '''Destroy the GUI''' 23 self.manager = None 24 25 def testDefaults(self): 26 '''Test the object in its default state''' 27 pass 28 29 def testUpdatePerspective(self): 30 """ 31 """ 32 pass 33 34 def testUpdateStatusBar(self): 35 """ 36 """ 37 pass 38 39 def testSetData(self): 40 """ 41 """ 42 pass 43 44 def testSetData(self): 45 """ 46 """ 47 pass 48 49 def testActions(self): 50 """ 51 """ 52 pass 53 54 # test each action separately 55 56 if __name__ == "__main__": 57 unittest.main() 58 -
src/sas/qtgui/UnitTesting/TestUtils.py
rf721030 r488c49d 12 12 super(QtSignalSpy, self).__init__(parent) 13 13 14 self._ connector = {}14 self._recorder = {} 15 15 self._count = 0 16 self._signal = [ None, None]16 self._signal = [] 17 17 18 18 # Assign our own slot to the emitted signal 19 if isinstance(signal, pyqtBoundSignal): 20 signal.connect(self.slot) 21 elif hasattr(widget, signal): 22 getattr(widget, signal).connect(self.slot) 23 else: 24 widget.signal.connect(slot) 19 try: 20 if isinstance(signal, pyqtBoundSignal): 21 signal.connect(self.slot) 22 elif hasattr(widget, signal): 23 getattr(widget, signal).connect(self.slot) 24 else: 25 widget.signal.connect(slot) 26 except AttributeError: 27 msg = "Wrong construction of QtSignalSpy instance" 28 raise RuntimeError, msg 25 29 26 30 def slot(self, *args, **kwargs): … … 28 32 Record emitted signal. 29 33 """ 30 self._ connector[self._count] = {34 self._recorder[self._count] = { 31 35 'args' : args, 32 36 'kwargs' : kwargs, … … 37 41 38 42 def signal(self, index=None): 39 """40 """41 43 if index == None: 42 44 return self._signal … … 45 47 46 48 def count(self): 47 """48 """49 49 return self._count 50 50 51 51 def called(self): 52 """ 53 """ 54 return self._connector 52 return self._recorder -
src/sas/qtgui/UnitTesting/WelcomePanelTest.py
rf721030 r488c49d 1 import sys 2 import unittest 3 4 from PyQt4.QtGui import * 5 from PyQt4.QtTest import QTest 6 from PyQt4.QtCore import * 7 8 # Local 9 from WelcomePanel import WelcomePanel 10 11 app = QApplication(sys.argv) 12 13 class WelcomePanelTest(unittest.TestCase): 14 '''Test the WelcomePanel''' 15 def setUp(self): 16 '''Create the WelcomePanel''' 17 18 self.widget = WelcomePanel(None) 19 20 def tearDown(self): 21 '''Destroy the GUI''' 22 self.widget.close() 23 self.widget = None 24 25 def testDefaults(self): 26 '''Test the GUI in its default state''' 27 self.assertIsInstance(self.widget, QDialog) 28 self.assertEqual(self.widget.windowTitle(), "Welcome") 29 30 def testVersion(self): 31 """ 32 """ 33 version = self.widget.lblVersion 34 self.assertIsInstance(version, QLabel) 35 ver_text = "\nSasView 4.0.0-alpha\nBuild: 1\n(c) 2009 - 2013, UTK, UMD, NIST, ORNL, ISIS, ESS and IL" 36 #self.assertEqual(str(version.text()), ver_text) 37 self.assertIn("SasView", str(version.text())) 38 self.assertIn("Build:", str(version.text())) 39 40 if __name__ == "__main__": 41 unittest.main() -
src/sas/qtgui/WelcomePanel.py
rf721030 r488c49d 18 18 build = sas.sasview.__build__ 19 19 20 self.lblVersion = "\nSasView %s\nBuild: %s" % (version, build) 21 self.lblVersion += "\n(c) 2009 - 2013, UTK, UMD, NIST, ORNL, ISIS, ESS and IL" 20 ver = "\nSasView %s\nBuild: %s" % (version, build) 21 ver += "\n(c) 2009 - 2013, UTK, UMD, NIST, ORNL, ISIS, ESS and IL" 22 23 self.lblVersion.setText(ver) -
src/sas/qtgui/run_tests.sh
rf721030 r488c49d 1 python -m UnitTesting.TestUtilsTest 2 python -m UnitTesting.WelcomePanelTest 1 3 python -m UnitTesting.DataExplorerTest 2 4 python -m UnitTesting.MainWindowTest
Note: See TracChangeset
for help on using the changeset viewer.