source: sasview/src/sas/qtgui/KiessigPanel.py @ 8595edd

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 8595edd was 040529d, checked in by trnielsen, 8 years ago

Update SasView?-249 with code review from PR

  • Property mode set to 100644
File size: 2.0 KB
Line 
1from PyQt4 import QtGui
2from PyQt4 import QtCore
3from UI.KiessigPanel import Ui_KiessigPanel
4
5# sas-global
6from sas.sascalc.calculator.kiessig_calculator import KiessigThicknessCalculator
7
8
9class KiessigPanel(QtGui.QDialog, Ui_KiessigPanel):
10    def __init__(self, parent=None):
11        super(KiessigPanel, self).__init__()
12        self.setupUi(self)
13
14        self.setWindowTitle("Kiessig Thickness Calculator")
15
16        self.manager = parent
17        self.thickness = KiessigThicknessCalculator()
18
19        self.deltaq_in.setText("0.05")
20
21        # signals
22        self.helpButton.clicked.connect(self.onHelp)
23        self.computeButton.clicked.connect(self.onCompute)
24        self.closeButton.clicked.connect(self.onClose)
25
26        # no reason to have this widget resizable
27        self.setFixedSize(self.minimumSizeHint())
28
29    def onHelp(self):
30        """
31        Bring up the Kiessig fringe calculator Documentation whenever
32        the HELP button is clicked.
33        Calls DocumentationWindow with the path of the location within the
34        documentation tree (after /doc/ ....".
35        """
36        try:
37            location = self.manager.HELP_DIRECTORY_LOCATION + \
38                "/user/sasgui/perspectives/calculator/kiessig_calculator_help.html"
39
40            self.manager._helpView.load(QtCore.QUrl(location))
41            self.manager._helpView.show()
42        except AttributeError:
43            # No manager defined - testing and standalone runs
44            pass
45
46    def onCompute(self):
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()
53            float_as_str = "{:.3f}".format(kiessing_result)
54            self.lengthscale_out.setText(float_as_str)
55        except (ArithmeticError, ValueError):
56            self.lengthscale_out.setText("")
57
58    def onClose(self):
59        """
60        close the window containing this panel
61        """
62        self.close()
Note: See TracBrowser for help on using the repository browser.