Ignore:
Timestamp:
Jun 16, 2017 4:22:23 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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:
85487ebd
Parents:
b0c5e8c
Message:

Code review changes SASVIEW-597

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/FittingOptions.py

    rb0c5e8c r72f4834  
    1919# Set the default optimizer 
    2020fitters.FIT_DEFAULT_ID = 'lm' 
     21 
    2122 
    2223class FittingOptions(QtGui.QDialog, Ui_FittingOptions): 
     
    6667        self.assignValidators() 
    6768 
     69        # Set defaults 
    6870        self.current_fitter_id = fitters.FIT_DEFAULT_ID 
     71 
     72        # OK has to be initialized to True, after initial validator setup 
     73        self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) 
    6974 
    7075        # Display HTML content 
     
    8085            if type(f_type) == types.FunctionType: 
    8186                validator = QtGui.QIntValidator() 
     87                validator.setBottom(0) 
    8288            elif f_type == types.FloatType: 
    8389                validator = QtGui.QDoubleValidator() 
     90                validator.setBottom(0) 
    8491            else: 
    8592                continue 
     
    8895                if hasattr(line_edit, 'setValidator') and validator is not None: 
    8996                    line_edit.setValidator(validator) 
     97                    line_edit.textChanged.connect(self.check_state) 
     98                    line_edit.textChanged.emit(line_edit.text()) 
     99 
     100    def check_state(self, *args, **kwargs): 
     101        sender = self.sender() 
     102        validator = sender.validator() 
     103        state = validator.validate(sender.text(), 0)[0] 
     104        if state == QtGui.QValidator.Acceptable: 
     105            color = '' # default 
     106            self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) 
     107        else: 
     108            color = '#fff79a' # yellow 
     109            self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(False) 
     110 
     111        sender.setStyleSheet('QLineEdit { background-color: %s }' % color) 
    90112 
    91113    def onAlgorithmChange(self, index): 
Note: See TracChangeset for help on using the changeset viewer.