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

ESS_GUIESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_opencl
Last change on this file since 12dfce6 was 33c0561, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 6 years ago

Replace Apply button menu driven functionality with additional button.
Removed Cancel.
Removed the window system context help button from all affected widgets.
SASVIEW-1239

  • Property mode set to 100644
File size: 2.4 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)
[33c0561]17        # disable the context help icon
18        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
[363fbfa]19
20        self.setWindowTitle("Kiessig Thickness Calculator")
21
22        self.manager = parent
23        self.thickness = KiessigThicknessCalculator()
24
[3e314e6]25        rx = QtCore.QRegExp("[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?")
26        self.deltaq_in.setValidator(QtGui.QRegExpValidator(rx, self.deltaq_in))
[040529d]27
[363fbfa]28        # signals
[040529d]29        self.helpButton.clicked.connect(self.onHelp)
[3e314e6]30        self.computeButton.setVisible(False)
[040529d]31        self.closeButton.clicked.connect(self.onClose)
[3e314e6]32        self.deltaq_in.textChanged.connect(self.onCompute)
33        self.deltaq_in.setText("0.05")
[363fbfa]34
[ccdee50]35        # Set focus away from Close
36        self.computeButton.setFocus()
37
[363fbfa]38        # no reason to have this widget resizable
39        self.setFixedSize(self.minimumSizeHint())
40
[040529d]41    def onHelp(self):
[363fbfa]42        """
43        Bring up the Kiessig fringe calculator Documentation whenever
44        the HELP button is clicked.
45        Calls DocumentationWindow with the path of the location within the
46        documentation tree (after /doc/ ....".
47        """
[aed0532]48        location = "/user/qtgui/Calculators/kiessig_calculator_help.html"
[e90988c]49        self.manager.showHelp(location)
[363fbfa]50
[040529d]51    def onCompute(self):
[363fbfa]52        """
53        Execute the computation of thickness
54        """
55        try:
56            self.thickness.set_deltaq(dq=float(self.deltaq_in.text()))
57            kiessing_result = self.thickness.compute_thickness()
[fbfc488]58            if kiessing_result:
59                float_as_str = "{:.3f}".format(kiessing_result)
60                self.lengthscale_out.setText(float_as_str)
61            else:
62                # error or division by zero
63                self.lengthscale_out.setText("")
64
[363fbfa]65        except (ArithmeticError, ValueError):
66            self.lengthscale_out.setText("")
67
[040529d]68    def onClose(self):
[363fbfa]69        """
70        close the window containing this panel
71        """
72        self.close()
Note: See TracBrowser for help on using the repository browser.