source: sasview/src/sas/qtgui/Plotting/BoxSum.py @ 033b1f2

Last change on this file since 033b1f2 was 5eebcd6, checked in by Piotr Rozyczko <piotr.rozyczko@…>, 6 years ago

Close subWindow properly. SASVIEW-1115

  • Property mode set to 100644
File size: 1.8 KB
Line 
1"""
2Allows users to modify the box slicer parameters.
3"""
4from PyQt5 import QtCore
5from PyQt5 import QtGui
6from PyQt5 import QtWidgets
7
8import sas.qtgui.Utilities.GuiUtils as GuiUtils
9
10# Local UI
11from sas.qtgui.UI import main_resources_rc
12from sas.qtgui.Plotting.UI.BoxSumUI import Ui_BoxSumUI
13
14class BoxSum(QtWidgets.QDialog, Ui_BoxSumUI):
15    closeWidgetSignal = QtCore.pyqtSignal()
16    def __init__(self, parent=None, model=None):
17        super(BoxSum, self).__init__()
18
19        self.setupUi(self)
20        assert isinstance(model, QtGui.QStandardItemModel)
21
22        self.txtBoxHeight.setValidator(GuiUtils.DoubleValidator())
23        self.txtBoxWidth.setValidator(GuiUtils.DoubleValidator())
24        self.txtCenterX.setValidator(GuiUtils.DoubleValidator())
25        self.txtCenterY.setValidator(GuiUtils.DoubleValidator())
26
27        self.model = model
28        self.mapper = QtWidgets.QDataWidgetMapper()
29        self.mapper.setModel(self.model)
30
31        # Map model items onto widget controls
32        self.mapper.addMapping(self.txtBoxHeight, 0)
33        self.mapper.addMapping(self.txtBoxWidth, 1)
34        self.mapper.addMapping(self.txtCenterX, 2)
35        self.mapper.addMapping(self.txtCenterY, 3)
36        self.mapper.addMapping(self.lblAvg, 4, b"text")
37        self.mapper.addMapping(self.lblAvgErr, 5, b"text")
38        self.mapper.addMapping(self.lblSum, 6, b"text")
39        self.mapper.addMapping(self.lblSumErr, 7, b"text")
40        self.mapper.addMapping(self.lblNumPoints, 8, b"text")
41
42        # Populate the widgets with data from the first column
43        self.mapper.toFirst()
44
45        self.setFixedSize(self.minimumSizeHint())
46
47        # Handle the Close button click
48        self.buttonBox.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(lambda:self.closeWidgetSignal.emit())
49
Note: See TracBrowser for help on using the repository browser.