def __init__(self, fig_params): super().__init__(fig_params) self.export_PDF_btn = FlatButton() self.export_PDF_btn.setToolTip('Export d(r)') button_height = 32 button_width = 32 icon_size = QtCore.QSize(22, 22) self.export_PDF_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'export.ico'))) self.export_PDF_btn.setIconSize(icon_size) self.export_PDF_btn.setMinimumHeight(button_height) self.export_PDF_btn.setMaximumHeight(button_height) self.export_PDF_btn.setMinimumWidth(button_width) self.export_PDF_btn.setMaximumWidth(button_width) self.add_top_button_widget_item(self.export_PDF_btn) self.pdf_type_widget = QtWidgets.QWidget() self._pdf_type_widget_layout = QtWidgets.QHBoxLayout() self.dr_cb = QtWidgets.QRadioButton("d(r)") self.dr_cb.setChecked(True) self.tr_cb = QtWidgets.QRadioButton("t(r)") self.gr_cb = QtWidgets.QRadioButton("g(r)") self.Gr_cb = QtWidgets.QRadioButton("G(r)") self._pdf_type_widget_layout.addWidget(self.dr_cb) self._pdf_type_widget_layout.addWidget(self.tr_cb) self._pdf_type_widget_layout.addWidget(self.gr_cb) self._pdf_type_widget_layout.addWidget(self.Gr_cb) self.pdf_type_widget.setLayout(self._pdf_type_widget_layout) self.add_top_button_widget_item(self.pdf_type_widget) self.add_top_button_widget_spacer()
def __init__(self, fig_params): super().__init__(fig_params) button_height = 32 button_width = 32 icon_size = QtCore.QSize(22, 22) self.cut_peak_btn = FlatButton() self.cut_peak_btn.setCheckable(True) self.apply_btn = FlatButton("Apply") self.apply_btn.setMinimumWidth(90) self.cut_peak_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'remove.ico'))) self.cut_peak_btn.setIconSize(icon_size) self.cut_peak_btn.setMinimumHeight(button_height) self.cut_peak_btn.setMaximumHeight(button_height) self.cut_peak_btn.setMinimumWidth(button_width) self.cut_peak_btn.setMaximumWidth(button_width) self.add_button_widget_item(QtWidgets.QLabel('Remove peak')) self.add_button_widget_item(self.cut_peak_btn) self.add_button_widget_spacer() self.add_button_widget_item(self.apply_btn)
def __init__(self): super().__init__() self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle('ROIs control') self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('rois_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(6) #self.add_btn = FlatButton('Add') #self.edit_btn = FlatButton('Edit') self.delete_btn = FlatButton('Delete') self.clear_btn = FlatButton('Clear') self.show_fit_btn = FlatButton('Show fit') self.pressure_btn = FlatButton('Pressure') self.save_peaks_btn = FlatButton('Save List') #self._button_layout.addWidget(self.add_btn) #self._button_layout.addWidget(self.edit_btn) self._button_layout.addWidget(self.delete_btn) self._button_layout.addWidget(self.clear_btn) self._button_layout.addWidget(self.show_fit_btn) #self._button_layout.addWidget(self.pressure_btn) self._button_layout.addWidget(self.save_peaks_btn) self.button_widget.setLayout(self._button_layout) self._layout.addWidget(self.button_widget) self._body_layout = QtWidgets.QHBoxLayout() self.roi_tw = ListTableWidget(columns=5) self._body_layout.addWidget(self.roi_tw, 10) self._layout.addLayout(self._body_layout) self.setLayout(self._layout) self.style_widgets() self.roi_show_cbs = [] self.name_items = [] self.index_items = [] #self.roi_color_btns = [] self.show_parameter_in_pattern = True header_view = QtWidgets.QHeaderView(QtCore.Qt.Horizontal, self.roi_tw) self.roi_tw.setHorizontalHeader(header_view) header_view.setResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) header_view.setResizeMode(1, QtWidgets.QHeaderView.Stretch) header_view.setResizeMode(2, QtWidgets.QHeaderView.Stretch) header_view.setResizeMode(3, QtWidgets.QHeaderView.Stretch) self.default_header = ['#', 'Name', 'Centroid', 'Counts', 'fwhm'] self.header = copy.deepcopy(self.default_header) self.roi_tw.setHorizontalHeaderLabels(self.header) #header_view.hide() self.roi_tw.setItemDelegate(NoRectDelegate()) self.roi_tw.itemChanged.connect(self.roi_name_item_changed)
def __init__(self, parent, presets=mcaDisplay_presets(), options=None): """ Creates a new GUI window The preset live time, real time, start channel, end channel and total counts can be controlled. Inputs: """ super(mcaControlPresets, self).__init__(parent) self.original_presets = presets self.ok = [False, presets] if presets is None: self.presets = mcaDisplay_presets() else: self.presets = copy.deepcopy(presets) self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle('Presets') self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint) self.opts = { "real_time": ["Real time:", self.presets.real_time, None], "live_time": ["Live time:", self.presets.live_time, None], "total_counts": ["Total counts:", self.presets.total_counts, None], "start_chan": ["Start channel:", self.presets.start_channel, None], "end_chan": ["End channel:", self.presets.end_channel, None] } for key in self.opts: t = self.add_row_number_field(self, key, self.opts[key][0], self.opts[key][1]) self.opts[key][2] = t[ 1] # remember a reference to "yes" button in option row widget self._layout.addWidget(t[0]) # option row widget self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('file_settings_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(6) self.ok_btn = FlatButton('OK') self.ok_btn.clicked.connect(partial(self.button_press, "OK")) self.cancel_btn = FlatButton('Cancel') self.cancel_btn.clicked.connect(partial(self.button_press, "Cancel")) self._button_layout.addWidget(self.ok_btn) self._button_layout.addWidget(self.cancel_btn) self.button_widget.setLayout(self._button_layout) self._layout.addWidget(self.button_widget) self.setLayout(self._layout) self.setFixedSize(self.sizeHint())
def __init__(self, parent, options=None): super(mcaFilePreferences, self).__init__(parent) self.original_options = options self.ok = [False, options] if options is None: self.options = mcaDisplay_options() else: self.options = copy.deepcopy(options) self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle('File Preferences') self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint) self.opts = { "warn_overwrite": [ "Warning when overwriting file:", self.options.warn_overwrite, None ], "warn_erase": [ "Warning when erasing unsaved data:", self.options.warn_erase, None ], #"inform_save" :["Informational popup after saving file:", self.options.inform_save, None], "autosave": ["Autosave when acquisition stops:", self.options.autosave, None], "autorestart": [ "Auto-restart when acquisition stops:", self.options.autorestart, None ] } for key in self.opts: t = self.add_row(self, key, self.opts[key][0], self.opts[key][1]) self.opts[key][2] = t[ 1] # remember a reference to "yes" button in option row widget self._layout.addWidget(t[0]) # option row widget self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('file_settings_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(6) self.ok_btn = FlatButton('OK') self.ok_btn.clicked.connect(partial(self.button_press, "OK")) self.cancel_btn = FlatButton('Cancel') self.cancel_btn.clicked.connect(partial(self.button_press, "Cancel")) self._button_layout.addWidget(self.ok_btn) self._button_layout.addWidget(self.cancel_btn) self.button_widget.setLayout(self._button_layout) self._layout.addWidget(self.button_widget) self.setLayout(self._layout) self.setFixedSize(self.sizeHint())
def setupUi(self): self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle(self.title) self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('options_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(15) self.apply_btn = FlatButton('Apply') self.apply_btn.clicked.connect(self.apply) self._button_layout.addWidget(self.apply_btn, 0) #self._button_layout.addWidget(VerticalLine()) self._button_layout.addSpacerItem(HorizontalSpacerItem()) #self._button_layout.addWidget(VerticalLine()) self.button_widget.setLayout(self._button_layout) self.parameter_widget = QtWidgets.QWidget() self._parameter_layout = QtWidgets.QGridLayout() self._parameter_layout.addWidget(QtWidgets.QLabel('Color'), 0, 1) self.opt_controls = {} i = 1 for opt in self.opts_fields: self._parameter_layout.addWidget( QtWidgets.QLabel(self.opts_fields[opt]['label']), i, 0) cb = FlatButton() cb.setObjectName(opt + "_control") color = self.opts_fields[opt]['val'] set_btn_color(cb, color) self._parameter_layout.addWidget(cb) self.opt_controls[opt] = {'control': cb} cb.clicked.connect(partial(self.color_btn_clicked, cb)) self._parameter_layout.addItem(HorizontalSpacerItem(), i, 4) i += 1 self._parameter_layout.addItem(VerticalSpacerItem(), i, 0) self.parameter_widget.setLayout(self._parameter_layout) self._body_layout = QtWidgets.QHBoxLayout() self._body_layout.addWidget(self.parameter_widget, 0) self._layout.addLayout(self._body_layout) self._layout.addWidget(HorizontalLine()) self._layout.addWidget(self.button_widget) self.setLayout(self._layout) self.style_widgets()
def __init__(self, fig_params): super().__init__(fig_params) self.export_iSq_btn = FlatButton() self.export_iSq_btn.setToolTip('Export Inverse Fourier-filtered S(q)') button_height = 32 button_width = 32 icon_size = QtCore.QSize(22, 22) self.export_iSq_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'export.ico'))) self.export_iSq_btn.setIconSize(icon_size) self.export_iSq_btn.setMinimumHeight(button_height) self.export_iSq_btn.setMaximumHeight(button_height) self.export_iSq_btn.setMinimumWidth(button_width) self.export_iSq_btn.setMaximumWidth(button_width) self.add_top_button_widget_item(self.export_iSq_btn) self.add_top_button_widget_spacer()
def add_phase(self, name, color): self.phase_tw.blockSignals(True) current_rows = self.phase_tw.rowCount() self.phase_tw.setRowCount(current_rows + 1) show_cb = QtWidgets.QCheckBox() show_cb.setChecked(True) show_cb.stateChanged.connect( partial(self.phase_show_cb_changed, show_cb)) show_cb.setStyleSheet("background-color: transparent") self.phase_tw.setCellWidget(current_rows, 0, show_cb) self.phase_show_cbs.append(show_cb) color_button = FlatButton() color_button.setStyleSheet("background-color: " + color) color_button.clicked.connect( partial(self.phase_color_btn_click, color_button)) self.phase_tw.setCellWidget(current_rows, 1, color_button) self.phase_color_btns.append(color_button) name_item = QtWidgets.QTableWidgetItem(name) name_item.setFlags(name_item.flags() & ~QtCore.Qt.ItemIsEditable) name_item.setTextAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.phase_tw.setItem(current_rows, 2, name_item) pressure_item = QtWidgets.QTableWidgetItem('0 GPa') pressure_item.setFlags(pressure_item.flags() & ~QtCore.Qt.ItemIsEditable) pressure_item.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.phase_tw.setItem(current_rows, 3, pressure_item) temperature_item = QtWidgets.QTableWidgetItem('298 K') temperature_item.setFlags(temperature_item.flags() & ~QtCore.Qt.ItemIsEditable) temperature_item.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.phase_tw.setItem(current_rows, 4, temperature_item) self.phase_tw.setColumnWidth(0, 35) self.phase_tw.setColumnWidth(1, 25) self.phase_tw.setRowHeight(current_rows, 25) self.select_phase(current_rows) self.phase_tw.blockSignals(False)
def _create_widgets(self, opts): """ Creates all necessary widgets. """ self.xray_wavelength_lbl = QtWidgets.QLabel(opts[0]) self.xray_wavelength_txt = QtWidgets.QLineEdit(opts[1]) self.xray_wavelength_txt.setToolTip(opts[2]) self.xray_wavelength_unit_lbl = QtWidgets.QLabel(opts[3]) self.ok_btn = FlatButton("OK")
def __init__(self,color, text ): super().__init__() self.color_button = FlatButton() self.color_button.setStyleSheet("background-color: " + color) self.color_button.setMaximumHeight(18) self.color_button.setMinimumWidth(18) self.color_button.setMaximumWidth(18) self.tthItem = QtWidgets.QLabel(text) self.tthItem.setStyleSheet("background-color: transparent") self._layout = QtWidgets.QHBoxLayout() self._layout.setContentsMargins(1,1,1,1) self._layout.addWidget(self.color_button) self._layout.addWidget(self.tthItem) self._layout.addSpacerItem(HorizontalSpacerItem()) self.setLayout(self._layout) self.setAcceptDrops(True)
def _create_widgets(self, opts): """ Creates all necessary widgets. """ self.detetor_lbl = QtWidgets.QLabel(opts[0]) self.detetor_txt = CleanLooksComboBox() self.detetor_txt.addItems(opts[1]) self.detetor_txt.setToolTip(opts[2]) self.detetor_unit_lbl = QtWidgets.QLabel(opts[3]) self.ok_btn = FlatButton("OK")
def _create_widgets(self): """ Creates all necessary widgets. """ self.int_cutoff_lbl = QtWidgets.QLabel("Intensity Cutoff:") self.min_d_spacing_lbl = QtWidgets.QLabel("Minimum d-spacing:") self.int_cutoff_txt = QtWidgets.QLineEdit("0.5") self.int_cutoff_txt.setToolTip( "Reflections with lower Intensity won't be considered.") self.min_d_spacing_txt = QtWidgets.QLineEdit("0.5") self.min_d_spacing_txt.setToolTip( "Reflections with smaller d_spacing won't be considered.") self.int_cutoff_unit_lbl = QtWidgets.QLabel("%") self.min_d_spacing_unit_lbl = QtWidgets.QLabel("A") self.ok_btn = FlatButton("OK")
def initUi(self): self.resize(793, 574) self.centralwidget = QtWidgets.QWidget(self) self._menu_layout = QtWidgets.QVBoxLayout() self._menu_layout.setContentsMargins(5, 0, 3, 0) self._menu_layout.setSpacing(5) self.save_as_btn = FlatButton() self.save_as_btn.setEnabled(False) self.save_btn = FlatButton() self.save_btn.setEnabled(False) self.load_btn = FlatButton() self.undo_btn = FlatButton() self.reset_btn = FlatButton() self.export_btn = FlatButton() self.angle_btn = FlatButton() self.spectra_btn = FlatButton() self.atoms_btn = FlatButton() self.sq_btn = FlatButton('Sq') self.pdf_btn = FlatButton('Gr') self.peaks_btn = FlatButton() self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 25, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.load_btn) self._menu_layout.addWidget(self.save_btn) self._menu_layout.addWidget(self.save_as_btn) self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 30, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.undo_btn) self._menu_layout.addWidget(self.reset_btn) self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 30, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.angle_btn) self._menu_layout.addWidget(self.spectra_btn) self._menu_layout.addWidget(self.atoms_btn) self._menu_layout.addWidget(self.sq_btn) self._menu_layout.addWidget(self.pdf_btn) self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 30, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.peaks_btn) self._menu_layout.addSpacerItem(VerticalSpacerItem()) self.horizontalLayout = QtWidgets.QHBoxLayout(self.centralwidget) self.horizontalLayout.setSpacing(2) self.horizontalLayout.setContentsMargins(0, 15, 5, 5) self.horizontalLayout.addLayout(self._menu_layout) self.tabWidget = QtWidgets.QTabWidget(self.centralwidget) self.tab_1 = QtWidgets.QWidget() self.vertical_layout_tab_raw = QtWidgets.QVBoxLayout(self.tab_1) self.vertical_layout_tab_raw.setContentsMargins(15, 5, 15, 0) self.tabWidget.addTab(self.tab_1, "") self.tab = QtWidgets.QWidget() self.vertical_layout_tab_spectrum = QtWidgets.QVBoxLayout(self.tab) self.vertical_layout_tab_spectrum.setContentsMargins(15, 5, 15, 10) self.tabWidget.addTab(self.tab, "") self.tab_2 = QtWidgets.QWidget() self.vertical_layout_tab_all_spectra = QtWidgets.QVBoxLayout( self.tab_2) self.vertical_layout_tab_all_spectra.setContentsMargins(15, 10, 15, 0) self.tabWidget.addTab(self.tab_2, "") self.tab_3 = QtWidgets.QWidget() self.vertical_layout_tab_primary_beam = QtWidgets.QVBoxLayout( self.tab_3) self.vertical_layout_tab_primary_beam.setContentsMargins(15, 5, 15, 0) self.tabWidget.addTab(self.tab_3, "") self.tab_4 = QtWidgets.QWidget() self.vertical_layout_tab_sq = QtWidgets.QVBoxLayout(self.tab_4) self.vertical_layout_tab_sq.setContentsMargins(15, 10, 15, 0) self.tabWidget.addTab(self.tab_4, "") self.tab_5 = QtWidgets.QWidget() self.vertical_layout_tab_pdf = QtWidgets.QVBoxLayout(self.tab_5) self.vertical_layout_tab_pdf.setContentsMargins(15, 10, 15, 0) self.tabWidget.addTab(self.tab_5, "") self.tab_6 = QtWidgets.QWidget() self.vertical_layout_tab_inverse = QtWidgets.QVBoxLayout(self.tab_6) self.vertical_layout_tab_inverse.setContentsMargins(15, 10, 15, 0) self.tabWidget.addTab(self.tab_6, "") '''self.tab_7 = QtWidgets.QWidget() self.vertical_layout_tab_rdf = QtWidgets.QVBoxLayout(self.tab_7) self.vertical_layout_tab_rdf.setContentsMargins(15,10,15,0) self.tabWidget.addTab(self.tab_7, "")''' self.horizontalLayout.addWidget(self.tabWidget) self.retranslateUi() self.centralwidget.setLayout(self.horizontalLayout) self.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(self) self.menubar.setGeometry(QtCore.QRect(0, 0, 793, 22)) self.file_menu = self.menubar.addMenu('File') self.file_op_act = QtWidgets.QAction('Open project', self) self.file_menu.addAction(self.file_op_act) self.file_save_act = QtWidgets.QAction('Save project', self) self.file_save_act.setEnabled(False) self.file_menu.addAction(self.file_save_act) self.file_save_as_act = QtWidgets.QAction('Save project as...', self) self.file_save_as_act.setEnabled(False) self.file_menu.addAction(self.file_save_as_act) self.file_save_hdf5_act = QtWidgets.QAction('Save to HDF5', self) #self.file_menu.addAction(self.file_save_hdf5_act) self.file_exp_menu = QtWidgets.QMenu('Export', self) self.file_exp_data_act = QtWidgets.QAction('I(E)', self) self.file_exp_menu.addAction(self.file_exp_data_act) self.file_exp_sf_act = QtWidgets.QAction('S(q)', self) self.file_exp_menu.addAction(self.file_exp_sf_act) self.file_exp_pdf_act = QtWidgets.QAction('G(r)', self) self.file_exp_menu.addAction(self.file_exp_pdf_act) self.file_exp_sf_inv_act = QtWidgets.QAction( 'Inverse Fourier-filtered S(q)', self) self.file_exp_menu.addAction(self.file_exp_sf_inv_act) self.file_menu.addMenu(self.file_exp_menu) self.opts_menu = self.menubar.addMenu('Options') self.tools_files_act = QtWidgets.QAction( f'2\N{GREEK SMALL LETTER THETA} Files Input', self) self.opts_menu.addAction(self.tools_files_act) self.opts_proc_act = QtWidgets.QAction('Spectra', self) self.opts_menu.addAction(self.opts_proc_act) self.tools_atoms_act = QtWidgets.QAction('Atoms', self) self.opts_menu.addAction(self.tools_atoms_act) self.opts_sq_act = QtWidgets.QAction('Scattering factor', self) self.opts_menu.addAction(self.opts_sq_act) self.opts_gr_act = QtWidgets.QAction('PDF', self) self.opts_menu.addAction(self.opts_gr_act) self.tools_menu = self.menubar.addMenu('Tools') self.tools_peaks_act = QtWidgets.QAction('Peak cutting', self) self.tools_menu.addAction(self.tools_peaks_act) self.setMenuBar(self.menubar) sb = self.statusBar() self.progress_bar = QtWidgets.QProgressBar() #self.progress_bar.setFixedHeight(15) #self.pb_widget = QWidget() #self._pb_widget_layout = QtWidgets.QHBoxLayout() #self._pb_widget_layout.addWidget(QtWidgets.QLabel('Progress: ')) #self._pb_widget_layout.addWidget(self.progress_bar) #self._pb_widget_layout.setContentsMargins(10,0,0,3) #self.pb_widget.setLayout(self._pb_widget_layout) #sb.addWidget(self.pb_widget) ''' self.setStyleSheet(""" QTabBar::tab { background: lightgray; color: black; border: 0; min-width: 90px; max-width: 250px; width: 90px; height: 20px; padding: 5px; } QTabBar::tab:selected { background: gray; color: white; } """) ''' self.style_widgets() self.add_tooltips()
class aEDXDRoiWidget(QtWidgets.QWidget): color_btn_clicked = QtCore.pyqtSignal(int, QtWidgets.QWidget) show_cb_state_changed = QtCore.pyqtSignal(dict) name_item_changed = QtCore.pyqtSignal(int, str) widget_closed = QtCore.pyqtSignal() roi_selection_changed_signal = QtCore.pyqtSignal(dict) def __init__(self): super().__init__() self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle('Cut regions control') self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('rois_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(15) #self.add_btn = FlatButton('Add') #self.edit_btn = FlatButton('Edit') self.delete_btn = FlatButton('Delete') self.clear_btn = FlatButton('Clear') #self.show_fit_btn = FlatButton('Show') self.edit_btn = FlatButton('Edit') self.filter_btn = FlatButton(f'Filter 2\N{GREEK SMALL LETTER THETA}') self.filter_btn.setCheckable(True) self.filter_btn.setChecked(True) self._button_layout.addWidget(self.edit_btn) self._button_layout.addWidget(self.delete_btn) self._button_layout.addWidget(self.clear_btn) self._button_layout.addWidget(self.filter_btn) self._button_layout.addSpacerItem(HorizontalSpacerItem()) self.button_widget.setLayout(self._button_layout) self._layout.addWidget(self.button_widget) self._body_layout = QtWidgets.QHBoxLayout() self.roi_tw = ListTableWidget(columns=3) self._body_layout.addWidget(self.roi_tw, 10) #### Start peak parameters widget self.baseline_params = QtWidgets.QWidget() self.baseline_params_layout = QtWidgets.QGridLayout() self.baseline_params_V_layout = QtWidgets.QVBoxLayout() self.cut_peak_Wn = DoubleSpinBoxAlignRight() self.cut_peak_Wn.setMinimumWidth(90) self.cut_peak_Wn.setMinimum(0.001) self.cut_peak_Wn.setMaximum(1) self.cut_peak_Wn.setValue(0.2) self.cut_peak_Wn.setDecimals(3) #self.cut_peak_Wn.setSingleStep(0.1) self.cut_peak_iter = DoubleSpinBoxAlignRight() self.cut_peak_iter.setMinimumWidth(90) self.cut_peak_iter.setMinimum(1) self.cut_peak_iter.setMaximum(50) self.cut_peak_iter.setValue(50) self.cut_peak_iter.setDecimals(0) #self.cut_peak_iter.setSingleStep(5) self.cut_peak_Wn_step = DoubleMultiplySpinBoxAlignRight() self.cut_peak_Wn_step.setDecimals(3) self.cut_peak_Wn_step.setMinimumWidth(70) self.cut_peak_iter_step = DoubleMultiplySpinBoxAlignRight() self.cut_peak_iter_step.setDecimals(0) self.cut_peak_iter_step.setMinimumWidth(70) self.cut_peak_Wn_step.valueChanged.connect(partial(self.update_step, \ self.cut_peak_Wn,self.cut_peak_Wn_step)) self.cut_peak_iter_step.valueChanged.connect(partial(self.update_step, \ self.cut_peak_iter,self.cut_peak_iter_step)) self.cut_peak_Wn_step.setValue(0.1) self.cut_peak_iter_step.setValue(5) self.cut_peak_method_spline_choice = QtWidgets.QRadioButton(text="Spline") self.cut_peak_method_baseline_choice = QtWidgets.QRadioButton(text="Baseline") self.cut_peak_method_baseline_choice.setChecked(True) self.cut_peak_label = QtWidgets.QLabel("Peak cutting parameters") self.cut_peak_Wn_label = QtWidgets.QLabel("W<sub>n</sub>") self.cut_peak_iter_label = QtWidgets.QLabel("Iterations") self.cut_peak_method_label = QtWidgets.QLabel("Method") self.baseline_params_layout.addWidget(self.cut_peak_label,0,0,1,2) self.baseline_params_layout.addWidget(self.cut_peak_method_label,1,0) self.baseline_params_layout.addWidget(self.cut_peak_method_baseline_choice,1,1) self.baseline_params_layout.addWidget(self.cut_peak_method_spline_choice,1,2) self.baseline_params_layout.addWidget(self.cut_peak_Wn_label,2,0) self.baseline_params_layout.addWidget(self.cut_peak_iter_label,3,0) self.baseline_params_layout.addWidget(self.cut_peak_Wn,2,1) self.baseline_params_layout.addWidget(self.cut_peak_iter,3,1) self.baseline_params_layout.addWidget(self.cut_peak_Wn_step,2,2) self.baseline_params_layout.addWidget(self.cut_peak_iter_step,3,2) self.baseline_params_apply_all = QtWidgets.QCheckBox('Apply to all') self.baseline_params_apply_all.setChecked(False) #self.baseline_params_layout.addWidget(self.baseline_params_apply_all,3,0,1,2) self.baseline_params.setLayout(self.baseline_params_layout) self.baseline_params_V_layout.addWidget(self.baseline_params) self.baseline_params_V_layout.addSpacerItem(VerticalSpacerItem()) # End peak parameters widget self._body_layout.addLayout(self.baseline_params_V_layout) self._layout.addLayout(self._body_layout) self.button_2_widget = QtWidgets.QWidget(self) self.button_2_widget.setObjectName('rois_control_button_2_widget') self._button_2_layout = QtWidgets.QHBoxLayout() self._button_2_layout.setContentsMargins(0, 0, 0, 0) self._button_2_layout.setSpacing(6) self.apply_btn = FlatButton('Apply') self._button_2_layout.addWidget(self.apply_btn,0) #self._button_2_layout.addWidget(VerticalLine()) self._button_2_layout.addSpacerItem(HorizontalSpacerItem()) #self._button_2_layout.addWidget(VerticalLine()) self.button_2_widget.setLayout(self._button_2_layout) self._layout.addWidget(HorizontalLine()) self._layout.addWidget(self.button_2_widget) self.setLayout(self._layout) self.style_widgets() self.roi_show_cbs = [] self.name_items = [] self.tth_items = [] self.show_parameter_in_pattern = True header_view = QtWidgets.QHeaderView(QtCore.Qt.Horizontal, self.roi_tw) self.roi_tw.setHorizontalHeader(header_view) header_view.setResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) header_view.setResizeMode(1, QtWidgets.QHeaderView.Stretch) self.default_header = [' Cut ', 'E range', f'2\N{GREEK SMALL LETTER THETA}'] self.header = copy.deepcopy(self.default_header) self.roi_tw.setHorizontalHeaderLabels(self.header) #header_view.hide() self.roi_tw.setItemDelegate(NoRectDelegate()) self.create_connections() def update_step(self, control, step_control): value = step_control.value() control.setSingleStep(value) def create_connections(self): self.roi_tw.currentCellChanged.connect(self.roi_selection_changed) def style_widgets(self): self.roi_tw.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) self.roi_tw.setMinimumWidth(370) self.roi_tw.setMinimumHeight(110) self.setStyleSheet(""" #rois_control_button_widget FlatButton { max-width: 70; min-width: 70; } #rois_control_button_2_widget FlatButton { max-width: 70; min-width: 70; } """) def closeEvent(self, event): # Overrides close event to let controller know that widget was closed by user self.widget_closed.emit() ################################################################################################ # Now comes all the roi tw stuff ################################################################################################ def roi_selection_changed(self, row, **kwargs): tth = None name = None if len(self.tth_items): tth = float(self.tth_items[row].text()) name = self.name_items[row].text() self.roi_selection_changed_signal.emit({'tth':tth,'name' :name}) def set_tw_header_unit(self, unit, unit_=''): if unit_ !='': unit_=' ('+unit_+')' self.header[2] = self.default_header[2] + ', '+unit+unit_ self.roi_tw.setHorizontalHeaderLabels(self.header) def filter_tth(self, fltr_tth): print(fltr_tth) def add_roi(self, use, name,tth): self.roi_tw.blockSignals(True) current_rows = self.roi_tw.rowCount() self.roi_tw.setRowCount(current_rows + 1) show_cb = QtWidgets.QCheckBox() show_cb.setChecked(use) show_cb.stateChanged.connect(partial(self.roi_show_cb_changed, show_cb)) show_cb.setStyleSheet("background-color: transparent") self.roi_tw.setCellWidget(current_rows, 0, show_cb) self.roi_show_cbs.append(show_cb) name_item = QtWidgets.QTableWidgetItem(name) name_item.setText(name) #name_item.setFlags(name_item.flags() & ~QtCore.Qt.ItemIsEditable) name_item.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.roi_tw.setItem(current_rows, 1, name_item) self.name_items.append(name_item) tth_item = QtWidgets.QTableWidgetItem(tth) tth_item.setText(tth) #tth_item.setFlags(tth_item.flags() & ~QtCore.Qt.ItemIsEditable) tth_item.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.roi_tw.setItem(current_rows, 2, tth_item) self.tth_items.append(tth_item) self.roi_tw.setColumnWidth(0, 50) self.roi_tw.setRowHeight(current_rows, 25) self.roi_tw.blockSignals(False) def select_roi(self, ind): self.roi_tw.selectRow(ind) def get_selected_roi_row(self): tth = None name = None row = -1 selected = self.roi_tw.selectionModel().selectedRows() if len(selected): row = selected[0].row() if len(self.tth_items): tth = float(self.tth_items[row].text()) name = self.name_items[row].text() return {'tth':tth,'name' :name,'row':row} def get_selected_roi_name(self): selected = self.roi_tw.selectionModel().selectedRows() try: row = selected[0].row() name = self.name_items[row].text() except IndexError: row = -1 name = '' return name def get_selected_roi_tth(self): selected = self.roi_tw.selectionModel().selectedRows() try: row = selected[0].row() tth_str = self.tth_items[row].text() tth = float(tth_str) except IndexError: row = -1 tth = -1 return tth def raise_widget(self): self.show() self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) self.activateWindow() self.raise_() def del_roi(self, ind): self.roi_tw.blockSignals(True) self.roi_tw.removeRow(ind) self.roi_tw.blockSignals(False) del self.roi_show_cbs[ind] del self.name_items[ind] del self.tth_items[ind] def rename_roi(self, ind, name): self.roi_tw.blockSignals(True) name_item = self.roi_tw.item(ind, 1) name_item.setText(name) self.roi_tw.blockSignals(False) def roi_show_cb_changed(self, checkbox): checked = checkbox.isChecked() ind = self.roi_show_cbs.index(checkbox) name=self.name_items[ind].text() tth=self.tth_items[ind].text() state = {'tth':tth, 'name':name, 'checked':checked} self.show_cb_state_changed.emit(state)
def setupUi(self): self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle(self.title) self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('options_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(15) self.apply_btn = FlatButton('Apply') self.apply_btn.clicked.connect(self.apply) self._button_layout.addWidget(self.apply_btn,0) #self._button_layout.addWidget(VerticalLine()) self._button_layout.addSpacerItem(HorizontalSpacerItem()) #self._button_layout.addWidget(VerticalLine()) self.button_widget.setLayout(self._button_layout) self.parameter_widget = QtWidgets.QWidget() self._parameter_layout = QtWidgets.QGridLayout() self._parameter_layout.addWidget(QtWidgets.QLabel('Parameter'), 0, 1) self._parameter_layout.addWidget(QtWidgets.QLabel('Step'), 0, 3) self.opt_controls = {} i = 1 for opt in self.opts_fields: self._parameter_layout.addWidget(QtWidgets.QLabel(self.opts_fields[opt]['label']), i, 0) self._parameter_layout.addWidget(QtWidgets.QLabel(self.opts_fields[opt]['unit']), i, 2) val=self.opts_fields[opt]['val'] e = is_e(val) if e: o = NumberTextField() else: o = DoubleSpinBoxAlignRight() o.setObjectName(opt+"_control") o.setValue(val) o.setToolTip(self.opts_fields[opt]['desc']) o.setMinimum (self.opts_fields[opt]['step']) o.setMinimumWidth(100) if not e: o.setSingleStep (self.opts_fields[opt]['step']) o_step = DoubleMultiplySpinBoxAlignRight() o_step.setObjectName(opt+"_control_step") o_step.setMinimum (0) step = self.opts_fields[opt]['step'] o_step.setValue(self.opts_fields[opt]['step']) if isinstance( self.opts_fields[opt]['val'], int): o.setDecimals(0) o.setMinimum(1) if not e: o_step.setMinimum(1) o_step.setDecimals(0) o_step.valueChanged.connect(partial(self.update_step, opt)) self.opt_controls[opt]= {'val':o,'step':o_step} self._parameter_layout.addWidget(o, i, 1) self._parameter_layout.addWidget(o_step, i, 3) self._parameter_layout.addItem(HorizontalSpacerItem(), i, 4) i += 1 self._parameter_layout.addItem(VerticalSpacerItem(), i, 0) self.parameter_widget.setLayout(self._parameter_layout) self._body_layout = QtWidgets.QHBoxLayout() self._body_layout.addWidget(self.parameter_widget, 0) self._layout.addLayout(self._body_layout) self._layout.addWidget(HorizontalLine()) self._layout.addWidget(self.button_widget) self.setLayout(self._layout) self.retranslateUi(self) self.style_widgets()
class aEDXDWidget(QMainWindow): def __init__(self, app): super().__init__() self.initUi() self.app = app raw_fig_parameters = 'Spectrum', 'Counts', 'Energy (keV)' self.raw_widget = aEDXDRawWidget(raw_fig_parameters) self.vertical_layout_tab_raw.addWidget(self.raw_widget) spectrum_fig_params = 'Spectrum', 'Intensity (arb.)', 'Energy (keV)' self.spectrum_widget = aEDXDSpectrumWidget(spectrum_fig_params) self.vertical_layout_tab_spectrum.addWidget(self.spectrum_widget) primary_beam_fig_params = 'MA-EDXD Primary Beam Analysis', 'Intensity (arb.)', 'Energy (keV)' self.primary_beam_widget = aEDXDPrimaryBeamWidget( primary_beam_fig_params) self.vertical_layout_tab_primary_beam.addWidget( self.primary_beam_widget) all_spectra_fig_params = 'MA-EDXD All Spectra', 'Intensity (arb.)', 'Energy (keV)' self.all_spectra_widget = aEDXDAllSpectraWidget(all_spectra_fig_params) self.vertical_layout_tab_all_spectra.addWidget(self.all_spectra_widget) sq_fig_parameters = 'S(q) Merged and Smoothened', 'S(q)', u'q (A<sup>-1</sup>)' self.sq_widget = aEDXDSqWidget(sq_fig_parameters) self.vertical_layout_tab_sq.addWidget(self.sq_widget) pdf_fig_parameters = 'd(r)', 'd(r)', u'r (\u212B)' # Angstrom symbol in unicode self.pdf_widget = aEDXDPDFWidget(pdf_fig_parameters) self.vertical_layout_tab_pdf.addWidget(self.pdf_widget) inverse_fig_parameters = 'S(q) filtered', 'S(q)', u'q (A<sup>-1</sup>)' self.inverse_widget = aEDXDInverseWidget(inverse_fig_parameters) self.vertical_layout_tab_inverse.addWidget(self.inverse_widget) '''rdf_fig_parameters = 't(r)', 't(r)', u'r (\u212B)' self.rdf_widget = aEDXDRDFWidget(rdf_fig_parameters) self.vertical_layout_tab_rdf.addWidget(self.rdf_widget)''' def raise_widget(self): self.show() #self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) #self.activateWindow() #self.raise_() def initUi(self): self.resize(793, 574) self.centralwidget = QtWidgets.QWidget(self) self._menu_layout = QtWidgets.QVBoxLayout() self._menu_layout.setContentsMargins(5, 0, 3, 0) self._menu_layout.setSpacing(5) self.save_as_btn = FlatButton() self.save_as_btn.setEnabled(False) self.save_btn = FlatButton() self.save_btn.setEnabled(False) self.load_btn = FlatButton() self.undo_btn = FlatButton() self.reset_btn = FlatButton() self.export_btn = FlatButton() self.angle_btn = FlatButton() self.spectra_btn = FlatButton() self.atoms_btn = FlatButton() self.sq_btn = FlatButton('Sq') self.pdf_btn = FlatButton('Gr') self.peaks_btn = FlatButton() self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 25, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.load_btn) self._menu_layout.addWidget(self.save_btn) self._menu_layout.addWidget(self.save_as_btn) self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 30, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.undo_btn) self._menu_layout.addWidget(self.reset_btn) self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 30, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.angle_btn) self._menu_layout.addWidget(self.spectra_btn) self._menu_layout.addWidget(self.atoms_btn) self._menu_layout.addWidget(self.sq_btn) self._menu_layout.addWidget(self.pdf_btn) self._menu_layout.addSpacerItem( QtWidgets.QSpacerItem(10, 30, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) self._menu_layout.addWidget(self.peaks_btn) self._menu_layout.addSpacerItem(VerticalSpacerItem()) self.horizontalLayout = QtWidgets.QHBoxLayout(self.centralwidget) self.horizontalLayout.setSpacing(2) self.horizontalLayout.setContentsMargins(0, 15, 5, 5) self.horizontalLayout.addLayout(self._menu_layout) self.tabWidget = QtWidgets.QTabWidget(self.centralwidget) self.tab_1 = QtWidgets.QWidget() self.vertical_layout_tab_raw = QtWidgets.QVBoxLayout(self.tab_1) self.vertical_layout_tab_raw.setContentsMargins(15, 5, 15, 0) self.tabWidget.addTab(self.tab_1, "") self.tab = QtWidgets.QWidget() self.vertical_layout_tab_spectrum = QtWidgets.QVBoxLayout(self.tab) self.vertical_layout_tab_spectrum.setContentsMargins(15, 5, 15, 10) self.tabWidget.addTab(self.tab, "") self.tab_2 = QtWidgets.QWidget() self.vertical_layout_tab_all_spectra = QtWidgets.QVBoxLayout( self.tab_2) self.vertical_layout_tab_all_spectra.setContentsMargins(15, 10, 15, 0) self.tabWidget.addTab(self.tab_2, "") self.tab_3 = QtWidgets.QWidget() self.vertical_layout_tab_primary_beam = QtWidgets.QVBoxLayout( self.tab_3) self.vertical_layout_tab_primary_beam.setContentsMargins(15, 5, 15, 0) self.tabWidget.addTab(self.tab_3, "") self.tab_4 = QtWidgets.QWidget() self.vertical_layout_tab_sq = QtWidgets.QVBoxLayout(self.tab_4) self.vertical_layout_tab_sq.setContentsMargins(15, 10, 15, 0) self.tabWidget.addTab(self.tab_4, "") self.tab_5 = QtWidgets.QWidget() self.vertical_layout_tab_pdf = QtWidgets.QVBoxLayout(self.tab_5) self.vertical_layout_tab_pdf.setContentsMargins(15, 10, 15, 0) self.tabWidget.addTab(self.tab_5, "") self.tab_6 = QtWidgets.QWidget() self.vertical_layout_tab_inverse = QtWidgets.QVBoxLayout(self.tab_6) self.vertical_layout_tab_inverse.setContentsMargins(15, 10, 15, 0) self.tabWidget.addTab(self.tab_6, "") '''self.tab_7 = QtWidgets.QWidget() self.vertical_layout_tab_rdf = QtWidgets.QVBoxLayout(self.tab_7) self.vertical_layout_tab_rdf.setContentsMargins(15,10,15,0) self.tabWidget.addTab(self.tab_7, "")''' self.horizontalLayout.addWidget(self.tabWidget) self.retranslateUi() self.centralwidget.setLayout(self.horizontalLayout) self.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(self) self.menubar.setGeometry(QtCore.QRect(0, 0, 793, 22)) self.file_menu = self.menubar.addMenu('File') self.file_op_act = QtWidgets.QAction('Open project', self) self.file_menu.addAction(self.file_op_act) self.file_save_act = QtWidgets.QAction('Save project', self) self.file_save_act.setEnabled(False) self.file_menu.addAction(self.file_save_act) self.file_save_as_act = QtWidgets.QAction('Save project as...', self) self.file_save_as_act.setEnabled(False) self.file_menu.addAction(self.file_save_as_act) self.file_save_hdf5_act = QtWidgets.QAction('Save to HDF5', self) #self.file_menu.addAction(self.file_save_hdf5_act) self.file_exp_menu = QtWidgets.QMenu('Export', self) self.file_exp_data_act = QtWidgets.QAction('I(E)', self) self.file_exp_menu.addAction(self.file_exp_data_act) self.file_exp_sf_act = QtWidgets.QAction('S(q)', self) self.file_exp_menu.addAction(self.file_exp_sf_act) self.file_exp_pdf_act = QtWidgets.QAction('G(r)', self) self.file_exp_menu.addAction(self.file_exp_pdf_act) self.file_exp_sf_inv_act = QtWidgets.QAction( 'Inverse Fourier-filtered S(q)', self) self.file_exp_menu.addAction(self.file_exp_sf_inv_act) self.file_menu.addMenu(self.file_exp_menu) self.opts_menu = self.menubar.addMenu('Options') self.tools_files_act = QtWidgets.QAction( f'2\N{GREEK SMALL LETTER THETA} Files Input', self) self.opts_menu.addAction(self.tools_files_act) self.opts_proc_act = QtWidgets.QAction('Spectra', self) self.opts_menu.addAction(self.opts_proc_act) self.tools_atoms_act = QtWidgets.QAction('Atoms', self) self.opts_menu.addAction(self.tools_atoms_act) self.opts_sq_act = QtWidgets.QAction('Scattering factor', self) self.opts_menu.addAction(self.opts_sq_act) self.opts_gr_act = QtWidgets.QAction('PDF', self) self.opts_menu.addAction(self.opts_gr_act) self.tools_menu = self.menubar.addMenu('Tools') self.tools_peaks_act = QtWidgets.QAction('Peak cutting', self) self.tools_menu.addAction(self.tools_peaks_act) self.setMenuBar(self.menubar) sb = self.statusBar() self.progress_bar = QtWidgets.QProgressBar() #self.progress_bar.setFixedHeight(15) #self.pb_widget = QWidget() #self._pb_widget_layout = QtWidgets.QHBoxLayout() #self._pb_widget_layout.addWidget(QtWidgets.QLabel('Progress: ')) #self._pb_widget_layout.addWidget(self.progress_bar) #self._pb_widget_layout.setContentsMargins(10,0,0,3) #self.pb_widget.setLayout(self._pb_widget_layout) #sb.addWidget(self.pb_widget) ''' self.setStyleSheet(""" QTabBar::tab { background: lightgray; color: black; border: 0; min-width: 90px; max-width: 250px; width: 90px; height: 20px; padding: 5px; } QTabBar::tab:selected { background: gray; color: white; } """) ''' self.style_widgets() self.add_tooltips() def retranslateUi(self): _translate = QtCore.QCoreApplication.translate self.setWindowTitle(_translate("aEDXDWidget", "aEDXD")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("aEDXDWidget", "I (E)")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_1), _translate("aEDXDWidget", "EDXD files")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("aEDXDWidget", "All I (E)")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("aEDXDWidget", "I p,eff (E)")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), _translate("aEDXDWidget", "S (q)")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_5), _translate("aEDXDWidget", "PDF")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_6), _translate("aEDXDWidget", "S (q) filtered")) #self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_7), _translate("aEDXDWidget", "t(r)")) def style_widgets(self): button_height = 32 button_width = 32 icon_size = QtCore.QSize(22, 22) self.save_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'save.ico'))) self.save_btn.setIconSize(icon_size) self.save_btn.setMinimumHeight(button_height) self.save_btn.setMaximumHeight(button_height) self.save_btn.setMinimumWidth(button_width) self.save_btn.setMaximumWidth(button_width) self.save_as_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'save_as.ico'))) self.save_as_btn.setIconSize(icon_size) self.save_as_btn.setMinimumHeight(button_height) self.save_as_btn.setMaximumHeight(button_height) self.save_as_btn.setMinimumWidth(button_width) self.save_as_btn.setMaximumWidth(button_width) self.load_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'open.ico'))) self.load_btn.setIconSize(icon_size) self.load_btn.setMinimumHeight(button_height) self.load_btn.setMaximumHeight(button_height) self.load_btn.setMinimumWidth(button_width) self.load_btn.setMaximumWidth(button_width) self.undo_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'undo.ico'))) self.undo_btn.setIconSize(icon_size) self.undo_btn.setMinimumHeight(button_height) self.undo_btn.setMaximumHeight(button_height) self.undo_btn.setMinimumWidth(button_width) self.undo_btn.setMaximumWidth(button_width) self.reset_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'restore.ico'))) self.reset_btn.setIconSize(icon_size) self.reset_btn.setMinimumHeight(button_height) self.reset_btn.setMaximumHeight(button_height) self.reset_btn.setMinimumWidth(button_width) self.reset_btn.setMaximumWidth(button_width) self.export_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'export.ico'))) self.export_btn.setIconSize(icon_size) self.export_btn.setMinimumHeight(button_height) self.export_btn.setMaximumHeight(button_height) self.export_btn.setMinimumWidth(button_width) self.export_btn.setMaximumWidth(button_width) self.angle_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'import.ico'))) self.angle_btn.setIconSize(icon_size) self.angle_btn.setMinimumHeight(button_height) self.angle_btn.setMaximumHeight(button_height) self.angle_btn.setMinimumWidth(button_width) self.angle_btn.setMaximumWidth(button_width) self.spectra_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'spectra.ico'))) self.spectra_btn.setIconSize(icon_size) self.spectra_btn.setMinimumHeight(button_height) self.spectra_btn.setMaximumHeight(button_height) self.spectra_btn.setMinimumWidth(button_width) self.spectra_btn.setMaximumWidth(button_width) self.atoms_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'atoms1.ico'))) self.atoms_btn.setIconSize(icon_size) self.atoms_btn.setMinimumHeight(button_height) self.atoms_btn.setMaximumHeight(button_height) self.atoms_btn.setMinimumWidth(button_width) self.atoms_btn.setMaximumWidth(button_width) #self.sq_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'sq1.ico'))) self.sq_btn.setIconSize(icon_size) self.sq_btn.setMinimumHeight(button_height) self.sq_btn.setMaximumHeight(button_height) self.sq_btn.setMinimumWidth(button_width) self.sq_btn.setMaximumWidth(button_width) #self.pdf_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'pdf1.ico'))) self.pdf_btn.setIconSize(icon_size) self.pdf_btn.setMinimumHeight(button_height) self.pdf_btn.setMaximumHeight(button_height) self.pdf_btn.setMinimumWidth(button_width) self.pdf_btn.setMaximumWidth(button_width) self.peaks_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'cut.ico'))) self.peaks_btn.setIconSize(icon_size) self.peaks_btn.setMinimumHeight(button_height) self.peaks_btn.setMaximumHeight(button_height) self.peaks_btn.setMinimumWidth(button_width) self.peaks_btn.setMaximumWidth(button_width) def add_tooltips(self): self.load_btn.setToolTip('Open Project') self.save_btn.setToolTip('Save Project') self.save_as_btn.setToolTip('Save Project As...') self.undo_btn.setToolTip('Undo') self.reset_btn.setToolTip('Reset to last saved configuration') self.angle_btn.setToolTip('EDXD Files Input') self.spectra_btn.setToolTip('Spectra options') self.atoms_btn.setToolTip('Atoms options') self.sq_btn.setToolTip('Scattering Factor options') self.pdf_btn.setToolTip('PDF options') self.peaks_btn.setToolTip('Peak cutting')
def __init__(self): super().__init__() self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle('Cut regions control') self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('rois_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(15) #self.add_btn = FlatButton('Add') #self.edit_btn = FlatButton('Edit') self.delete_btn = FlatButton('Delete') self.clear_btn = FlatButton('Clear') #self.show_fit_btn = FlatButton('Show') self.edit_btn = FlatButton('Edit') self.filter_btn = FlatButton(f'Filter 2\N{GREEK SMALL LETTER THETA}') self.filter_btn.setCheckable(True) self.filter_btn.setChecked(True) self._button_layout.addWidget(self.edit_btn) self._button_layout.addWidget(self.delete_btn) self._button_layout.addWidget(self.clear_btn) self._button_layout.addWidget(self.filter_btn) self._button_layout.addSpacerItem(HorizontalSpacerItem()) self.button_widget.setLayout(self._button_layout) self._layout.addWidget(self.button_widget) self._body_layout = QtWidgets.QHBoxLayout() self.roi_tw = ListTableWidget(columns=3) self._body_layout.addWidget(self.roi_tw, 10) #### Start peak parameters widget self.baseline_params = QtWidgets.QWidget() self.baseline_params_layout = QtWidgets.QGridLayout() self.baseline_params_V_layout = QtWidgets.QVBoxLayout() self.cut_peak_Wn = DoubleSpinBoxAlignRight() self.cut_peak_Wn.setMinimumWidth(90) self.cut_peak_Wn.setMinimum(0.001) self.cut_peak_Wn.setMaximum(1) self.cut_peak_Wn.setValue(0.2) self.cut_peak_Wn.setDecimals(3) #self.cut_peak_Wn.setSingleStep(0.1) self.cut_peak_iter = DoubleSpinBoxAlignRight() self.cut_peak_iter.setMinimumWidth(90) self.cut_peak_iter.setMinimum(1) self.cut_peak_iter.setMaximum(50) self.cut_peak_iter.setValue(50) self.cut_peak_iter.setDecimals(0) #self.cut_peak_iter.setSingleStep(5) self.cut_peak_Wn_step = DoubleMultiplySpinBoxAlignRight() self.cut_peak_Wn_step.setDecimals(3) self.cut_peak_Wn_step.setMinimumWidth(70) self.cut_peak_iter_step = DoubleMultiplySpinBoxAlignRight() self.cut_peak_iter_step.setDecimals(0) self.cut_peak_iter_step.setMinimumWidth(70) self.cut_peak_Wn_step.valueChanged.connect(partial(self.update_step, \ self.cut_peak_Wn,self.cut_peak_Wn_step)) self.cut_peak_iter_step.valueChanged.connect(partial(self.update_step, \ self.cut_peak_iter,self.cut_peak_iter_step)) self.cut_peak_Wn_step.setValue(0.1) self.cut_peak_iter_step.setValue(5) self.cut_peak_method_spline_choice = QtWidgets.QRadioButton(text="Spline") self.cut_peak_method_baseline_choice = QtWidgets.QRadioButton(text="Baseline") self.cut_peak_method_baseline_choice.setChecked(True) self.cut_peak_label = QtWidgets.QLabel("Peak cutting parameters") self.cut_peak_Wn_label = QtWidgets.QLabel("W<sub>n</sub>") self.cut_peak_iter_label = QtWidgets.QLabel("Iterations") self.cut_peak_method_label = QtWidgets.QLabel("Method") self.baseline_params_layout.addWidget(self.cut_peak_label,0,0,1,2) self.baseline_params_layout.addWidget(self.cut_peak_method_label,1,0) self.baseline_params_layout.addWidget(self.cut_peak_method_baseline_choice,1,1) self.baseline_params_layout.addWidget(self.cut_peak_method_spline_choice,1,2) self.baseline_params_layout.addWidget(self.cut_peak_Wn_label,2,0) self.baseline_params_layout.addWidget(self.cut_peak_iter_label,3,0) self.baseline_params_layout.addWidget(self.cut_peak_Wn,2,1) self.baseline_params_layout.addWidget(self.cut_peak_iter,3,1) self.baseline_params_layout.addWidget(self.cut_peak_Wn_step,2,2) self.baseline_params_layout.addWidget(self.cut_peak_iter_step,3,2) self.baseline_params_apply_all = QtWidgets.QCheckBox('Apply to all') self.baseline_params_apply_all.setChecked(False) #self.baseline_params_layout.addWidget(self.baseline_params_apply_all,3,0,1,2) self.baseline_params.setLayout(self.baseline_params_layout) self.baseline_params_V_layout.addWidget(self.baseline_params) self.baseline_params_V_layout.addSpacerItem(VerticalSpacerItem()) # End peak parameters widget self._body_layout.addLayout(self.baseline_params_V_layout) self._layout.addLayout(self._body_layout) self.button_2_widget = QtWidgets.QWidget(self) self.button_2_widget.setObjectName('rois_control_button_2_widget') self._button_2_layout = QtWidgets.QHBoxLayout() self._button_2_layout.setContentsMargins(0, 0, 0, 0) self._button_2_layout.setSpacing(6) self.apply_btn = FlatButton('Apply') self._button_2_layout.addWidget(self.apply_btn,0) #self._button_2_layout.addWidget(VerticalLine()) self._button_2_layout.addSpacerItem(HorizontalSpacerItem()) #self._button_2_layout.addWidget(VerticalLine()) self.button_2_widget.setLayout(self._button_2_layout) self._layout.addWidget(HorizontalLine()) self._layout.addWidget(self.button_2_widget) self.setLayout(self._layout) self.style_widgets() self.roi_show_cbs = [] self.name_items = [] self.tth_items = [] self.show_parameter_in_pattern = True header_view = QtWidgets.QHeaderView(QtCore.Qt.Horizontal, self.roi_tw) self.roi_tw.setHorizontalHeader(header_view) header_view.setResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) header_view.setResizeMode(1, QtWidgets.QHeaderView.Stretch) self.default_header = [' Cut ', 'E range', f'2\N{GREEK SMALL LETTER THETA}'] self.header = copy.deepcopy(self.default_header) self.roi_tw.setHorizontalHeaderLabels(self.header) #header_view.hide() self.roi_tw.setItemDelegate(NoRectDelegate()) self.create_connections()
def setupUi(self): self._layout = QtWidgets.QVBoxLayout() #self._layout.setSpacing(5) self.setWindowTitle('EDXD Files Input Control') self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('files_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_grid_layout = QtWidgets.QGridLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) #self._button_layout.set self.add_tth_btn = FlatButton('+ '+f'2\N{GREEK SMALL LETTER THETA}') self._button_grid_layout.addWidget(self.add_tth_btn, 0,1) self.add_btn = FlatButton('+ EDXD') self._button_grid_layout.addWidget(self.add_btn,1,1) self.add_all_btn = FlatButton('+ All EDXD') self._button_grid_layout.addWidget(self.add_all_btn,1,0) self.add_scan = FlatButton(f'+ All 2\N{GREEK SMALL LETTER THETA}') self._button_grid_layout.addWidget(self.add_scan,0,0) self.del_btn = FlatButton('Delete') self._button_grid_layout.addWidget(self.del_btn,0,2) self.clear_btn = FlatButton('Clear') self._button_grid_layout.addWidget(self.clear_btn,0,3) self.expand_btn = FlatButton('Expand') self._button_grid_layout.addWidget(self.expand_btn,1,2) self.collapse_btn = FlatButton('Collapse') self._button_grid_layout.addWidget(self.collapse_btn,1,3) self._button_layout.addLayout(self._button_grid_layout) self._button_layout.addSpacerItem(HorizontalSpacerItem()) #self.from_config_btn = QtWidgets.QPushButton('From config.') #self._button_layout.addWidget(self.from_config_btn,0) #self._button_layout.addWidget(VerticalLine()) #self._button_layout.addSpacerItem(HorizontalSpacerItem()) #self._button_layout.addWidget(VerticalLine()) self.button_widget.setLayout(self._button_layout) self._body_layout = QtWidgets.QHBoxLayout() '''self.file_tw = ListTableWidget(columns=4) header_view = QtWidgets.QHeaderView(QtCore.Qt.Horizontal, self.file_tw) self.file_tw.setHorizontalHeader(header_view) header_view.setResizeMode(0, QtWidgets.QHeaderView.ResizeToContents) header_view.setResizeMode(1, QtWidgets.QHeaderView.ResizeToContents) header_view.setResizeMode(2, QtWidgets.QHeaderView.Stretch) header_view.setResizeMode(3, QtWidgets.QHeaderView.ResizeToContents)''' self.file_trw = treeWidget() #self.file_trw.setHeaderLabels([' ' + f' 2\N{GREEK SMALL LETTER THETA}']) self.file_trw.setHeaderHidden(True) #self.file_trw.setAlternatingRowColors(True) #self.file_trw.setItemDelegate(NoRectDelegate()) header = self.file_trw.header() header.setResizeMode(QtWidgets.QHeaderView.Fixed) self._body_layout.addWidget(self.file_trw ) self._layout.addWidget(self.button_widget) self._layout.addLayout(self._body_layout) self.button_2_widget = QtWidgets.QWidget(self) self.button_2_widget.setObjectName('files_control_button_2_widget') self._button_2_layout = QtWidgets.QHBoxLayout() self._button_2_layout.setContentsMargins(0, 0, 0, 0) self._button_2_layout.setSpacing(6) self.apply_btn = FlatButton('Apply') self._button_2_layout.addWidget(self.apply_btn,0) #self._button_2_layout.addWidget(VerticalLine()) self._button_2_layout.addSpacerItem(HorizontalSpacerItem()) #self._button_2_layout.addWidget(VerticalLine()) self.button_2_widget.setLayout(self._button_2_layout) self._layout.addWidget(HorizontalLine()) self._layout.addWidget(self.button_2_widget) self.setLayout(self._layout) self.retranslateUi(self) self.style_widgets() self.del_btn.clicked.connect(self.delete_clicked)
class parameterWidget(QtWidgets.QWidget): sequence_changed_signal = QtCore.pyqtSignal(dict) widget_closed = QtCore.pyqtSignal() def __init__(self): super().__init__() self.setWindowTitle('New multiangle setup') self._layout = QtWidgets.QVBoxLayout() self._parameter_layout = QtWidgets.QGridLayout() self.q_low_sb = DoubleSpinBoxAlignRight() self.E_low_sb = DoubleSpinBoxAlignRight() self.q_high_sb = DoubleSpinBoxAlignRight() self.E_high_sb = DoubleSpinBoxAlignRight() self.overlap_sb = DoubleSpinBoxAlignRight() self.q_low_sb.setMinimumWidth(100) self.E_low_sb.setMinimumWidth(100) self.q_high_sb.setMinimumWidth(100) self.E_high_sb.setMinimumWidth(100) self.overlap_sb.setMinimumWidth(100) self.q_low_sb.setMaximum(50) self.q_low_sb.setMinimum(0.001) self.q_low_sb.setValue(1) self.E_low_sb.setMaximum(1000) self.E_low_sb.setMinimum(1) self.E_low_sb.setValue(34) self.q_high_sb.setMaximum(50) self.q_high_sb.setMinimum(0.001) self.q_high_sb.setValue(15) self.E_low_sb.setMaximum(1000) self.E_low_sb.setMinimum(1) self.E_high_sb.setValue(68) self.overlap_sb.setMaximum(90) self.overlap_sb.setMinimum(10) self.overlap_sb.setValue(75) self._parameter_layout.addWidget(QtWidgets.QLabel('Low'), 0, 1) self._parameter_layout.addWidget(QtWidgets.QLabel('High'), 0, 2) self._parameter_layout.addWidget(QtWidgets.QLabel('q:'), 1, 0) self._parameter_layout.addWidget(QtWidgets.QLabel('E:'), 2, 0) self._parameter_layout.addWidget(QtWidgets.QLabel('Overlap %:'), 3, 0) self._parameter_layout.addWidget( QtWidgets.QLabel( f'\N{LATIN CAPITAL LETTER A WITH RING ABOVE}\N{SUPERSCRIPT MINUS}\N{SUPERSCRIPT ONE}' ), 1, 3) self._parameter_layout.addWidget(QtWidgets.QLabel('KeV'), 2, 3) self._parameter_layout.addWidget(self.q_low_sb, 1, 1) self._parameter_layout.addWidget(self.q_high_sb, 1, 2) self._parameter_layout.addWidget(self.E_low_sb, 2, 1) self._parameter_layout.addWidget(self.E_high_sb, 2, 2) self._parameter_layout.addWidget(self.overlap_sb, 3, 1) self.apply_btn = FlatButton('Apply') self.apply_btn.setMinimumWidth(75) self.overlap_lbl = QtWidgets.QLabel('') self._parameter_layout.addWidget(self.apply_btn, 4, 1, 1, 1) self._parameter_layout.addWidget(self.overlap_lbl, 3, 2, 1, 1) self._layout.addLayout(self._parameter_layout) self._layout.addSpacerItem(VerticalSpacerItem()) self.setLayout(self._layout) self.apply_btn.clicked.connect(self.compute_2th) def compute_2th(self): q_low = self.q_low_sb.value() e_low = self.E_low_sb.value() q_high = self.q_high_sb.value() e_high = self.E_high_sb.value() overlap_fract = self.overlap_sb.value() * 0.01 start_time = time.time() n, overlap_fract, seq = optimize_tth(q_low, q_high, e_low, e_high, overlap_fract) timer = time.time() - start_time t = [] for tth in seq: t.append(tth['tth']) d = {} d['n'] = n d['overlap_fract'] = overlap_fract d['seq'] = seq d['tth'] = t low_q = seq[0]['q_low'] high_q = seq[-1]['q_high'] d['q_low'] = low_q d['q_high'] = high_q ''' print(str(t)) print('n = '+ str(int(n))) print('overlap = '+ str(overlap_fract*100)) print('q start = '+ str(low_q)+ '; q end = '+ str(high_q)) print("tth optimized --- %s seconds ---" % (timer)) ''' self.overlap_lbl.setText('n: ' + str(int(n)) + '\nOverlap %: ' + str(round(overlap_fract * 100, 3))) self.sequence_changed_signal.emit(d) def raise_widget(self): self.show() self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) self.activateWindow() self.raise_()
class TthItem(QtWidgets.QWidget): file_dragged_in = pyqtSignal(dict) color_btn_clicked_signal = pyqtSignal(QtWidgets.QWidget) file_dragged_in_from_treewidget = pyqtSignal(dict) def __init__(self,color, text ): super().__init__() self.color_button = FlatButton() self.color_button.setStyleSheet("background-color: " + color) self.color_button.setMaximumHeight(18) self.color_button.setMinimumWidth(18) self.color_button.setMaximumWidth(18) self.tthItem = QtWidgets.QLabel(text) self.tthItem.setStyleSheet("background-color: transparent") self._layout = QtWidgets.QHBoxLayout() self._layout.setContentsMargins(1,1,1,1) self._layout.addWidget(self.color_button) self._layout.addWidget(self.tthItem) self._layout.addSpacerItem(HorizontalSpacerItem()) self.setLayout(self._layout) self.setAcceptDrops(True) #tth_item.editingFinished.connect(partial(self.Tth_edit_finished, tth_item)) def dragEnterEvent(self, e): md = e.mimeData() if md.hasUrls: e.accept() else: e.reject() def dragMoveEvent(self, e): md = e.mimeData() if md.hasUrls: e.accept() else: e.reject() def dropEvent(self, e): """ Drop files directly onto the widget File locations are stored in fname :param e: :return: """ TW = isinstance(e.source(), QTreeWidget) if TW: tth = self.tthItem.text() self.file_dragged_in_from_treewidget.emit({tth:e}) return tth = float(self.tthItem.text()) md = e.mimeData() if md.hasUrls: e.setDropAction(QtCore.Qt.CopyAction) e.accept() fnames = list() for url in e.mimeData().urls(): fname = str(url.toLocalFile()) fnames.append(fname) d = {} d[tth]=fnames self.file_dragged_in.emit(d)
def __init__(self): super().__init__() self.setWindowTitle('New multiangle setup') self._layout = QtWidgets.QVBoxLayout() self._parameter_layout = QtWidgets.QGridLayout() self.q_low_sb = DoubleSpinBoxAlignRight() self.E_low_sb = DoubleSpinBoxAlignRight() self.q_high_sb = DoubleSpinBoxAlignRight() self.E_high_sb = DoubleSpinBoxAlignRight() self.overlap_sb = DoubleSpinBoxAlignRight() self.q_low_sb.setMinimumWidth(100) self.E_low_sb.setMinimumWidth(100) self.q_high_sb.setMinimumWidth(100) self.E_high_sb.setMinimumWidth(100) self.overlap_sb.setMinimumWidth(100) self.q_low_sb.setMaximum(50) self.q_low_sb.setMinimum(0.001) self.q_low_sb.setValue(1) self.E_low_sb.setMaximum(1000) self.E_low_sb.setMinimum(1) self.E_low_sb.setValue(34) self.q_high_sb.setMaximum(50) self.q_high_sb.setMinimum(0.001) self.q_high_sb.setValue(15) self.E_low_sb.setMaximum(1000) self.E_low_sb.setMinimum(1) self.E_high_sb.setValue(68) self.overlap_sb.setMaximum(90) self.overlap_sb.setMinimum(10) self.overlap_sb.setValue(75) self._parameter_layout.addWidget(QtWidgets.QLabel('Low'), 0, 1) self._parameter_layout.addWidget(QtWidgets.QLabel('High'), 0, 2) self._parameter_layout.addWidget(QtWidgets.QLabel('q:'), 1, 0) self._parameter_layout.addWidget(QtWidgets.QLabel('E:'), 2, 0) self._parameter_layout.addWidget(QtWidgets.QLabel('Overlap %:'), 3, 0) self._parameter_layout.addWidget( QtWidgets.QLabel( f'\N{LATIN CAPITAL LETTER A WITH RING ABOVE}\N{SUPERSCRIPT MINUS}\N{SUPERSCRIPT ONE}' ), 1, 3) self._parameter_layout.addWidget(QtWidgets.QLabel('KeV'), 2, 3) self._parameter_layout.addWidget(self.q_low_sb, 1, 1) self._parameter_layout.addWidget(self.q_high_sb, 1, 2) self._parameter_layout.addWidget(self.E_low_sb, 2, 1) self._parameter_layout.addWidget(self.E_high_sb, 2, 2) self._parameter_layout.addWidget(self.overlap_sb, 3, 1) self.apply_btn = FlatButton('Apply') self.apply_btn.setMinimumWidth(75) self.overlap_lbl = QtWidgets.QLabel('') self._parameter_layout.addWidget(self.apply_btn, 4, 1, 1, 1) self._parameter_layout.addWidget(self.overlap_lbl, 3, 2, 1, 1) self._layout.addLayout(self._parameter_layout) self._layout.addSpacerItem(VerticalSpacerItem()) self.setLayout(self._layout) self.apply_btn.clicked.connect(self.compute_2th)
def __init__(self): super().__init__() self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle('Atoms control') self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('atom_control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(15) self.add_btn = FlatButton('Add') self.delete_btn = FlatButton('Delete') self.clear_btn = FlatButton('Clear') self._button_layout.addWidget(self.add_btn) self._button_layout.addWidget(self.delete_btn) self._button_layout.addWidget(self.clear_btn) self._button_layout.addSpacerItem(HorizontalSpacerItem()) ''' self._button_layout.addWidget(VerticalLine()) self._button_layout.addWidget(VerticalLine()) self._button_layout.addWidget(self.save_btn) ''' self.button_widget.setLayout(self._button_layout) self._layout.addWidget(self.button_widget) self._body_layout = QtWidgets.QHBoxLayout() self.atom_tw = ListTableWidget(columns=4) self._body_layout.addWidget(self.atom_tw, 10) self._layout.addLayout(self._body_layout) self.button_2_widget = QtWidgets.QWidget(self) self.button_2_widget.setObjectName('options_control_button_2_widget') self._button_2_layout = QtWidgets.QHBoxLayout() self._button_2_layout.setContentsMargins(0, 0, 0, 0) self._button_2_layout.setSpacing(6) self.apply_btn = FlatButton('Apply') self._button_2_layout.addWidget(self.apply_btn, 0) #self._button_2_layout.addWidget(VerticalLine()) self._button_2_layout.addSpacerItem(HorizontalSpacerItem()) #self._button_2_layout.addWidget(VerticalLine()) self.button_2_widget.setLayout(self._button_2_layout) self._layout.addWidget(HorizontalLine()) self._layout.addWidget(self.button_2_widget) self.setLayout(self._layout) self.style_widgets() self.name_items = [] self.index_items = [] self.fract_items = [] self.show_parameter_in_pattern = True header_view = QtWidgets.QHeaderView(QtCore.Qt.Horizontal, self.atom_tw) self.atom_tw.setHorizontalHeader(header_view) header_view.setSectionResizeMode( 0, QtWidgets.QHeaderView.ResizeToContents) header_view.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch) header_view.setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch) header_view.setSectionResizeMode(3, QtWidgets.QHeaderView.Stretch) self.default_header = ['#', 'Atom', 'Note', 'Fraction', 'ind'] self.header = copy.deepcopy(self.default_header) self.atom_tw.setHorizontalHeaderLabels(self.header) self.atom_tw.setItemDelegate(NoRectDelegate()) self.ap = aEDXDAtomicParameters() self.sq_pars = [] self.make_connections()
class aEDXDAllSpectraWidget(customWidget): def __init__(self, fig_params): super().__init__(fig_params) self.export_IE_btn = FlatButton() self.export_IE_btn.setToolTip('Export All I(E)') button_height = 32 button_width = 32 icon_size = QtCore.QSize(22, 22) self.export_IE_btn.setIcon( QtGui.QIcon(os.path.join(icons_path, 'export.ico'))) self.export_IE_btn.setIconSize(icon_size) self.export_IE_btn.setMinimumHeight(button_height) self.export_IE_btn.setMaximumHeight(button_height) self.export_IE_btn.setMinimumWidth(button_width) self.export_IE_btn.setMaximumWidth(button_width) self.add_top_button_widget_item(self.export_IE_btn) self.add_top_button_widget_spacer()
def __init__(self, multiangle_model): super().__init__() self.multiangle_model = multiangle_model self.parameter_widget = parameterWidget() self._layout = QtWidgets.QVBoxLayout() self.setWindowTitle('Multiangle control') self.button_widget = QtWidgets.QWidget(self) self.button_widget.setObjectName('control_button_widget') self._button_layout = QtWidgets.QHBoxLayout() self._button_layout.setContentsMargins(0, 0, 0, 0) self._button_layout.setSpacing(15) self.new_btn = FlatButton('Setup') self.load_btn = FlatButton('Load') self.save_btn = FlatButton('Save') self.delete_btn = FlatButton('Delete') self.clear_btn = FlatButton('Clear') self.add_btn = FlatButton('Add') self.plot_btn = FlatButton('Plot') self._button_layout.addWidget(self.new_btn) self._button_layout.addWidget(self.load_btn) self._button_layout.addWidget(self.save_btn) self._button_layout.addWidget(self.add_btn) self._button_layout.addWidget(self.delete_btn) self._button_layout.addWidget(self.clear_btn) self._button_layout.addWidget(self.plot_btn) self._button_layout.addSpacerItem(HorizontalSpacerItem()) ''' self._button_layout.addWidget(VerticalLine()) self._button_layout.addWidget(VerticalLine()) self._button_layout.addWidget(self.save_btn) ''' self.button_widget.setLayout(self._button_layout) self._layout.addWidget(self.button_widget) self._body_layout = QtWidgets.QHBoxLayout() self.tth_tv = QtWidgets.QTreeView() self.tth_tv.sortByColumn(0, 0) self.tth_tv.setSortingEnabled(True) self.tth_tv.setModel(self.multiangle_model) self._body_layout.addWidget(self.tth_tv, 10) self.make_beam_parameter_widget() self._body_layout.addWidget(self.beam_parameter_widget) self._layout.addLayout(self._body_layout) self.button_2_widget = QtWidgets.QWidget(self) self.button_2_widget.setObjectName('options_control_button_2_widget') self._button_2_layout = QtWidgets.QHBoxLayout() self._button_2_layout.setContentsMargins(0, 0, 0, 0) self._button_2_layout.setSpacing(15) self.iterations_lbl = QtWidgets.QLabel('Iterations:') self._button_2_layout.addWidget(self.iterations_lbl) self.iterations_control = QtWidgets.QLineEdit() self.iterations_control.setText('1') self._button_2_layout.addWidget(self.iterations_control) self.run_btn = FlatButton('Run') self._button_2_layout.addWidget(self.run_btn, 0) self.stop_btn = FlatButton('Stop') self._button_2_layout.addWidget(self.stop_btn, 0) self.test_btn = FlatButton('Test') self._button_2_layout.addWidget(self.test_btn, 0) self.setup_btn = FlatButton('Setup') self._button_2_layout.addWidget(self.setup_btn, 0) #self._button_2_layout.addWidget(VerticalLine()) self._button_2_layout.addSpacerItem(HorizontalSpacerItem()) #self._button_2_layout.addWidget(VerticalLine()) self.button_2_widget.setLayout(self._button_2_layout) self._layout.addWidget(HorizontalLine()) self._layout.addWidget(self.button_2_widget) self.setLayout(self._layout) self.style_widgets() self.show_parameter_in_pattern = True #self.tth_tv.setItemDelegate(NoRectDelegate()) columns = self.multiangle_model.columnCount() self.tth_tv.resizeColumnToContents(0) header = self.tth_tv.header() for ind in range(columns): header.setSectionResizeMode(ind, QtWidgets.QHeaderView.Stretch) self.make_connections()
def __init__(self, parent=None): super(JcpdsEditorWidget, self).__init__(parent) self.setWindowTitle('JCPDS Editor') self._layout = QtWidgets.QVBoxLayout() self._file_layout = QtWidgets.QGridLayout() self._file_layout.addWidget(LabelAlignRight('Filename:'), 0, 0) self._file_layout.addWidget(LabelAlignRight('Comment:'), 1, 0) self.filename_txt = QtWidgets.QLineEdit('') self.comments_txt = QtWidgets.QLineEdit('') self._file_layout.addWidget(self.filename_txt, 0, 1) self._file_layout.addWidget(self.comments_txt, 1, 1) self._layout.addLayout((self._file_layout)) self.lattice_parameters_gb = QtWidgets.QGroupBox('Lattice Parameters') self._lattice_parameters_layout = QtWidgets.QVBoxLayout() self._symmetry_layout = QtWidgets.QHBoxLayout() self._symmetry_layout.addWidget(LabelAlignRight('Symmetry')) self.symmetry_cb = CleanLooksComboBox() self.symmetries = [ 'cubic', 'tetragonal', 'hexagonal', 'trigonal', 'rhombohedral', 'orthorhombic', 'monoclinic', 'triclinic' ] self.symmetry_cb.addItems(self.symmetries) self._symmetry_layout.addWidget(self.symmetry_cb) self._symmetry_layout.addSpacerItem(HorizontalSpacerItem()) self._lattice_parameters_layout.addLayout(self._symmetry_layout) self._parameters_layout = QtWidgets.QGridLayout() self.lattice_a_sb = DoubleSpinBoxAlignRight() self.lattice_a_sb.setSingleStep(0.01) self.lattice_a_sb.setMinimum(0) self.lattice_a_sb.setMaximum(99999) self.lattice_a_sb.setDecimals(4) self.lattice_b_sb = DoubleSpinBoxAlignRight() self.lattice_b_sb.setMinimum(0) self.lattice_b_sb.setMaximum(99999) self.lattice_b_sb.setDecimals(4) self.lattice_b_sb.setSingleStep(0.01) self.lattice_c_sb = DoubleSpinBoxAlignRight() self.lattice_c_sb.setMinimum(0) self.lattice_c_sb.setMaximum(99999) self.lattice_c_sb.setDecimals(4) self.lattice_c_sb.setSingleStep(0.01) self.lattice_length_step_txt = NumberTextField('0.01') self.add_field(self._parameters_layout, self.lattice_a_sb, 'a<sub>0</sub>:', u"Å", 0, 0) self.add_field(self._parameters_layout, self.lattice_b_sb, 'b<sub>0</sub>:', u"Å", 0, 3) self.add_field(self._parameters_layout, self.lattice_c_sb, 'c<sub>0</sub>:', u"Å", 0, 6) self.add_field(self._parameters_layout, self.lattice_length_step_txt, 'st:', u"Å", 0, 9) self.lattice_eos_a_txt = NumberTextField() self.lattice_eos_b_txt = NumberTextField() self.lattice_eos_c_txt = NumberTextField() self.add_field(self._parameters_layout, self.lattice_eos_a_txt, 'a:', u"Å", 1, 0) self.add_field(self._parameters_layout, self.lattice_eos_b_txt, 'b:', u"Å", 1, 3) self.add_field(self._parameters_layout, self.lattice_eos_c_txt, 'c:', u"Å", 1, 6) self.lattice_alpha_sb = DoubleSpinBoxAlignRight() self.lattice_alpha_sb.setMaximum(180) self.lattice_beta_sb = DoubleSpinBoxAlignRight() self.lattice_beta_sb.setMaximum(180) self.lattice_gamma_sb = DoubleSpinBoxAlignRight() self.lattice_gamma_sb.setMaximum(180) self.lattice_angle_step_txt = NumberTextField('1') self.add_field(self._parameters_layout, self.lattice_alpha_sb, u'α:', u"°", 2, 0) self.add_field(self._parameters_layout, self.lattice_beta_sb, u'β:', u"°", 2, 3) self.add_field(self._parameters_layout, self.lattice_gamma_sb, u'γ:', u"°", 2, 6) self.add_field(self._parameters_layout, self.lattice_angle_step_txt, u'st:', u"°", 2, 9) self.lattice_ab_sb = DoubleSpinBoxAlignRight() self.lattice_ab_sb.setDecimals(4) self.lattice_ca_sb = DoubleSpinBoxAlignRight() self.lattice_ca_sb.setDecimals(4) self.lattice_cb_sb = DoubleSpinBoxAlignRight() self.lattice_cb_sb.setDecimals(4) self.lattice_ratio_step_txt = NumberTextField('0.01') self.add_field(self._parameters_layout, self.lattice_ab_sb, 'a/b:', None, 3, 0) self.add_field(self._parameters_layout, self.lattice_ca_sb, 'c/a:', None, 3, 3) self.add_field(self._parameters_layout, self.lattice_cb_sb, 'c/b:', None, 3, 6) self.add_field(self._parameters_layout, self.lattice_ratio_step_txt, 'st:', None, 3, 9) self.lattice_volume_txt = NumberTextField() self.lattice_eos_volume_txt = NumberTextField() self.lattice_eos_molar_volume_txt = NumberTextField() self.lattice_eos_z_txt = NumberTextField() self.add_field(self._parameters_layout, self.lattice_volume_txt, 'V<sub>0</sub>:', u'ų', 4, 0) self.add_field(self._parameters_layout, self.lattice_eos_volume_txt, 'V:', u'ų', 4, 3) self.add_field(self._parameters_layout, self.lattice_eos_molar_volume_txt, 'V<sub>m</sub>:', u'm³/mol', 5, 3) self.add_field(self._parameters_layout, self.lattice_eos_z_txt, 'Z:', u'', 5, 0) self._lattice_parameters_layout.addLayout(self._parameters_layout) self.lattice_parameters_gb.setLayout(self._lattice_parameters_layout) self.eos_widget = EosGroupbox() self.reflections_gb = QtWidgets.QGroupBox('Reflections') self._reflection_layout = QtWidgets.QGridLayout() self.reflection_table_view = QtWidgets.QTableView() self.reflection_table_model = ReflectionTableModel() self.reflection_table_view.setModel(self.reflection_table_model) #self.reflection_table.setColumnCount(8) self.reflections_add_btn = FlatButton('Add') self.reflections_delete_btn = FlatButton('Delete') self.reflections_clear_btn = FlatButton('Clear') self._reflection_layout.addWidget(self.reflection_table_view, 0, 0, 1, 3) self._reflection_layout.addWidget(self.reflections_add_btn, 1, 0) self._reflection_layout.addWidget(self.reflections_delete_btn, 1, 1) self._reflection_layout.addWidget(self.reflections_clear_btn, 1, 2) self.reflections_gb.setLayout(self._reflection_layout) self._body_layout = QtWidgets.QGridLayout() self._body_layout.addWidget(self.eos_widget, 0, 0) self._body_layout.addItem(VerticalSpacerItem(), 1, 0) self._body_layout.addWidget(self.reflections_gb, 0, 1, 2, 1) self._button_layout = QtWidgets.QHBoxLayout() self.save_as_btn = FlatButton('Save As') self.reload_file_btn = FlatButton('Reload File') self._button_layout.addWidget(self.save_as_btn) self._button_layout.addWidget(self.reload_file_btn) self._button_layout.addSpacerItem(HorizontalSpacerItem()) self._layout.addWidget(self.lattice_parameters_gb) self._layout.addLayout(self._body_layout) self._layout.addLayout(self._button_layout) self.setLayout(self._layout) self.style_widgets()