source: sasview/src/sas/qtgui/Calculators/KiessigPanel.py @ d72ac57

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since d72ac57 was 3e314e6, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 6 years ago

Minor fixes to the Kiessig calculator. SASVIEW-1161

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[4992ff2]1from PyQt5 import QtCore
2from PyQt5 import QtGui
3from PyQt5 import QtWidgets
[cd2cc745]4
5from sas.qtgui.UI import main_resources_rc
[b3e8629]6from .UI.KiessigPanel import Ui_KiessigPanel
[b0c5e8c]7import sas.qtgui.Utilities.GuiUtils as GuiUtils
[363fbfa]8
9# sas-global
10from sas.sascalc.calculator.kiessig_calculator import KiessigThicknessCalculator
11
12
[4992ff2]13class KiessigPanel(QtWidgets.QDialog, Ui_KiessigPanel):
[363fbfa]14    def __init__(self, parent=None):
15        super(KiessigPanel, self).__init__()
16        self.setupUi(self)
17
18        self.setWindowTitle("Kiessig Thickness Calculator")
19
20        self.manager = parent
21        self.thickness = KiessigThicknessCalculator()
22
[3e314e6]23        rx = QtCore.QRegExp("[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?")
24        self.deltaq_in.setValidator(QtGui.QRegExpValidator(rx, self.deltaq_in))
[040529d]25
[363fbfa]26        # signals
[040529d]27        self.helpButton.clicked.connect(self.onHelp)
[3e314e6]28        self.computeButton.setVisible(False)
[040529d]29        self.closeButton.clicked.connect(self.onClose)
[3e314e6]30        self.deltaq_in.textChanged.connect(self.onCompute)
31        self.deltaq_in.setText("0.05")
[363fbfa]32
33        # no reason to have this widget resizable
34        self.setFixedSize(self.minimumSizeHint())
35
[040529d]36    def onHelp(self):
[363fbfa]37        """
38        Bring up the Kiessig fringe calculator Documentation whenever
39        the HELP button is clicked.
40        Calls DocumentationWindow with the path of the location within the
41        documentation tree (after /doc/ ....".
42        """
[aed0532]43        location = "/user/qtgui/Calculators/kiessig_calculator_help.html"
[e90988c]44        self.manager.showHelp(location)
[363fbfa]45
[040529d]46    def onCompute(self):
[363fbfa]47        """
48        Execute the computation of thickness
49        """
50        try:
51            self.thickness.set_deltaq(dq=float(self.deltaq_in.text()))
52            kiessing_result = self.thickness.compute_thickness()
[fbfc488]53            if kiessing_result:
54                float_as_str = "{:.3f}".format(kiessing_result)
55                self.lengthscale_out.setText(float_as_str)
56            else:
57                # error or division by zero
58                self.lengthscale_out.setText("")
59
[363fbfa]60        except (ArithmeticError, ValueError):
61            self.lengthscale_out.setText("")
62
[040529d]63    def onClose(self):
[363fbfa]64        """
65        close the window containing this panel
66        """
67        self.close()
Note: See TracBrowser for help on using the repository browser.