def add_parameter_rows(self, f):
     row = self.parameter_grid.rowCount()
     name = self.expanded_name(f.name)
     f.rows = []
     f.label_box = QtGui.QLabel(name)
     self.parameter_grid.addWidget(f.label_box, row, 0)
     for p in f.parameters:
         p.parameter_index = row
         p.parameter_box = QtGui.QLabel(str(p.parameter_index))
         p.value_box = QtGui.QLineEdit()
         p.value_box.setAlignment(QtCore.Qt.AlignRight)
         p.error_box = QtGui.QLabel()
         p.min_box = QtGui.QLineEdit('-inf')
         p.min_box.setAlignment(QtCore.Qt.AlignRight)
         p.max_box = QtGui.QLineEdit('inf')
         p.max_box.setAlignment(QtCore.Qt.AlignRight)
         p.fixed_box = QtGui.QCheckBox()
         #            p.bound_box = QtGui.QLineEdit()
         self.parameter_grid.addWidget(p.parameter_box,
                                       row,
                                       1,
                                       alignment=QtCore.Qt.AlignHCenter)
         self.parameter_grid.addWidget(QtGui.QLabel(p.name), row, 2)
         self.parameter_grid.addWidget(p.value_box, row, 3)
         self.parameter_grid.addWidget(p.error_box, row, 4)
         self.parameter_grid.addWidget(p.min_box, row, 5)
         self.parameter_grid.addWidget(p.max_box, row, 6)
         self.parameter_grid.addWidget(p.fixed_box,
                                       row,
                                       7,
                                       alignment=QtCore.Qt.AlignHCenter)
         #            self.parameter_grid.addWidget(p.bound_box, row, 8)
         f.rows.append(row)
         row += 1
     self.parameter_grid.setRowStretch(self.parameter_grid.rowCount(), 10)
    def __init__(self, parent=None):

        super(ImportDialog, self).__init__(parent)

        self.file_type = None

        layout = QtGui.QVBoxLayout()
        layout.addLayout(self.filebox())

        title_layout = QtGui.QHBoxLayout()
        title_label = QtGui.QLabel('Title')
        self.title_box = QtGui.QLineEdit()
        title_layout.addWidget(title_label)
        title_layout.addWidget(self.title_box)
        layout.addLayout(title_layout)

        energy_layout = QtGui.QHBoxLayout()
        energy_label = QtGui.QLabel('Incident Energy')
        self.energy_box = QtGui.QLineEdit()
        self.energy_box.setFixedWidth(150)
        energy_layout.addWidget(energy_label)
        energy_layout.addWidget(self.energy_box)
        energy_layout.addStretch()
        layout.addLayout(energy_layout)

        step_layout = QtGui.QHBoxLayout()
        Q_label = QtGui.QLabel('dQ')
        self.Q_box = QtGui.QLineEdit()
        self.Q_box.setFixedWidth(75)
        E_label = QtGui.QLabel('dE')
        self.E_box = QtGui.QLineEdit()
        self.E_box.setFixedWidth(75)
        self.convert_box = QtGui.QCheckBox('Convert to S(Q,E)')
        self.convert_box.setChecked(False)
        step_layout.addWidget(self.convert_box)
        step_layout.addStretch()
        step_layout.addWidget(Q_label)
        step_layout.addWidget(self.Q_box)
        step_layout.addWidget(E_label)
        step_layout.addWidget(self.E_box)
        step_layout.addStretch()
        layout.addLayout(step_layout)

        layout.addWidget(self.close_buttons())

        self.setLayout(layout)

        self.setWindowTitle("Import " + str(filetype))
    def __init__(self, entry, parent=None):

        super(FitDialog, self).__init__(parent)
        self.setMinimumWidth(850)

        self.data = self.initialize_data(entry.data)

        from nexpy.gui.consoleapp import _tree
        self.tree = _tree

        from nexpy.gui.plotview import plotview
        self.plotview = plotview
        self.functions = []
        self.parameters = []

        self.first_time = True
        self.fitted = False
        self.fit = None

        self.initialize_functions()

        function_layout = QtGui.QHBoxLayout()
        self.functioncombo = QtGui.QComboBox()
        for name in sorted(self.function_module.keys()):
            self.functioncombo.addItem(name)
        self.functioncombo.setSizeAdjustPolicy(
            QtGui.QComboBox.AdjustToContents)
        self.functioncombo.setMinimumWidth(100)
        add_button = QtGui.QPushButton("Add Function")
        add_button.clicked.connect(self.add_function)
        function_layout.addWidget(self.functioncombo)
        function_layout.addWidget(add_button)
        function_layout.addStretch()

        self.header_font = QtGui.QFont()
        self.header_font.setBold(True)

        self.parameter_layout = self.initialize_parameter_grid()

        self.remove_layout = QtGui.QHBoxLayout()
        remove_button = QtGui.QPushButton("Remove Function")
        remove_button.clicked.connect(self.remove_function)
        self.removecombo = QtGui.QComboBox()
        self.removecombo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
        self.removecombo.setMinimumWidth(100)
        self.remove_layout.addWidget(remove_button)
        self.remove_layout.addWidget(self.removecombo)
        self.remove_layout.addStretch()

        self.plot_layout = QtGui.QHBoxLayout()
        plot_data_button = QtGui.QPushButton('Plot Data')
        plot_data_button.clicked.connect(self.plot_data)
        plot_function_button = QtGui.QPushButton('Plot Function')
        plot_function_button.clicked.connect(self.plot_model)
        self.plotcombo = QtGui.QComboBox()
        self.plotcombo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
        self.plotcombo.setMinimumWidth(100)
        plot_label = QtGui.QLabel('X-axis:')
        self.plot_minbox = QtGui.QLineEdit(str(self.plotview.xtab.axis.min))
        self.plot_minbox.setAlignment(QtCore.Qt.AlignRight)
        plot_tolabel = QtGui.QLabel(' to ')
        self.plot_maxbox = QtGui.QLineEdit(str(self.plotview.xtab.axis.max))
        self.plot_maxbox.setAlignment(QtCore.Qt.AlignRight)
        self.plot_checkbox = QtGui.QCheckBox('Use Data Points')
        self.plot_layout.addWidget(plot_data_button)
        self.plot_layout.addWidget(plot_function_button)
        self.plot_layout.addWidget(self.plotcombo)
        self.plot_layout.addWidget(plot_label)
        self.plot_layout.addWidget(self.plot_minbox)
        self.plot_layout.addWidget(plot_tolabel)
        self.plot_layout.addWidget(self.plot_maxbox)
        self.plot_layout.addWidget(self.plot_checkbox)
        self.plot_layout.addStretch()

        self.action_layout = QtGui.QHBoxLayout()
        fit_button = QtGui.QPushButton("Fit")
        fit_button.clicked.connect(self.fit_data)
        self.fit_label = QtGui.QLabel()
        if self.data.nxerrors:
            self.fit_checkbox = QtGui.QCheckBox('Use Errors')
            self.fit_checkbox.setCheckState(QtCore.Qt.Checked)
        else:
            self.fit_checkbox = QtGui.QCheckBox('Use Poisson Errors')
            self.fit_checkbox.setCheckState(QtCore.Qt.Unchecked)
            self.fit_checkbox.stateChanged.connect(self.define_errors)
        self.report_button = QtGui.QPushButton("Show Fit Report")
        self.report_button.clicked.connect(self.report_fit)
        self.save_button = QtGui.QPushButton("Save Parameters")
        self.save_button.clicked.connect(self.save_fit)
        self.restore_button = QtGui.QPushButton("Restore Parameters")
        self.restore_button.clicked.connect(self.restore_parameters)
        self.action_layout.addWidget(fit_button)
        self.action_layout.addWidget(self.fit_label)
        self.action_layout.addStretch()
        self.action_layout.addWidget(self.fit_checkbox)
        self.action_layout.addWidget(self.save_button)

        self.layout = QtGui.QVBoxLayout()
        self.layout.addLayout(function_layout)
        self.layout.addWidget(self.close_buttons())

        self.setLayout(self.layout)

        self.setWindowTitle("Fit NeXus Data")

        self.load_entry(entry)