1 | from PyQt4 import QtGui |
---|
2 | from PyQt4 import QtCore |
---|
3 | |
---|
4 | from sas.qtgui.UI import main_resources_rc |
---|
5 | from UI.KiessigPanel import Ui_KiessigPanel |
---|
6 | |
---|
7 | # sas-global |
---|
8 | from sas.sascalc.calculator.kiessig_calculator import KiessigThicknessCalculator |
---|
9 | |
---|
10 | |
---|
11 | class 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() |
---|