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

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 b3e8629 was b3e8629, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

Initial changes to make SasView? run with python3

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