Changeset 4992ff2 in sasview for src/sas/qtgui/Perspectives/Fitting
- Timestamp:
- Nov 9, 2017 8:43:07 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:
- 7969b9c
- Parents:
- 7fb471d
- git-author:
- Piotr Rozyczko <rozyczko@…> (10/30/17 07:50:09)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/09/17 08:43:07)
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingOptions.py
- Property mode changed from 100755 to 100644
rb3e8629 r4992ff2 4 4 import types 5 5 6 from PyQt4 import QtCore 7 from PyQt4 import QtGui 8 from PyQt4 import QtWebKit 6 from PyQt5 import QtCore 7 from PyQt5 import QtGui 8 from PyQt5 import QtWidgets 9 from PyQt5 import QtWebKitWidgets 9 10 10 11 from sas.qtgui.UI import images_rc … … 21 22 22 23 23 class FittingOptions(Qt Gui.QDialog, Ui_FittingOptions):24 class FittingOptions(QtWidgets.QDialog, Ui_FittingOptions): 24 25 """ 25 26 Hard-coded version of the fit options dialog available from BUMPS. … … 52 53 53 54 # Handle the Apply button click 54 self.buttonBox.button(Qt Gui.QDialogButtonBox.Ok).clicked.connect(self.onApply)55 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).clicked.connect(self.onApply) 55 56 # handle the Help button click 56 self.buttonBox.button(Qt Gui.QDialogButtonBox.Help).clicked.connect(self.onHelp)57 self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self.onHelp) 57 58 58 59 # Handle the combo box changes … … 71 72 72 73 # OK has to be initialized to True, after initial validator setup 73 self.buttonBox.button(Qt Gui.QDialogButtonBox.Ok).setEnabled(True)74 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 74 75 75 76 # Display HTML content 76 self.helpView = QtWebKit .QWebView()77 self.helpView = QtWebKitWidgets.QWebView() 77 78 78 79 def assignValidators(self): … … 104 105 if state == QtGui.QValidator.Acceptable: 105 106 color = '' # default 106 self.buttonBox.button(Qt Gui.QDialogButtonBox.Ok).setEnabled(True)107 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 107 108 else: 108 109 color = '#fff79a' # yellow 109 self.buttonBox.button(Qt Gui.QDialogButtonBox.Ok).setEnabled(False)110 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False) 110 111 111 112 sender.setStyleSheet('QLineEdit { background-color: %s }' % color) … … 134 135 135 136 # OK has to be reinitialized to True 136 self.buttonBox.button(Qt Gui.QDialogButtonBox.Ok).setEnabled(True)137 self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True) 137 138 138 139 def onApply(self): … … 148 149 """ 149 150 widget = self.widgetFromOption(option) 150 new_value = widget.currentText() if isinstance(widget, Qt Gui.QComboBox) \151 new_value = widget.currentText() if isinstance(widget, QtWidgets.QComboBox) \ 151 152 else float(widget.text()) 152 153 self.config.values[self.current_fitter_id][option] = new_value -
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
rb3e8629 r4992ff2 1 1 import numpy 2 2 3 from PyQt4 import QtCore 4 from PyQt4 import QtGui 3 from PyQt5 import QtCore 4 from PyQt5 import QtGui 5 from PyQt5 import QtWidgets 5 6 6 7 from bumps import options … … 14 15 #from sas.qtgui.Perspectives.Fitting import ModelUtilities 15 16 16 class FittingWindow(Qt Gui.QTabWidget):17 class FittingWindow(QtWidgets.QTabWidget): 17 18 """ 18 19 """ 19 20 name = "Fitting" # For displaying in the combo box in DataExplorer 20 21 def __init__(self, parent=None, data=None): 22 21 23 super(FittingWindow, self).__init__() 22 24 -
src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
rcee5c78 r4992ff2 1 1 from copy import deepcopy 2 2 3 from PyQt4 import QtGui 4 from PyQt4 import QtCore 3 from PyQt5 import QtCore 4 from PyQt5 import QtGui 5 from PyQt5 import QtWidgets 5 6 6 7 import numpy -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r7fb471d r4992ff2 9 9 import numpy as np 10 10 11 from PyQt4 import QtGui 12 from PyQt4 import QtCore 13 from PyQt4 import QtWebKit 11 from PyQt5 import QtCore 12 from PyQt5 import QtGui 13 from PyQt5 import QtWidgets 14 from PyQt5 import QtWebKitWidgets 14 15 15 16 from sasmodels import product … … 74 75 return QtGui.QStandardItemModel.headerData(self, section, orientation, role) 75 76 76 class FittingWidget(Qt Gui.QWidget, Ui_FittingWidgetUI):77 class FittingWidget(QtWidgets.QWidget, Ui_FittingWidgetUI): 77 78 """ 78 79 Main widget for selecting form and structure factor models … … 121 122 122 123 # Display HTML content 123 self.helpView = QtWebKit .QWebView()124 self.helpView = QtWebKitWidgets.QWebView() 124 125 125 126 # New font to display angstrom symbol … … 233 234 """ 234 235 # Options widget 235 layout = Qt Gui.QGridLayout()236 layout = QtWidgets.QGridLayout() 236 237 self.options_widget = OptionsWidget(self, self.logic) 237 238 layout.addWidget(self.options_widget) … … 239 240 240 241 # Smearing widget 241 layout = Qt Gui.QGridLayout()242 layout = QtWidgets.QGridLayout() 242 243 self.smearing_widget = SmearingWidget(self) 243 244 layout.addWidget(self.smearing_widget) … … 254 255 255 256 # Magnetic angles explained in one picture 256 self.magneticAnglesWidget = Qt Gui.QWidget()257 labl = Qt Gui.QLabel(self.magneticAnglesWidget)257 self.magneticAnglesWidget = QtWidgets.QWidget() 258 labl = QtWidgets.QLabel(self.magneticAnglesWidget) 258 259 pixmap = QtGui.QPixmap(GuiUtils.IMAGES_DIRECTORY_LOCATION + '/M_angles_pic.bmp') 259 260 labl.setPixmap(pixmap) … … 274 275 self.lstParams.setModel(self._model_model) 275 276 self.readCategoryInfo() 277 276 278 self.model_parameters = None 277 279 … … 307 309 self.lstParams.customContextMenuRequested.connect(self.showModelDescription) 308 310 self.lstParams.setAttribute(QtCore.Qt.WA_MacShowFocusRect, False) 309 310 311 # Poly model displayed in poly list 311 312 self.lstPoly.setModel(self._poly_model) … … 466 467 msg += "You must select a model to get information on this" 467 468 468 menu = Qt Gui.QMenu()469 label = Qt Gui.QLabel(msg)469 menu = QtWidgets.QMenu() 470 label = QtWidgets.QLabel(msg) 470 471 action = QtGui.QWidgetAction(self) 471 472 action.setDefaultWidget(label) … … 915 916 self.lstParams.resizeColumnToContents(4) 916 917 self.lstParams.resizeColumnToContents(5) 917 self.lstParams.setSizePolicy(Qt Gui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding)918 self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 918 919 919 920 self.has_error_column = True … … 1230 1231 # Adjust the table cells width 1231 1232 self.lstParams.resizeColumnToContents(0) 1232 self.lstParams.setSizePolicy(Qt Gui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding)1233 self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 1233 1234 1234 1235 # Now we claim the model has been loaded … … 1536 1537 table.verticalHeader().setVisible(False) 1537 1538 table.setAlternatingRowColors(True) 1538 table.setSizePolicy(Qt Gui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding)1539 table.setSelectionBehavior(Qt Gui.QAbstractItemView.SelectRows)1539 table.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 1540 table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) 1540 1541 table.resizeColumnsToContents() 1541 1542 1542 1543 # Header 1543 1544 header = table.horizontalHeader() 1544 header.setResizeMode(QtGui.QHeaderView.ResizeToContents) 1545 1546 header.ResizeMode(QtGui.QHeaderView.Interactive) 1545 header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) 1546 header.ResizeMode(QtWidgets.QHeaderView.Interactive) 1547 1548 # Qt5: the following 2 lines crash - figure out why! 1547 1549 # Resize column 0 and 7 to content 1548 header.setResizeMode(0, QtGui.QHeaderView.ResizeToContents)1549 header.setResizeMode(7, QtGui.QHeaderView.ResizeToContents)1550 #header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) 1551 #header.setSectionResizeMode(7, QtWidgets.QHeaderView.ResizeToContents) 1550 1552 1551 1553 def setPolyModel(self): … … 1600 1602 1601 1603 # All possible polydisp. functions as strings in combobox 1602 func = Qt Gui.QComboBox()1604 func = QtWidgets.QComboBox() 1603 1605 func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS.keys()]) 1604 1606 # Set the default index … … 1683 1685 Show the load file dialog and loads requested data into state 1684 1686 """ 1685 datafile = Qt Gui.QFileDialog.getOpenFileName(1686 self, "Choose a weight file", "", "All files (*.*)", 1687 Qt Gui.QFileDialog.DontUseNativeDialog)1687 datafile = QtWidgets.QFileDialog.getOpenFileName( 1688 self, "Choose a weight file", "", "All files (*.*)", None, 1689 QtWidgets.QFileDialog.DontUseNativeDialog) 1688 1690 1689 1691 if datafile is None or str(datafile)=='': … … 1784 1786 item1 = QtGui.QStandardItem(param_name) 1785 1787 1786 func = Qt Gui.QComboBox()1788 func = QtWidgets.QComboBox() 1787 1789 # Available range of shells displayed in the combobox 1788 1790 func.addItems([str(i) for i in range(param_length+1)]) -
src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py
- Property mode changed from 100755 to 100644
rb3e8629 r4992ff2 3 3 """ 4 4 import numpy as np 5 from PyQt4 import QtGui 6 from PyQt4 import QtCore 5 from PyQt5 import QtCore 6 from PyQt5 import QtGui 7 from PyQt5 import QtWidgets 7 8 8 9 from sas.qtgui.Plotting.PlotterData import Data2D … … 21 22 'LOG_SPACED'] 22 23 23 class DataWidgetMapper(Qt Gui.QDataWidgetMapper):24 class DataWidgetMapper(QtWidgets.QDataWidgetMapper): 24 25 """ 25 26 Custom version of the standard QDataWidgetMapper allowing for proper … … 32 33 super(DataWidgetMapper, self).addMapping(widget, section, propertyName) 33 34 34 if isinstance(widget, Qt Gui.QComboBox):35 if isinstance(widget, QtWidgets.QComboBox): 35 36 delegate = self.itemDelegate() 36 37 widget.currentIndexChanged.connect(lambda: delegate.commitData.emit(widget)) 37 38 38 elif isinstance(widget, Qt Gui.QCheckBox):39 elif isinstance(widget, QtWidgets.QCheckBox): 39 40 delegate = self.itemDelegate() 40 41 widget.stateChanged.connect(lambda: delegate.commitData.emit(widget)) 41 42 42 class OptionsWidget(Qt Gui.QWidget, Ui_tabOptions):43 class OptionsWidget(QtWidgets.QWidget, Ui_tabOptions): 43 44 plot_signal = QtCore.pyqtSignal() 44 45 def __init__(self, parent=None, logic=None): … … 52 53 53 54 # Weight radio box group 54 self.weightingGroup = Qt Gui.QButtonGroup()55 self.weightingGroup = QtWidgets.QButtonGroup() 55 56 self.weighting = 0 56 57 … … 114 115 self.mapper.addMapping(self.txtNpts, MODEL.index('NPTS')) 115 116 self.mapper.addMapping(self.chkLogData, MODEL.index('LOG_SPACED')) 116 self.mapper.toFirst() 117 # FIXME DOESNT WORK WITH QT5 118 #self.mapper.toFirst() 117 119 118 120 def toggleLogData(self, isChecked): -
src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py
- Property mode changed from 100755 to 100644
rb3e8629 r4992ff2 2 2 Widget/logic for smearing data. 3 3 """ 4 from PyQt4 import QtGui 5 from PyQt4 import QtCore 4 from PyQt5 import QtCore 5 from PyQt5 import QtGui 6 from PyQt5 import QtWidgets 6 7 7 8 from sas.qtgui.Plotting.PlotterData import Data1D … … 11 12 from sas.qtgui.Perspectives.Fitting.UI.SmearingWidgetUI import Ui_SmearingWidgetUI 12 13 13 class DataWidgetMapper(Qt Gui.QDataWidgetMapper):14 class DataWidgetMapper(QtWidgets.QDataWidgetMapper): 14 15 """ 15 16 Custom version of the standard QDataWidgetMapper allowing for proper … … 22 23 super(DataWidgetMapper, self).addMapping(widget, section, propertyName) 23 24 24 if isinstance(widget, Qt Gui.QComboBox):25 if isinstance(widget, QtWidgets.QComboBox): 25 26 delegate = self.itemDelegate() 26 27 widget.currentIndexChanged.connect(lambda: delegate.commitData.emit(widget)) … … 35 36 'ACCURACY'] 36 37 37 class SmearingWidget(Qt Gui.QWidget, Ui_SmearingWidgetUI):38 class SmearingWidget(QtWidgets.QWidget, Ui_SmearingWidgetUI): 38 39 def __init__(self, parent=None): 39 40 super(SmearingWidget, self).__init__() … … 83 84 self.mapper.addMapping(self.cbSmearing, MODEL.index('SMEARING')) 84 85 self.mapper.addMapping(self.cbAccuracy, MODEL.index('ACCURACY')) 85 self.mapper.toFirst() 86 87 # FIXME DOESNT WORK WITH QT5 88 #self.mapper.toFirst() 86 89 87 90 def updateSmearing(self, data=None): -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r02f1d12 r4992ff2 1 from PyQt4 import QtGui 2 from PyQt4 import QtCore 1 from PyQt5 import QtCore 2 from PyQt5 import QtGui 3 from PyQt5 import QtWidgets 3 4 4 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils 5 6 6 class ModelViewDelegate(Qt Gui.QStyledItemDelegate):7 class ModelViewDelegate(QtWidgets.QStyledItemDelegate): 7 8 """ 8 9 Custom delegate for appearance and behavior control of the model view … … 12 13 Overwrite generic constructor to allow for some globals 13 14 """ 14 super(Qt Gui.QStyledItemDelegate, self).__init__()15 super(QtWidgets.QStyledItemDelegate, self).__init__() 15 16 16 17 # Main parameter table view columns … … 43 44 if index.column() in self.fancyColumns(): 44 45 # Units - present in nice HTML 45 options = QtGui.QStyleOptionViewItemV4(option) 46 #options = QtWidgets.QStyleOptionViewItemV4(option) 47 options = QtWidgets.QStyleOptionViewItem(option) 46 48 self.initStyleOption(options,index) 47 49 … … 57 59 # delete the original content 58 60 options.text = "" 59 style.drawControl(Qt Gui.QStyle.CE_ItemViewItem, options, painter, options.widget);61 style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 60 62 61 63 context = QtGui.QAbstractTextDocumentLayout.PaintContext() 62 textRect = style.subElementRect(Qt Gui.QStyle.SE_ItemViewItemText, options)64 textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 63 65 64 66 painter.save() … … 70 72 else: 71 73 # Just the default paint 72 Qt Gui.QStyledItemDelegate.paint(self, painter, option, index)74 QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 73 75 74 76 def createEditor(self, widget, option, index): … … 79 81 return 0 80 82 if index.column() == self.param_value: #only in the value column 81 editor = Qt Gui.QLineEdit(widget)83 editor = QtWidgets.QLineEdit(widget) 82 84 validator = QtGui.QDoubleValidator() 83 85 editor.setValidator(validator) … … 100 102 # balloon popup? tooltip? cell background colour flash? 101 103 return 102 Qt Gui.QStyledItemDelegate.setModelData(self, editor, model, index)103 104 105 class PolyViewDelegate(Qt Gui.QStyledItemDelegate):104 QtWidgets.QStyledItemDelegate.setModelData(self, editor, model, index) 105 106 107 class PolyViewDelegate(QtWidgets.QStyledItemDelegate): 106 108 """ 107 109 Custom delegate for appearance and behavior control of the polydispersity view … … 116 118 Overwrite generic constructor to allow for some globals 117 119 """ 118 super(Qt Gui.QStyledItemDelegate, self).__init__()120 super(QtWidgets.QStyledItemDelegate, self).__init__() 119 121 120 122 self.poly_parameter = 0 … … 160 162 return None 161 163 elif index.column() in self.editableParameters(): 162 self.editor = Qt Gui.QLineEdit(widget)164 self.editor = QtWidgets.QLineEdit(widget) 163 165 validator = QtGui.QDoubleValidator() 164 166 self.editor.setValidator(validator) 165 167 return self.editor 166 168 else: 167 Qt Gui.QStyledItemDelegate.createEditor(self, widget, option, index)169 QtWidgets.QStyledItemDelegate.createEditor(self, widget, option, index) 168 170 169 171 def paint(self, painter, option, index): … … 173 175 if index.column() in (self.poly_min, self.poly_max): 174 176 # Units - present in nice HTML 175 options = Qt Gui.QStyleOptionViewItemV4(option)177 options = QtWidgets.QStyleOptionViewItem(option) 176 178 self.initStyleOption(options,index) 177 179 … … 187 189 # delete the original content 188 190 options.text = "" 189 style.drawControl(Qt Gui.QStyle.CE_ItemViewItem, options, painter, options.widget);191 style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 190 192 191 193 context = QtGui.QAbstractTextDocumentLayout.PaintContext() 192 textRect = style.subElementRect(Qt Gui.QStyle.SE_ItemViewItemText, options)194 textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 193 195 194 196 painter.save() … … 200 202 else: 201 203 # Just the default paint 202 Qt Gui.QStyledItemDelegate.paint(self, painter, option, index)203 204 class MagnetismViewDelegate(Qt Gui.QStyledItemDelegate):204 QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) 205 206 class MagnetismViewDelegate(QtWidgets.QStyledItemDelegate): 205 207 """ 206 208 Custom delegate for appearance and behavior control of the magnetism view … … 210 212 Overwrite generic constructor to allow for some globals 211 213 """ 212 super(Qt Gui.QStyledItemDelegate, self).__init__()214 super(QtWidgets.QStyledItemDelegate, self).__init__() 213 215 214 216 self.mag_parameter = 0 … … 238 240 return 0 239 241 if index.column() in self.editableParameters(): 240 editor = Qt Gui.QLineEdit(widget)242 editor = QtWidgets.QLineEdit(widget) 241 243 validator = QtGui.QDoubleValidator() 242 244 editor.setValidator(validator) 243 245 return editor 244 246 else: 245 Qt Gui.QStyledItemDelegate.createEditor(self, widget, option, index)247 QtWidgets.QStyledItemDelegate.createEditor(self, widget, option, index) 246 248 247 249 def paint(self, painter, option, index): … … 251 253 if index.column() in (self.mag_min, self.mag_max, self.mag_unit): 252 254 # Units - present in nice HTML 253 options = Qt Gui.QStyleOptionViewItemV4(option)255 options = QtWidgets.QStyleOptionViewItem(option) 254 256 self.initStyleOption(options,index) 255 257 … … 265 267 # delete the original content 266 268 options.text = "" 267 style.drawControl(Qt Gui.QStyle.CE_ItemViewItem, options, painter, options.widget);269 style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, options, painter, options.widget); 268 270 269 271 context = QtGui.QAbstractTextDocumentLayout.PaintContext() 270 textRect = style.subElementRect(Qt Gui.QStyle.SE_ItemViewItemText, options)272 textRect = style.subElementRect(QtWidgets.QStyle.SE_ItemViewItemText, options) 271 273 272 274 painter.save() … … 278 280 else: 279 281 # Just the default paint 280 Qt Gui.QStyledItemDelegate.paint(self, painter, option, index)282 QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
Note: See TracChangeset
for help on using the changeset viewer.