class ImportPage(QWidget): update_command_lst_low_level = Signal(list) """ This stacked widget basically helps the user to browse the input images path, there is no auto-generated GUI form Phil parameters in use withing this widget. """ def __init__(self, parent=None): super(ImportPage, self).__init__(parent=None) main_v_box = QVBoxLayout() label_font = QFont() sys_font_point_size = label_font.pointSize() label_font.setPointSize(sys_font_point_size + 2) step_label = QLabel(str("Import")) step_label.setFont(label_font) self.simple_lin = QLineEdit(self) self.simple_lin.textChanged.connect(self.update_command) self.x_spn_bx = QSpinBox() self.x_spn_bx.setMaximum(99999) self.x_spn_bx.setSpecialValueText(" ") self.y_spn_bx = QSpinBox() self.y_spn_bx.setMaximum(99999) self.y_spn_bx.setSpecialValueText(" ") self.x_spn_bx.valueChanged.connect(self.x_beam_changed) self.y_spn_bx.valueChanged.connect(self.y_beam_changed) self.chk_invert = QCheckBox("Invert rotation axis") self.chk_invert.stateChanged.connect(self.inv_rota_changed) self.opn_fil_btn = QPushButton(" \n Select file(s) \n ") main_path = get_main_path() self.opn_fil_btn.setIcon(QIcon(main_path + "/resources/import.png")) self.opn_fil_btn.setIconSize(QSize(80, 48)) main_v_box.addWidget(step_label) main_v_box.addWidget(self.opn_fil_btn) main_v_box.addWidget(self.simple_lin) self.b_cetre_label = QLabel("\n\n Beam centre") main_v_box.addWidget(self.b_cetre_label) cent_hbox = QHBoxLayout() self.x_label = QLabel(" X: ") cent_hbox.addWidget(self.x_label) cent_hbox.addWidget(self.x_spn_bx) self.y_label = QLabel(" Y: ") cent_hbox.addWidget(self.y_label) cent_hbox.addWidget(self.y_spn_bx) # cent_hbox.addWidget(QLabel(" \n ")) cent_hbox.addStretch() main_v_box.addLayout(cent_hbox) main_v_box.addWidget(self.chk_invert) main_v_box.addStretch() self.opn_fil_btn.clicked.connect(self.open_files) self.defa_dir = str(os.getcwd()) self.setLayout(main_v_box) # self.show() self.reset_par() def reset_par(self): logger.info("reset_par(ImportPage)") self.cmd_list = [] self.simple_lin.setText(" ? ") self.x_spn_bx.setValue(0.0) self.y_spn_bx.setValue(0.0) self.chk_invert.setChecked(False) self.x_beam, self.y_beam = 0.0, 0.0 self.path_file_str = "" self.second_half = "" self.third_half = "" def update_param_w_lst(self, lst_in): self.reset_par() logger.info("update_param_w_lst(ImportPage) \n lst: \n", lst_in) for singl_com in lst_in: if singl_com[0:1] == "/": self.path_file_str = str(singl_com) self.put_str_lin() if singl_com[0:12] == "image_range=": self.path_file_str += " " self.path_file_str += str(singl_com) self.put_str_lin() if singl_com == "invert_rotation_axis=True": self.chk_invert.setChecked(True) if singl_com[0:22] == "slow_fast_beam_centre=": yb_xb_str = singl_com[22:] yb_str, xb_str = yb_xb_str.split(",") yb = float(yb_str) xb = float(xb_str) self.y_spn_bx.setValue(yb) self.x_spn_bx.setValue(xb) def inv_rota_changed(self): if self.chk_invert.checkState(): self.third_half = "invert_rotation_axis=True" else: self.third_half = "" self.put_str_lin() def x_beam_changed(self, value): self.x_beam = value self.build_second_half() def y_beam_changed(self, value): self.y_beam = value self.build_second_half() def build_second_half(self): if self.x_beam != 0.0 and self.y_beam != 0.0: self.second_half = ( "slow_fast_beam_centre=" + str(self.y_beam) + "," + str(self.x_beam) ) else: self.second_half = "" self.put_str_lin() def open_files(self): lst_file_path = QFileDialog.getOpenFileNames( self, "Open File(s)", self.defa_dir, "All Files (*.*)" ) if len(lst_file_path) > 0: new_dir, new_command = get_import_run_string(lst_file_path) # logger.info("\n new_dir=", new_dir, ">>") # logger.info("\n new_command =", new_command, ">>") self.path_file_str = new_command self.defa_dir = new_dir self.put_str_lin() def put_str_lin(self): # logger.info("self.path_file_str =", self.path_file_str, ">>") self.cmd_list = [ self.path_file_str, self.second_half.lstrip(), self.third_half.lstrip(), ] txt_lin = " ".join(self.cmd_list).rstrip() while " " in txt_lin: txt_lin = txt_lin.replace(" ", " ") self.simple_lin.setText(txt_lin) def set_arg_obj(self, sys_arg_in): """Pass the system argument object to handle launch arguments.""" if sys_arg_in.template is not None: str_arg = str(sys_arg_in.template) self.simple_lin.setText(str_arg) def update_command(self): self.command_lst = [["import"]] param_com = str(self.simple_lin.text()) cmd_lst = param_com.split(" ") for single_com in cmd_lst: self.command_lst[0].append(single_com) self.update_command_lst_low_level.emit(self.command_lst[0]) def gray_me_out(self): self.simple_lin.setEnabled(False) self.opn_fil_btn.setEnabled(False) self.x_spn_bx.setEnabled(False) self.y_spn_bx.setEnabled(False) self.x_label.setEnabled(False) self.y_label.setEnabled(False) self.b_cetre_label.setEnabled(False) self.chk_invert.setEnabled(False) def activate_me(self, cur_nod=None): self.simple_lin.setEnabled(True) self.opn_fil_btn.setEnabled(True) self.y_spn_bx.setEnabled(True) self.x_spn_bx.setEnabled(True) self.x_label.setEnabled(True) self.y_label.setEnabled(True) self.b_cetre_label.setEnabled(True) self.chk_invert.setEnabled(True)
class ExportPage(QWidget): update_command_lst_low_level = Signal(list) """ This stacked widget basically helps the user to export by generating an MTZ file, there is no auto-generated GUI form Phil parameters in use withing this widget. """ def __init__(self, parent=None): super(ExportPage, self).__init__(parent=None) main_v_box = QVBoxLayout() label_font = QFont() sys_font_point_size = label_font.pointSize() label_font.setPointSize(sys_font_point_size + 2) step_label = QLabel(str("Export")) step_label.setFont(label_font) out_file_label = QLabel(str("mtz output name:")) self.simple_lin = QLineEdit(self) self.simple_lin.textChanged.connect(self.update_command) self.check_scale = QCheckBox("Output Scaled Intensities") self.check_scale.setChecked(False) self.check_scale.stateChanged.connect(self.update_command) self.warning_label = QLabel(str(" ")) self.warning_label.setWordWrap(True) main_v_box.addWidget(step_label) main_v_box.addWidget(out_file_label) main_v_box.addWidget(self.simple_lin) main_v_box.addWidget(self.check_scale) main_v_box.addStretch() main_v_box.addWidget(self.warning_label) main_v_box.addStretch() self.setLayout(main_v_box) self.fist_time = False # self.show() self.simple_lin.setText("integrated.mtz") def update_command(self): self.command_lst = [["export"]] param1_com = str(self.simple_lin.text()) self.command_lst[0].append("mtz.hklout=" + param1_com) if self.check_scale.checkState(): param2_com = "intensity=scale" self.command_lst[0].append(param2_com) self.update_command_lst_low_level.emit(self.command_lst[0]) self.check_repeated_file() def check_repeated_file(self): param1_com = str(self.simple_lin.text()) cwd_path = os.path.join(sys_arg.directory, "dui_files") mtz_file_path = os.path.join(cwd_path, param1_com) if os.path.isfile(mtz_file_path): txt_warning = "Warning, file: " + param1_com + " already exists" self.warning_label.setText(txt_warning) self.warning_label.setStyleSheet("color: rgba(255, 55, 55, 255)") """ self.warning_label.setStyleSheet( "color: rgba(255, 55, 55, 255);" "background-color: yellow;" ) """ else: self.warning_label.setText(" ") self.warning_label.setStyleSheet("color: rgba(0, 155, 255, 255)") def gray_me_out(self): self.simple_lin.setEnabled(False) self.check_scale.setEnabled(False) self.fist_time = False def activate_me(self, cur_nod=None): self.simple_lin.setEnabled(True) self.check_scale.setEnabled(True) if self.fist_time is False: self.fist_time = True self.simple_lin.setText("integrated.mtz") self.check_scale.setChecked(False) my_node = cur_nod found_scale = False for iters in range(5): try: if my_node.ll_command_lst[0][0] == "scale": found_scale = True break except AttributeError as at_err: logger.info("found ", at_err, " in for loop, not to worry") my_node = my_node.prev_step if found_scale is True: self.simple_lin.setText("scaled.mtz") self.check_scale.setChecked(True) self.check_repeated_file() def reset_par(self): logger.info("command_lst(ExportPage.reset_par) = ", self.command_lst) logger.info(" Not supposed to reset export page")