Changeset e4676c8 in sasview for src/sas/qtgui/GuiUtils.py


Ignore:
Timestamp:
Nov 3, 2016 6:07:10 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:
ca8b853
Parents:
f140169
Message:

Added SLDCalculator unit tests. Refactored things a bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/GuiUtils.py

    • Property mode changed from 100755 to 100644
    r39551a68 re4676c8  
    2525#from sas.sasgui.guiframe.events import StatusEvent 
    2626#from sas.sasgui.guiframe.events import NewPlotEvent 
     27 
     28from periodictable import formula as Formula 
    2729 
    2830from sas.sasgui.guiframe.dataFitting import Data1D 
     
    535537    if os.path.splitext(filename)[1].lower() == ext_format: 
    536538        loader.save(filename, data, ext_format) 
     539 
     540class FormulaValidator(QtGui.QValidator): 
     541    def __init__(self, parent=None): 
     542        super(FormulaValidator, self).__init__(parent) 
     543   
     544    def validate(self, input, pos): 
     545        try: 
     546            Formula(str(input)) 
     547            self._setStyleSheet("") 
     548            return QtGui.QValidator.Acceptable, pos 
     549 
     550        except Exception as e: 
     551            self._setStyleSheet("background-color:pink;") 
     552            return QtGui.QValidator.Intermediate, pos 
     553 
     554    def _setStyleSheet(self, value): 
     555        try: 
     556            if self.parent(): 
     557                self.parent().setStyleSheet(value) 
     558        except: 
     559            pass 
Note: See TracChangeset for help on using the changeset viewer.