Changeset 412e069e in sasview for src/sas/qtgui
- Timestamp:
- Nov 7, 2017 6:29:59 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:
- 3e8dee3
- Parents:
- 6280464
- Location:
- src/sas/qtgui
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Calculators/DataOperationUtilityPanel.py
r6280464 r412e069e 56 56 57 57 # validator for coefficient 58 self.txtNumber.setValidator( QtGui.QDoubleValidator())58 self.txtNumber.setValidator(GuiUtils.DoubleValidator()) 59 59 60 60 self.layoutOutput = QtWidgets.QHBoxLayout() -
src/sas/qtgui/Calculators/GenericScatteringCalculator.py
r6280464 r412e069e 611 611 'options': QtWidgets.QFileDialog.DontUseNativeDialog} 612 612 # Query user for filename. 613 filename = str(QtWidgets.QFileDialog.getSaveFileName(**kwargs)) 613 filename_tuple = QtWidgets.QFileDialog.getSaveFileName(**kwargs) 614 filename = name_tuple[0] 614 615 if filename: 615 616 try: 616 if os.path.splitext(filename)[1].lower() == '.sld': 617 sas_gen.SLDReader().write(filename, self.sld_data) 618 else: 619 sas_gen.SLDReader().write('.'.join((filename, 'sld')), 620 self.sld_data) 617 _, extension = os.path.splitext(filename) 618 if not extension: 619 filename = '.'.join((filename, 'sld')) 620 sas_gen.SLDReader().write(filename, self.sld_data) 621 621 except: 622 622 raise -
src/sas/qtgui/Calculators/ResolutionCalculatorPanel.py
r6280464 r412e069e 106 106 107 107 # double validator 108 self.txtSource2SampleDistance.setValidator( QtGui.QDoubleValidator())109 self.txtSample2DetectorDistance.setValidator( QtGui.QDoubleValidator())110 self.txtSampleOffset.setValidator( QtGui.QDoubleValidator())108 self.txtSource2SampleDistance.setValidator(GuiUtils.DoubleValidator()) 109 self.txtSample2DetectorDistance.setValidator(GuiUtils.DoubleValidator()) 110 self.txtSampleOffset.setValidator(GuiUtils.DoubleValidator()) 111 111 112 112 # call compute to calculate with default values -
src/sas/qtgui/MainWindow/DataExplorer.py
r6280464 r412e069e 270 270 'options' : QtWidgets.QFileDialog.DontUseNativeDialog 271 271 } 272 filename = str(QtWidgets.QFileDialog.getSaveFileName(**kwargs)) 272 name_tuple = QtWidgets.QFileDialog.getSaveFileName(**kwargs) 273 filename = name_tuple[0] 273 274 if filename: 275 _, extension = os.path.splitext(filename) 276 if not extension: 277 filename = '.'.join((filename, 'json')) 274 278 self.communicator.statusBarUpdateSignal.emit("Saving Project... %s\n" % os.path.basename(filename)) 275 279 with open(filename, 'w') as outfile: … … 1084 1088 # TODO: fix this to resemble GuiUtils.updateModelItemWithPlot 1085 1089 # 1086 self.model.beginResetModel() 1087 current_tab_name = model_item.text()[:2] 1088 for current_index in range(self.theory_model.rowCount()): 1089 if current_tab_name in self.theory_model.item(current_index).text(): 1090 self.theory_model.removeRow(current_index) 1091 break 1092 1093 # Reset the view 1094 self.model.endResetModel() 1090 ##self.model.beginResetModel() 1091 ##current_tab_name = model_item.text()[:2] 1092 ##for current_index in range(self.theory_model.rowCount()): 1093 #if current_tab_name in self.theory_model.item(current_index).text(): 1094 # return 1095 ## self.theory_model.removeRow(current_index) 1096 ## break 1097 1098 ### Reset the view 1099 ##self.model.endResetModel() 1095 1100 1096 1101 # Reset the view -
src/sas/qtgui/MainWindow/GuiManager.py
r6280464 r412e069e 8 8 from PyQt5.QtWidgets import * 9 9 from PyQt5.QtGui import * 10 from PyQt5.QtCore import Qt, QLocale 10 from PyQt5.QtCore import Qt, QLocale, QUrl 11 11 from PyQt5.QtWebKitWidgets import QWebView 12 12 … … 55 55 self._workspace = parent 56 56 self._parent = parent 57 58 # Decide on a locale 59 QLocale.setDefault(QLocale('en_US')) 57 60 58 61 # Add signal callbacks -
src/sas/qtgui/MainWindow/MainWindow.py
r6280464 r412e069e 61 61 # (unless you know what you're doing) 62 62 import qt5reactor 63 # Using the Qt 4reactor wrapper from https://github.com/ghtdak/qtreactor63 # Using the Qt5 reactor wrapper from https://github.com/ghtdak/qtreactor 64 64 qt5reactor.install() 65 65 -
src/sas/qtgui/Perspectives/Fitting/FittingOptions.py
r0849aec r412e069e 88 88 validator.setBottom(0) 89 89 elif f_type == float: 90 validator = QtGui.QDoubleValidator()90 validator = GuiUtils.DoubleValidator() 91 91 validator.setBottom(0) 92 92 else: -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r6280464 r412e069e 13 13 from PyQt5 import QtWidgets 14 14 from PyQt5 import QtWebKitWidgets 15 # Officially QtWebEngineWidgets are the way to display HTML in Qt5, 16 # but this module isn't ported to PyQt5 yet... 17 # let's wait. In the meantime no Help. 18 #from PyQt5 import QtWebEngineWidgets 15 19 16 20 from sasmodels import generate … … 50 54 DEFAULT_POLYDISP_FUNCTION = 'gaussian' 51 55 52 USING_TWISTED = True 56 #USING_TWISTED = True 57 USING_TWISTED = False 53 58 54 59 class ToolTippedItemModel(QtGui.QStandardItemModel): … … 463 468 menu = QtWidgets.QMenu() 464 469 label = QtWidgets.QLabel(msg) 465 action = Qt Gui.QWidgetAction(self)470 action = QtWidgets.QWidgetAction(self) 466 471 action.setDefaultWidget(label) 467 472 menu.addAction(action) … … 472 477 Respond to select Model from list event 473 478 """ 474 model = s tr(self.cbModel.currentText())479 model = self.cbModel.currentText() 475 480 476 481 # empty combobox forced to be read … … 528 533 Select Category from list 529 534 """ 530 category = s tr(self.cbCategory.currentText())535 category = self.cbCategory.currentText() 531 536 # Check if the user chose "Choose category entry" 532 537 if category == CATEGORY_DEFAULT: … … 674 679 helpfile = "mag_help.html" 675 680 help_location = tree_location + helpfile 681 682 content = QtCore.QUrl(help_location) 676 683 self.helpView.load(QtCore.QUrl(help_location)) 677 684 self.helpView.show() … … 727 734 fitter = Fit() 728 735 data = GuiUtils.dataFromItem(fit_index) 729 fitter.set_model(model, fit_id, params_to_fit, data=data, 736 try: 737 fitter.set_model(model, fit_id, params_to_fit, data=data, 730 738 constraints=constraints) 739 except ValueError as ex: 740 logging.error("Setting model parameters failed with: %s" % ex) 741 return 742 731 743 qmin, qmax, _ = self.logic.computeRangeFromData(data) 732 744 fitter.set_data(data=data, id=fit_id, smearer=smearer, qmin=qmin, … … 1513 1525 residuals_plot.id = "Residual " + residuals_plot.id 1514 1526 self.createNewIndex(residuals_plot) 1515 self.communicate.plotUpdateSignal.emit([residuals_plot])1527 #self.communicate.plotUpdateSignal.emit([residuals_plot]) 1516 1528 1517 1529 def calcException(self, etype, value, tb): -
src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py
r0849aec r412e069e 8 8 9 9 from sas.qtgui.Plotting.PlotterData import Data2D 10 import sas.qtgui.Utilities.GuiUtils as GuiUtils 10 11 11 12 # Local UI … … 66 67 67 68 # Let only floats in the range edits 68 self.txtMinRange.setValidator( QtGui.QDoubleValidator())69 self.txtMaxRange.setValidator( QtGui.QDoubleValidator())69 self.txtMinRange.setValidator(GuiUtils.DoubleValidator()) 70 self.txtMaxRange.setValidator(GuiUtils.DoubleValidator()) 70 71 # Let only ints in the number of points edit 71 72 self.txtNpts.setValidator(QtGui.QIntValidator()) -
src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py
r0849aec r412e069e 8 8 from sas.qtgui.Plotting.PlotterData import Data1D 9 9 from sas.qtgui.Plotting.PlotterData import Data2D 10 import sas.qtgui.Utilities.GuiUtils as GuiUtils 10 11 11 12 # Local UI … … 51 52 self.parent = parent 52 53 # Let only floats in the line edits 53 self.txtSmearDown.setValidator( QtGui.QDoubleValidator())54 self.txtSmearUp.setValidator( QtGui.QDoubleValidator())54 self.txtSmearDown.setValidator(GuiUtils.DoubleValidator()) 55 self.txtSmearUp.setValidator(GuiUtils.DoubleValidator()) 55 56 56 57 # Attach slots -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r6280464 r412e069e 4 4 5 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils 6 7 class CommaLessValidator(QtGui.QDoubleValidator):8 """9 Custom double validator which doesn't allow for commas to be used as decimal point10 """11 pass12 6 13 7 class ModelViewDelegate(QtWidgets.QStyledItemDelegate): … … 87 81 if index.column() == self.param_value: #only in the value column 88 82 editor = QtWidgets.QLineEdit(widget) 89 validator = QtGui.QDoubleValidator()83 validator = GuiUtils.DoubleValidator() 90 84 editor.setValidator(validator) 91 85 return editor … … 168 162 elif index.column() in self.editableParameters(): 169 163 self.editor = QtWidgets.QLineEdit(widget) 170 validator = QtGui.QDoubleValidator()164 validator = GuiUtils.DoubleValidator() 171 165 self.editor.setValidator(validator) 172 166 return self.editor … … 246 240 if index.column() in self.editableParameters(): 247 241 editor = QtWidgets.QLineEdit(widget) 248 validator = QtGui.QDoubleValidator()242 validator = GuiUtils.DoubleValidator() 249 243 editor.setValidator(validator) 250 244 return editor -
src/sas/qtgui/Plotting/BoxSum.py
r6280464 r412e069e 5 5 from PyQt5 import QtGui 6 6 from PyQt5 import QtWidgets 7 8 import sas.qtgui.Utilities.GuiUtils as GuiUtils 7 9 8 10 # Local UI … … 17 19 assert isinstance(model, QtGui.QStandardItemModel) 18 20 19 self.txtBoxHeight.setValidator( QtGui.QDoubleValidator())20 self.txtBoxWidth.setValidator( QtGui.QDoubleValidator())21 self.txtCenterX.setValidator( QtGui.QDoubleValidator())22 self.txtCenterY.setValidator( QtGui.QDoubleValidator())21 self.txtBoxHeight.setValidator(GuiUtils.DoubleValidator()) 22 self.txtBoxWidth.setValidator(GuiUtils.DoubleValidator()) 23 self.txtCenterX.setValidator(GuiUtils.DoubleValidator()) 24 self.txtCenterY.setValidator(GuiUtils.DoubleValidator()) 23 25 24 26 self.model = model -
src/sas/qtgui/Plotting/ColorMap.py
r0849aec r412e069e 13 13 from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 14 14 from sas.qtgui.Plotting.PlotterData import Data2D 15 from sas.qtgui.Utilities.GuiUtils import formatNumber 15 from sas.qtgui.Utilities.GuiUtils import formatNumber, DoubleValidator 16 16 from .rangeSlider import RangeSlider 17 17 … … 51 51 52 52 # Initialize validators on amplitude textboxes 53 validator_min = QtGui.QDoubleValidator(self.txtMinAmplitude)53 validator_min = DoubleValidator(self.txtMinAmplitude) 54 54 validator_min.setNotation(0) 55 55 self.txtMinAmplitude.setValidator(validator_min) 56 validator_max = QtGui.QDoubleValidator(self.txtMaxAmplitude)56 validator_max = DoubleValidator(self.txtMaxAmplitude) 57 57 validator_max.setNotation(0) 58 58 self.txtMaxAmplitude.setValidator(validator_max) -
src/sas/qtgui/Plotting/LinearFit.py
r304d082 r412e069e 8 8 from PyQt5 import QtWidgets 9 9 10 from sas.qtgui.Utilities.GuiUtils import formatNumber 10 from sas.qtgui.Utilities.GuiUtils import formatNumber, DoubleValidator 11 11 12 12 from sas.qtgui.Plotting import Fittings … … 43 43 self.y_is_log = self.yLabel == "log10(y)" 44 44 45 self.txtFitRangeMin.setValidator( QtGui.QDoubleValidator())46 self.txtFitRangeMax.setValidator( QtGui.QDoubleValidator())45 self.txtFitRangeMin.setValidator(DoubleValidator()) 46 self.txtFitRangeMax.setValidator(DoubleValidator()) 47 47 48 48 # Default values in the line edits … … 158 158 y_model = self.model.run(xmin) 159 159 tempx.append(xminView) 160 tempy.append(numpy.power(10 , y_model) if self.y_is_log else y_model)160 tempy.append(numpy.power(10.0, y_model) if self.y_is_log else y_model) 161 161 162 162 # load tempy with the maximum transformation 163 163 y_model = self.model.run(xmax) 164 164 tempx.append(xmaxView) 165 tempy.append(numpy.power(10 , y_model) if self.y_is_log else y_model)165 tempy.append(numpy.power(10.0, y_model) if self.y_is_log else y_model) 166 166 167 167 # Set the fit parameter display when FitDialog is opened again … … 247 247 return numpy.sqrt(numpy.sqrt(x)) 248 248 elif self.xLabel == "log10(x)": 249 return numpy.power(10 , x)249 return numpy.power(10.0, x) 250 250 elif self.xLabel == "ln(x)": 251 251 return numpy.exp(x) 252 252 elif self.xLabel == "log10(x^(4))": 253 return numpy.sqrt(numpy.sqrt(numpy.power(10 , x)))253 return numpy.sqrt(numpy.sqrt(numpy.power(10.0, x))) 254 254 return x 255 255 -
src/sas/qtgui/Plotting/Plotter2D.py
r6280464 r412e069e 3 3 import pylab 4 4 import functools 5 import logging 5 6 6 7 from PyQt5 import QtCore … … 126 127 zmax_temp = self.zmax 127 128 # self.scale predefined in the baseclass 129 # in numpy > 1.12 power(int, -int) raises ValueException 130 # "Integers to negative integer powers are not allowed." 128 131 if self.scale == 'log_{10}': 129 132 if self.zmin is not None: 130 zmin_temp = numpy.power(10 , self.zmin)133 zmin_temp = numpy.power(10.0, self.zmin) 131 134 if self.zmax is not None: 132 zmax_temp = numpy.power(10 , self.zmax)135 zmax_temp = numpy.power(10.0, self.zmax) 133 136 else: 134 137 if self.zmin is not None: … … 289 292 new_plot.is_data = True 290 293 GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 294 291 295 self.manager.communicator.plotUpdateSignal.emit([new_plot]) 292 296 -
src/sas/qtgui/Plotting/SetGraphRange.py
r0849aec r412e069e 5 5 from PyQt5 import QtGui 6 6 from PyQt5 import QtWidgets 7 8 import sas.qtgui.Utilities.GuiUtils as GuiUtils 7 9 8 10 # Local UI … … 18 20 assert(isinstance(y_range, tuple)) 19 21 20 self.txtXmin.setValidator( QtGui.QDoubleValidator())21 self.txtXmax.setValidator( QtGui.QDoubleValidator())22 self.txtYmin.setValidator( QtGui.QDoubleValidator())23 self.txtYmax.setValidator( QtGui.QDoubleValidator())22 self.txtXmin.setValidator(GuiUtils.DoubleValidator()) 23 self.txtXmax.setValidator(GuiUtils.DoubleValidator()) 24 self.txtYmin.setValidator(GuiUtils.DoubleValidator()) 25 self.txtYmax.setValidator(GuiUtils.DoubleValidator()) 24 26 25 27 self.txtXmin.setText(str(x_range[0])) -
src/sas/qtgui/Plotting/SlicerModel.py
r0849aec r412e069e 1 1 from PyQt5 import QtGui 2 from PyQt5 import QtCore 2 3 3 4 import sas.qtgui.Utilities.GuiUtils as GuiUtils -
src/sas/qtgui/Plotting/SlicerParameters.py
r0849aec r412e069e 8 8 from PyQt5 import QtWidgets 9 9 from PyQt5 import QtWebKitWidgets 10 11 import sas.qtgui.Utilities.GuiUtils as GuiUtils 10 12 11 13 # Local UI … … 126 128 super(PositiveDoubleEditor, self).__init__(parent) 127 129 self.setAutoFillBackground(True) 128 validator = QtGui.QDoubleValidator()130 validator = GuiUtils.DoubleValidator() 129 131 # Don't use the scientific notation, cause 'e'. 130 validator.setNotation( QtGui.QDoubleValidator.StandardNotation)132 validator.setNotation(GuiUtils.DoubleValidator.StandardNotation) 131 133 132 134 self.setValidator(validator) -
src/sas/qtgui/Plotting/Slicers/SectorSlicer.py
r0849aec r412e069e 3 3 """ 4 4 import numpy 5 import logging 5 6 6 7 from .BaseInteractor import BaseInteractor … … 167 168 new_plot.is_data = True 168 169 GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 170 169 171 self.base.manager.communicator.plotUpdateSignal.emit([new_plot]) 170 172 -
src/sas/qtgui/Utilities/GuiUtils.py
r6280464 r412e069e 584 584 } 585 585 # Query user for filename. 586 filename = QtWidgets.QFileDialog.getSaveFileName(**kwargs) 586 filename_tuple = QtWidgets.QFileDialog.getSaveFileName(**kwargs) 587 filename = filename_tuple[0] 587 588 588 589 # User cancelled. 589 590 if not filename: 590 591 return 591 592 filename = str(filename)593 592 594 593 #Instantiate a loader … … 616 615 } 617 616 # Query user for filename. 618 filename = QtWidgets.QFileDialog.getSaveFileName(**kwargs) 617 filename_tuple = QtWidgets.QFileDialog.getSaveFileName(**kwargs) 618 filename = filename_tuple[0] 619 619 620 620 # User cancelled. 621 621 if not filename: 622 622 return 623 filename = str(filename) 623 624 624 #Instantiate a loader 625 625 loader = Loader() … … 825 825 else: 826 826 raise ValueError 827 828 class DoubleValidator(QtGui.QDoubleValidator): 829 """ 830 Allow only dots as decimal separator 831 """ 832 def validate(self, input, pos): 833 """ 834 Return invalid for commas 835 """ 836 if (',' in input): 837 return (QtGui.QValidator.Invalid, input, pos) 838 return super(DoubleValidator, self).validate(input, pos) 839 840 def fixup(self, input): 841 """ 842 Correct (remove) potential preexisting content 843 """ 844 QtGui.QDoubleValidator.fixup(input) 845 input = input.replace(",", "") 846
Note: See TracChangeset
for help on using the changeset viewer.