def __init__(self, parent): super(NXPlainTextEdit, self).__init__() self.setFont(QtGui.QFont('Courier')) self.setMinimumWidth(700) self.setMinimumHeight(600) self.setWordWrapMode(QtGui.QTextOption.NoWrap) self.parent = parent self.blockCountChanged.connect(self.parent.update_line_numbers)
def __init__(self, parent=None): super(TransformDialog, self).__init__(parent) self.select_entry(self.initialize_grid) self.refine = NXRefine() grid = QtWidgets.QGridLayout() grid.setSpacing(10) header_font = QtGui.QFont() header_font.setBold(True) start_label = QtWidgets.QLabel('Start') start_label.setFont(header_font) grid.addWidget(start_label, 0, 1) step_label = QtWidgets.QLabel('Step') step_label.setFont(header_font) grid.addWidget(step_label, 0, 2) stop_label = QtWidgets.QLabel('Stop') stop_label.setFont(header_font) grid.addWidget(stop_label, 0, 3) grid.addWidget(QtWidgets.QLabel('H:'), 1, 0) grid.addWidget(QtWidgets.QLabel('K:'), 2, 0) grid.addWidget(QtWidgets.QLabel('L:'), 3, 0) self.start_h_box = QtWidgets.QLineEdit() self.step_h_box = QtWidgets.QLineEdit() self.stop_h_box = QtWidgets.QLineEdit() grid.addWidget(self.start_h_box, 1, 1) grid.addWidget(self.step_h_box, 1, 2) grid.addWidget(self.stop_h_box, 1, 3) self.start_k_box = QtWidgets.QLineEdit() self.step_k_box = QtWidgets.QLineEdit() self.stop_k_box = QtWidgets.QLineEdit() grid.addWidget(self.start_k_box, 2, 1) grid.addWidget(self.step_k_box, 2, 2) grid.addWidget(self.stop_k_box, 2, 3) self.start_l_box = QtWidgets.QLineEdit() self.step_l_box = QtWidgets.QLineEdit() self.stop_l_box = QtWidgets.QLineEdit() grid.addWidget(self.start_l_box, 3, 1) grid.addWidget(self.step_l_box, 3, 2) grid.addWidget(self.stop_l_box, 3, 3) self.set_layout( self.entry_layout, grid, self.checkboxes( ('copy', 'Copy to all entries', True), ('mask', 'Create masked transform group', True), ('overwrite', 'Overwrite existing transforms', False)), self.close_buttons(save=True)) self.setWindowTitle('Transforming Data') try: self.initialize_grid() except Exception: pass
def __init__(self, file_name=None, parent=None): from nexpy.gui.consoleapp import _mainwindow self.window = _mainwindow.editors QtGui.QWidget.__init__(self, parent=self.window.tabs) self.file_name = file_name from consoleapp import _nexpy_dir self.default_directory = os.path.join(_nexpy_dir, 'scripts') layout = QtGui.QVBoxLayout() self.text_layout = QtGui.QHBoxLayout() self.number_box = QtGui.QLabel('1') self.number_box.setFont(QtGui.QFont('Courier')) self.number_box.setAlignment(QtCore.Qt.AlignTop | QtCore.Qt.AlignRight) self.number_box.setStyleSheet("QLabel {padding: 1px 0}") self.text_box = NXPlainTextEdit(self) self.text_layout.addWidget(self.number_box) self.text_layout.addWidget(self.text_box) layout.addLayout(self.text_layout) run_button = QtGui.QPushButton('Run Script') run_button.clicked.connect(self.run_script) run_button.setAutoDefault(False) self.argument_box = QtGui.QLineEdit() self.argument_box.setMinimumWidth(200) save_button = QtGui.QPushButton('Save') save_button.clicked.connect(self.save_script) save_as_button = QtGui.QPushButton('Save as...') save_as_button.clicked.connect(self.save_script_as) self.delete_button = QtGui.QPushButton('Delete') self.delete_button.clicked.connect(self.delete_script) close_button = QtGui.QPushButton('Close Tab') close_button.clicked.connect(self.close) button_layout = QtGui.QHBoxLayout() button_layout.addWidget(run_button) button_layout.addWidget(self.argument_box) button_layout.addStretch() button_layout.addWidget(save_button) button_layout.addWidget(save_as_button) button_layout.addWidget(self.delete_button) button_layout.addWidget(close_button) layout.addLayout(button_layout) self.setLayout(layout) if self.file_name: with open(self.file_name, 'r') as f: text = f.read() self.text_box.setPlainText(text) self.window.tabs.addTab(self, os.path.basename(self.file_name)) self.update_line_numbers(self.text_box.count) else: self.delete_button.setVisible(False) self.window.tabs.addTab(self, 'Untitled %s' % (self.window.tabs.count()+1)) self.index = self.window.tabs.indexOf(self) self.window.tabs.adjustSize() self.window.tabs.setCurrentWidget(self) self.hl = Highlighter(self.text_box.document())
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)