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

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 00b3b40 was cd2cc745, checked in by Piotr Rozyczko <rozyczko@…>, 8 years ago

Workaround for the resource file requirement in each UI directory

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