1 | from PyQt4 import QtGui |
---|
2 | from PyQt4 import QtCore |
---|
3 | from UI.KiessigPanel import Ui_KiessigPanel |
---|
4 | |
---|
5 | # sas-global |
---|
6 | from sas.sascalc.calculator.kiessig_calculator import KiessigThicknessCalculator |
---|
7 | |
---|
8 | |
---|
9 | class 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 | # signals |
---|
20 | self.helpButton.clicked.connect(self.on_help) |
---|
21 | self.computeButton.clicked.connect(self.on_compute) |
---|
22 | self.closeButton.clicked.connect(self.on_close) |
---|
23 | |
---|
24 | # no reason to have this widget resizable |
---|
25 | self.setFixedSize(self.minimumSizeHint()) |
---|
26 | |
---|
27 | def on_help(self): |
---|
28 | """ |
---|
29 | Bring up the Kiessig fringe calculator Documentation whenever |
---|
30 | the HELP button is clicked. |
---|
31 | Calls DocumentationWindow with the path of the location within the |
---|
32 | documentation tree (after /doc/ ....". |
---|
33 | """ |
---|
34 | try: |
---|
35 | location = self.manager.HELP_DIRECTORY_LOCATION + \ |
---|
36 | "/user/sasgui/perspectives/calculator/kiessig_calculator_help.html" |
---|
37 | |
---|
38 | self.manager._helpView.load(QtCore.QUrl(location)) |
---|
39 | self.manager._helpView.show() |
---|
40 | except AttributeError: |
---|
41 | # No manager defined - testing and standalone runs |
---|
42 | pass |
---|
43 | |
---|
44 | def on_compute(self): |
---|
45 | """ |
---|
46 | Execute the computation of thickness |
---|
47 | """ |
---|
48 | try: |
---|
49 | self.thickness.set_deltaq(dq=float(self.deltaq_in.text())) |
---|
50 | kiessing_result = self.thickness.compute_thickness() |
---|
51 | float_as_str = "{:5.4f}".format(kiessing_result) |
---|
52 | self.lengthscale_out.setText(float_as_str) |
---|
53 | except (ArithmeticError, ValueError): |
---|
54 | self.lengthscale_out.setText("") |
---|
55 | |
---|
56 | def on_close(self): |
---|
57 | """ |
---|
58 | close the window containing this panel |
---|
59 | """ |
---|
60 | self.close() |
---|