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


Ignore:
Timestamp:
Nov 3, 2016 6:07:10 AM (8 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/DensityPanel.py

    rf140169 re4676c8  
    22import logging 
    33import functools 
     4from PyQt4 import QtGui, QtCore 
    45 
    56from periodictable import formula as Formula 
    67 
    7 from PyQt4 import QtGui, QtCore 
     8from GuiUtils import FormulaValidator 
    89 
    910# Local UI 
     
    3435    except: 
    3536        return "" 
    36  
    37  
    38 class FormulaValidator(QtGui.QValidator): 
    39     def __init__(self, parent=None): 
    40         super(FormulaValidator, self).__init__(parent) 
    41    
    42     def validate(self, input, pos): 
    43         try: 
    44             Formula(str(input)) 
    45             self._setStyleSheet("") 
    46             return QtGui.QValidator.Acceptable, pos 
    47  
    48         except Exception as e: 
    49             self._setStyleSheet("background-color:pink;") 
    50             return QtGui.QValidator.Intermediate, pos 
    51  
    52     def _setStyleSheet(self, value): 
    53         try: 
    54             if self.parent(): 
    55                 self.parent().setStyleSheet(value) 
    56         except: 
    57             pass 
    5837 
    5938 
Note: See TracChangeset for help on using the changeset viewer.