source: sasview/src/sas/qtgui/Plotting/ScaleProperties.py @ 33c0561

ESS_GUIESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_openclESS_GUI_sync_sascalc
Last change on this file since 33c0561 was 33c0561, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 5 years ago

Replace Apply button menu driven functionality with additional button.
Removed Cancel.
Removed the window system context help button from all affected widgets.
SASVIEW-1239

  • Property mode set to 100644
File size: 3.0 KB
Line 
1from PyQt5 import QtCore
2from PyQt5 import QtGui
3from PyQt5 import QtWidgets
4
5import sas.sasview
6from sas.qtgui.UI import main_resources_rc
7
8from sas.qtgui.UI import main_resources_rc
9from sas.qtgui.Plotting.UI.ScalePropertiesUI import Ui_scalePropertiesUI
10
11x_values = ["x", "x^(2)", "x^(4)", "ln(x)", "log10(x)", "log10(x^(4))"]
12y_values = ["y", "1/y", "ln(y)", "y^(2)", "y*x^(2)", "y*x^(4)", "1/sqrt(y)",
13            "log10(y)", "ln(y*x)", "ln(y*x^(2))", "ln(y*x^(4))", "log10(y*x^(4))"]
14view_values = ["--", "Linear y vs x", "log(y) vs log(x)", "Guinier lny vs x^(2)",
15            "XS Guinier ln(y*x) vs x^(2)", "Porod y*x^(4) vs x^(4)", "Kratky y*x^(2) vs x"]
16view_to_xy = {
17    view_values[0]: [None, None], # custom
18    view_values[1]: [0, 0], # linear
19    view_values[2]: [4, 7], # log
20    view_values[3]: [1, 2], # Guinier
21    view_values[4]: [1, 8], # XS Guinier
22    view_values[5]: [2, 5], # Porod
23    view_values[6]: [0, 4], # Kratky
24}
25class ScaleProperties(QtWidgets.QDialog, Ui_scalePropertiesUI):
26    def __init__(self, parent=None, init_scale_x='x', init_scale_y='y'):
27        super(ScaleProperties, self).__init__(parent)
28        self.setupUi(self)
29        # disable the context help icon
30        self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
31
32        # Set up comboboxes
33        self.cbX.addItems(x_values)
34        self.cbY.addItems(y_values)
35        self.cbView.addItems(view_values)
36        # Resize the dialog only AFTER the boxes are populated
37        self.setFixedSize(self.minimumSizeHint())
38
39        # Set up the initial values for x and y.
40        # This avoids keeping a QModel instance here.
41        if init_scale_x in x_values and init_scale_y in y_values:
42            self.cbX.setCurrentIndex(x_values.index(init_scale_x))
43            self.cbY.setCurrentIndex(y_values.index(init_scale_y))
44
45        # Connect combobox index change to a custom method
46        self.cbView.currentIndexChanged.connect(self.viewIndexChanged)
47        self.cbX.currentIndexChanged.connect(self.xyIndexChanged)
48        self.cbY.currentIndexChanged.connect(self.xyIndexChanged)
49
50    def getValues(self):
51        """
52        Return current values from comboboxes
53        """
54        return str(self.cbX.currentText()), str(self.cbY.currentText())
55
56    def viewIndexChanged(self, index):
57        """
58        Update X and Y labels based on the "View" index
59        """
60        if index > 0:
61            # Disable signals so xyIndexChanged() doesn't get called
62            self.cbX.blockSignals(True)
63            self.cbY.blockSignals(True)
64
65            # Update the sub-controls
66            self.cbX.setCurrentIndex(view_to_xy[view_values[index]][0])
67            self.cbY.setCurrentIndex(view_to_xy[view_values[index]][1])
68            # Re-enable the signals
69
70            self.cbX.blockSignals(False)
71            self.cbY.blockSignals(False)
72
73    def xyIndexChanged(self, index):
74        """
75        Update View label based on the "X" and "Y" index
76        """
77        self.cbView.setCurrentIndex(0)
Note: See TracBrowser for help on using the repository browser.