class StopRunRetry(QWidget): def __init__(self, parent=None): super(StopRunRetry, self).__init__() main_path = get_main_path() ctrl_box = QHBoxLayout() self.repeat_btn = QPushButton("\n Retry \n", self) re_try_icon_path = str(main_path + "/resources/re_try.png") re_try_grayed_path = str(main_path + "/resources/re_try_grayed.png") tmp_ico = QIcon() tmp_ico.addFile(re_try_icon_path, mode=QIcon.Normal) tmp_ico.addFile(re_try_grayed_path, mode=QIcon.Disabled) self.repeat_btn.setIcon(tmp_ico) self.repeat_btn.setIconSize(QSize(50, 38)) ctrl_box.addWidget(self.repeat_btn) self.run_btn = QPushButton("\n Run \n", self) self.dials_logo_path = str( main_path + "/resources/DIALS_Logo_smaller_centred.png" ) dials_grayed_path = str( main_path + "/resources/DIALS_Logo_smaller_centred_grayed.png" ) tmp_ico = QIcon() tmp_ico.addFile(self.dials_logo_path, mode=QIcon.Normal) tmp_ico.addFile(dials_grayed_path, mode=QIcon.Disabled) self.run_btn.setIcon(tmp_ico) self.run_btn.setIconSize(QSize(50, 50)) ctrl_box.addWidget(self.run_btn) self.stop_btn = QPushButton("\n Stop \n", self) stop_logo_path = str(main_path + "/resources/stop.png") stop_grayed_path = str(main_path + "/resources/stop_grayed.png") tmp_ico = QIcon() tmp_ico.addFile(stop_logo_path, mode=QIcon.Normal) tmp_ico.addFile(stop_grayed_path, mode=QIcon.Disabled) self.stop_btn.setIcon(tmp_ico) self.stop_btn.setIconSize(QSize(50, 38)) ctrl_box.addWidget(self.stop_btn) self.setLayout(ctrl_box)
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)