Changeset 99ea1b0 in sasview for src/sas/qtgui/Calculators
- Timestamp:
- Oct 27, 2017 8:49:35 AM (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:
- 0849aec
- Parents:
- 895e7359
- Location:
- src/sas/qtgui/Calculators
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Calculators/DataOperationUtilityPanel.py
r895e7359 r99ea1b0 273 273 msg = 'DataOperation: Number requires a float number' 274 274 logging.warning(msg) 275 self.txtNumber.setStyleSheet( QtCore.QString(BG_RED))275 self.txtNumber.setStyleSheet(BG_RED) 276 276 277 277 elif float(self.txtNumber.text()) == 0.: … … 279 279 msg = 'DataOperation: Number requires a non zero number' 280 280 logging.warning(msg) 281 self.txtNumber.setStyleSheet( QtCore.QString(BG_RED))281 self.txtNumber.setStyleSheet(BG_RED) 282 282 283 283 else: 284 self.txtNumber.setStyleSheet( QtCore.QString(BG_WHITE))284 self.txtNumber.setStyleSheet(BG_WHITE) 285 285 self.data2 = float(self.txtNumber.text()) 286 286 self.updatePlot(self.graphData2, self.layoutData2, self.data2) … … 293 293 else: 294 294 if self.cbData2.currentText() == 'Number': 295 self.cbData1.setStyleSheet( QtCore.QString(BG_WHITE))296 self.cbData2.setStyleSheet( QtCore.QString(BG_WHITE))295 self.cbData1.setStyleSheet(BG_WHITE) 296 self.cbData2.setStyleSheet(BG_WHITE) 297 297 return True 298 298 299 299 elif self.data1.__class__.__name__ != self.data2.__class__.__name__: 300 self.cbData1.setStyleSheet( QtCore.QString(BG_RED))301 self.cbData2.setStyleSheet( QtCore.QString(BG_RED))300 self.cbData1.setStyleSheet(BG_RED) 301 self.cbData2.setStyleSheet(BG_RED) 302 302 print(self.data1.__class__.__name__ != self.data2.__class__.__name__) 303 303 logging.warning('Cannot compute data of different dimensions') … … 308 308 not all(i == j for i, j in zip(self.data1.x, self.data2.x))): 309 309 logging.warning('Cannot compute 1D data of different lengths') 310 self.cbData1.setStyleSheet( QtCore.QString(BG_RED))311 self.cbData2.setStyleSheet( QtCore.QString(BG_RED))310 self.cbData1.setStyleSheet(BG_RED) 311 self.cbData2.setStyleSheet(BG_RED) 312 312 return False 313 313 … … 320 320 zip(self.data1.qy_data, self.data2.qy_data)) 321 321 ): 322 self.cbData1.setStyleSheet( QtCore.QString(BG_RED))323 self.cbData2.setStyleSheet( QtCore.QString(BG_RED))322 self.cbData1.setStyleSheet(BG_RED) 323 self.cbData2.setStyleSheet(BG_RED) 324 324 logging.warning('Cannot compute 2D data of different lengths') 325 325 return False 326 326 327 327 else: 328 self.cbData1.setStyleSheet( QtCore.QString(BG_WHITE))329 self.cbData2.setStyleSheet( QtCore.QString(BG_WHITE))328 self.cbData1.setStyleSheet(BG_WHITE) 329 self.cbData2.setStyleSheet(BG_WHITE) 330 330 return True 331 331 … … 333 333 """ Check that name of output does not already exist """ 334 334 name_to_check = str(self.txtOutputData.text()) 335 self.txtOutputData.setStyleSheet( QtCore.QString(BG_WHITE))335 self.txtOutputData.setStyleSheet(BG_WHITE) 336 336 337 337 if name_to_check is None or name_to_check == '': 338 self.txtOutputData.setStyleSheet( QtCore.QString(BG_RED))338 self.txtOutputData.setStyleSheet(BG_RED) 339 339 logging.warning('No output name') 340 340 return False 341 341 342 342 elif name_to_check in self.list_data_items: 343 self.txtOutputData.setStyleSheet( QtCore.QString(BG_RED))343 self.txtOutputData.setStyleSheet(BG_RED) 344 344 logging.warning('The Output data name already exists') 345 345 return False 346 346 347 347 else: 348 self.txtOutputData.setStyleSheet( QtCore.QString(BG_WHITE))348 self.txtOutputData.setStyleSheet(BG_WHITE) 349 349 return True 350 350 -
src/sas/qtgui/Calculators/GenericScatteringCalculator.py
- Property mode changed from 100755 to 100644
rb0b09b9 r99ea1b0 235 235 """Check range of text edits for QMax and Number of Qbins """ 236 236 text_edit = self.sender() 237 text_edit.setStyleSheet( 238 QtCore.QString.fromUtf8('background-color: rgb(255, 255, 255);')) 237 text_edit.setStyleSheet('background-color: rgb(255, 255, 255);') 239 238 if text_edit.text(): 240 239 value = float(str(text_edit.text())) 241 240 if text_edit == self.txtQxMax: 242 241 if value <= 0 or value > 1000: 243 text_edit.setStyleSheet(QtCore.QString.fromUtf8( 244 'background-color: rgb(255, 182, 193);')) 242 text_edit.setStyleSheet('background-color: rgb(255, 182, 193);') 245 243 else: 246 text_edit.setStyleSheet(QtCore.QString.fromUtf8( 247 'background-color: rgb(255, 255, 255);')) 244 text_edit.setStyleSheet('background-color: rgb(255, 255, 255);') 248 245 elif text_edit == self.txtNoQBins: 249 246 if value < 2 or value > 1000: 250 self.txtNoQBins.setStyleSheet(QtCore.QString.fromUtf8( 251 'background-color: rgb(255, 182, 193);')) 247 self.txtNoQBins.setStyleSheet('background-color: rgb(255, 182, 193);') 252 248 else: 253 self.txtNoQBins.setStyleSheet(QtCore.QString.fromUtf8( 254 'background-color: rgb(255, 255, 255);')) 249 self.txtNoQBins.setStyleSheet('background-color: rgb(255, 255, 255);') 255 250 256 251 def update_gui(self): … … 555 550 # Add deferred callback for call return 556 551 d.addCallback(self.plot_1_2d) 552 d.addErrback(self.calculateFailed) 557 553 except: 558 554 log_msg = "{}. stop".format(sys.exc_info()[1]) … … 564 560 Copied from previous version 565 561 """ 562 pass 563 564 def calculateFailed(self, reason): 565 """ 566 """ 567 print("Calculate Failed with:\n", reason) 566 568 pass 567 569 -
src/sas/qtgui/Calculators/ResolutionCalculatorPanel.py
- Property mode changed from 100755 to 100644
rb0b09b9 r99ea1b0 111 111 # call compute to calculate with default values 112 112 self.createTemplate2DPlot() 113 self.onCompute()113 #self.onCompute() 114 114 115 115 # ################################# … … 123 123 text_edit = self.txtWavelength # self.sender() 124 124 if text_edit.isModified(): 125 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))125 text_edit.setStyleSheet(BG_WHITE) 126 126 input_string = str(text_edit.text()) 127 127 if self.cbWaveColor.currentText() != 'TOF': 128 128 input_wavelength = re.match('\d+\.?\d*', input_string) 129 129 if input_wavelength is None: 130 text_edit.setStyleSheet( QtCore.QString(BG_RED))130 text_edit.setStyleSheet(BG_RED) 131 131 self.cmdCompute.setEnabled(False) 132 132 logging.info('Wavelength has to be a number.') 133 133 else: 134 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))134 text_edit.setStyleSheet(BG_WHITE) 135 135 self.cmdCompute.setEnabled(True) 136 136 else: … … 139 139 140 140 if interval_wavelength is None: 141 text_edit.setStyleSheet( QtCore.QString(BG_RED))141 text_edit.setStyleSheet(BG_RED) 142 142 self.cmdCompute.setEnabled(False) 143 143 logging.info("Wavelength's input has to be an interval: " … … 149 149 150 150 if float(wavelength_min) >= float(wavelength_max): 151 text_edit.setStyleSheet( QtCore.QString(BG_RED))151 text_edit.setStyleSheet(BG_RED) 152 152 self.cmdCompute.setEnabled(False) 153 153 logging.info("Wavelength: min must be smaller than max.") 154 154 155 155 else: 156 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))156 text_edit.setStyleSheet(BG_WHITE) 157 157 self.cmdCompute.setEnabled(True) 158 158 … … 163 163 164 164 if text_edit.isModified(): 165 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))165 text_edit.setStyleSheet(BG_WHITE) 166 166 if self.cbWaveColor.currentText() != 'TOF': 167 167 pattern = '^\d+\.?\d*(|;\s*\d+)$' … … 170 170 171 171 if wavelength_spread_input is None: 172 text_edit.setStyleSheet( QtCore.QString(BG_RED))172 text_edit.setStyleSheet(BG_RED) 173 173 self.cmdCompute.setEnabled(False) 174 174 logging.info('Wavelength spread has to be specified: ' … … 178 178 split_input = wavelength_spread_input.group().split(';') 179 179 self.num_wave = split_input[1] if len(split_input) > 1 else 10 180 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))180 text_edit.setStyleSheet(BG_WHITE) 181 181 self.cmdCompute.setEnabled(True) 182 182 else: … … 186 186 187 187 if wavelength_spread_input is None: 188 text_edit.setStyleSheet( QtCore.QString(BG_RED))188 text_edit.setStyleSheet(BG_RED) 189 189 self.cmdCompute.setEnabled(False) 190 190 logging.info("Wavelength spread has to be specified: " … … 197 197 self.num_wave = split_input[1] if len( 198 198 split_input) > 1 else 10 199 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))199 text_edit.setStyleSheet(BG_WHITE) 200 200 self.cmdCompute.setEnabled(True) 201 201 … … 205 205 206 206 if text_edit.isModified(): 207 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))207 text_edit.setStyleSheet(BG_WHITE) 208 208 pattern = '^\d+\.?\d*,\s*\d+\.?\d*$' 209 209 input_string = str(text_edit.text()) … … 211 211 212 212 if pixels_input is None: 213 text_edit.setStyleSheet( QtCore.QString(BG_RED))213 text_edit.setStyleSheet(BG_RED) 214 214 self.cmdCompute.setEnabled(False) 215 215 logging.info('The input for the detector should contain 2 ' … … 217 217 218 218 else: 219 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))219 text_edit.setStyleSheet(BG_WHITE) 220 220 self.cmdCompute.setEnabled(True) 221 221 … … 229 229 q_input = re.match(pattern, input_string) 230 230 if q_input is None: 231 text_edit.setStyleSheet( QtCore.QString(BG_RED))231 text_edit.setStyleSheet(BG_RED) 232 232 self.cmdCompute.setEnabled(False) 233 233 logging.info('Qx and Qy should contain one or more comma-separated numbers.') 234 234 else: 235 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))235 text_edit.setStyleSheet(BG_WHITE) 236 236 self.cmdCompute.setEnabled(True) 237 237 qx = str(self.txtQx.text()).split(',') … … 247 247 248 248 elif len(qx) != len(qy): 249 text_edit.setStyleSheet( QtCore.QString(BG_RED))249 text_edit.setStyleSheet(BG_RED) 250 250 self.cmdCompute.setEnabled(False) 251 251 logging.info( … … 253 253 254 254 else: 255 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))255 text_edit.setStyleSheet(BG_WHITE) 256 256 self.cmdCompute.setEnabled(True) 257 257 … … 261 261 262 262 if text_edit.isModified(): 263 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))263 text_edit.setStyleSheet(BG_WHITE) 264 264 input_string = str(text_edit.text()) 265 265 pattern = '^\d+\.?\d*(|,\s*\d+)$' … … 267 267 268 268 if aperture_input is None: 269 text_edit.setStyleSheet( QtCore.QString(BG_RED))269 text_edit.setStyleSheet(BG_RED) 270 270 self.cmdCompute.setEnabled(False) 271 271 logging.info('A circular aperture is defined by a single ' … … 274 274 275 275 else: 276 text_edit.setStyleSheet( QtCore.QString(BG_WHITE))276 text_edit.setStyleSheet(BG_WHITE) 277 277 self.cmdCompute.setEnabled(True) 278 278 … … 524 524 525 525 cal_res.addCallback(self.complete) 526 cal_res.addErrback(self.calculateFailed) 526 527 527 528 # logging.info("Computation is in progress...") … … 531 532 raise 532 533 534 def calculateFailed(self, reason): 535 print("calculateFailed Failed with:\n", reason) 536 pass 537 533 538 def complete(self, image): 534 539 """ … … 562 567 : return: image (numpy array) 563 568 """ 569 # This fails in py3 with 570 # [Failure instance: Traceback: <class 'TypeError'>: 'map' object is not subscriptable 571 # INVESTIGATE 564 572 image = map(func, qx, qy, 565 573 qx_min, qx_max, -
src/sas/qtgui/Calculators/SldPanel.py
- Property mode changed from 100755 to 100644
-
src/sas/qtgui/Calculators/SlitSizeCalculator.py
- Property mode changed from 100755 to 100644
rb0b09b9 r99ea1b0 82 82 return 83 83 84 if isinstance(path, QtCore.QString):85 path = str(path)86 87 84 return path 88 85 -
src/sas/qtgui/Calculators/UnitTesting/DataOperationUtilityTest.py
r0c468bf r99ea1b0 8 8 from PyQt4.QtTest import QTest 9 9 from PyQt4.QtCore import Qt 10 from mock import MagicMock11 from mock import patch10 from unittest.mock import MagicMock 11 from unittest.mock import patch 12 12 13 13 from twisted.internet import threads -
src/sas/qtgui/Calculators/UnitTesting/DensityCalculatorTest.py
r464cd07 r99ea1b0 6 6 from PyQt4.QtTest import QTest 7 7 from PyQt4 import QtCore 8 from mock import MagicMock8 from unittest.mock import MagicMock 9 9 10 10 ####### TEMP -
src/sas/qtgui/Calculators/UnitTesting/GenericScatteringCalculatorTest.py
rf4a1433 r99ea1b0 7 7 8 8 from PyQt4.QtCore import Qt 9 from mock import MagicMock10 from mock import patch9 from unittest.mock import MagicMock 10 from unittest.mock import patch 11 11 12 12 # set up import paths -
src/sas/qtgui/Calculators/UnitTesting/ResolutionCalculatorPanelTest.py
r170e95d r99ea1b0 8 8 from PyQt4.QtTest import QTest 9 9 from PyQt4.QtCore import Qt 10 from mock import MagicMock 11 from mock import patch 10 from unittest.mock import MagicMock 12 11 13 12 from twisted.internet import threads -
src/sas/qtgui/Calculators/UnitTesting/SLDCalculatorTest.py
rf4a1433 r99ea1b0 6 6 from PyQt4.QtTest import QTest 7 7 from PyQt4 import QtCore 8 from mock import MagicMock8 from unittest.mock import MagicMock 9 9 10 10 ####### TEMP -
src/sas/qtgui/Calculators/UnitTesting/SlitSizeCalculatorTest.py
- Property mode changed from 100755 to 100644
rb0b09b9 r99ea1b0 4 4 from PyQt4.QtTest import QTest 5 5 from PyQt4.QtCore import Qt 6 from mock import MagicMock6 from unittest.mock import MagicMock 7 7 8 8 # set up import paths
Note: See TracChangeset
for help on using the changeset viewer.