def __init__(self): super(MainWidget, self).__init__() try: with open('bkp.pickle', 'rb') as bkp_in: self.uni_controler = pickle.load(bkp_in) except: self.uni_controler = Runner() self.cli_tree_output = TreeShow() self.cli_tree_output(self.uni_controler) self.cur_html = None self.cur_pick = None self.cur_json = None main_box = QVBoxLayout() h_main_splitter = QSplitter() h_main_splitter.setOrientation(Qt.Horizontal) self.tree_out = TreeNavWidget() self.tree_out.clicked[QModelIndex].connect(self.item_clicked) self.tree_out.update_me(self.uni_controler.step_list[0], self.uni_controler.current) h_main_splitter.addWidget(self.tree_out) self.centre_widget = CentreWidget() self.centre_widget.run_btn.clicked.connect(self.run_clicked) h_main_splitter.addWidget(self.centre_widget) self.cli_out = CliOutView() self.web_view = WebTab() self.img_view = MyImgWin() self.my_tabs = QTabWidget() self.my_tabs.addTab(self.img_view, "Image View") self.my_tabs.addTab(self.cli_out, "CLI Output") self.my_tabs.addTab(self.web_view, "Report View") h_main_splitter.addWidget(self.my_tabs) main_box.addWidget(h_main_splitter) self.custom_thread = MyThread() self.custom_thread.finished.connect(self.update_after_finished) self.custom_thread.str_print_signal.connect(self.cli_out.add_txt) self.main_widget = QWidget() self.main_widget.setLayout(main_box) self.setCentralWidget(self.main_widget)
def __init__(self): super(MainWidget, self).__init__() self.my_pop = None # Any child popup windows. Only bravais_table ATM self.storage_path = sys_arg.directory refresh_gui = False # Load the previous state of DUI, if present dui_files_path = os.path.join(self.storage_path, "dui_files") if os.path.isfile(os.path.join(dui_files_path, "bkp.pickle")): try: self.idials_runner = load_previous_state(dui_files_path) except Exception as e: # Something went wrong - tell the user then close msg = traceback.format_exc() logger.error("ERROR LOADING PREVIOUS DATA:\n%s", msg) raise_from(DUIDataLoadingError(msg), e) refresh_gui = True else: # No dui_files path - start with a fresh state if not os.path.isdir(dui_files_path): os.mkdir(dui_files_path) self.idials_runner = Runner() self.gui2_log = {"pairs_list": []} self.cli_tree_output = TreeShow() self.cli_tree_output(self.idials_runner) self.cur_html = None self.cur_pick = None self.cur_json = None self.cur_log = None self.cur_cmd_name = "None" main_box = QVBoxLayout() self.centre_par_widget = ControlWidget() self.centre_par_widget.pass_sys_arg_object_to_import(sys_arg) self.stop_run_retry = StopRunRetry() self.tree_out = TreeNavWidget() left_control_box = QHBoxLayout() left_top_control_box = QVBoxLayout() left_top_control_box.addWidget(self.centre_par_widget) left_top_control_box.addStretch() left_control_box.addLayout(left_top_control_box) centre_control_box = QVBoxLayout() v_control_splitter = QSplitter() v_control_splitter.setOrientation(Qt.Vertical) v_control_splitter.addWidget(self.tree_out) v_control_splitter.addWidget(self.centre_par_widget.step_param_widg) centre_control_box.addWidget(v_control_splitter) centre_control_box.addWidget(self.stop_run_retry) left_control_box.addLayout(centre_control_box) dummy_left_widget = QWidget() dummy_h_layout = QHBoxLayout() dummy_h_layout.addLayout(left_control_box) dummy_left_widget.setLayout(dummy_h_layout) dummy_left_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) h_main_splitter = QSplitter() h_main_splitter.setOrientation(Qt.Horizontal) h_main_splitter.addWidget(dummy_left_widget) self.cli_out = CliOutView() self.web_view = WebTab() self.img_view = MyImgWin() self.ext_view = OuterCaller() self.info_widget = InfoWidget() self.output_info_tabs = QTabWidget() self.output_info_tabs.addTab(self.img_view, "Image") self.output_info_tabs.addTab(self.cli_out, "Log") self.output_info_tabs.addTab(self.web_view, "Report") self.output_info_tabs.addTab(self.ext_view, "Tools") self.output_info_tabs.addTab(self.info_widget, "Experiment") self.view_tab_num = 0 self.output_info_tabs.currentChanged.connect(self.tab_changed) self.img_view.mask_applied.connect(self.pop_mask_list) self.img_view.predic_changed.connect(self.tab_changed) self.img_view.bc_applied.connect(self.pop_b_centr_coord) self.img_view.new_pars_applied.connect(self.pass_parmams) # self.ext_view.pass_parmam_lst.connect(self.pass_parmams) self.centre_par_widget.finished_masking.connect(self.img_view.unchec_my_mask) self.centre_par_widget.click_mask.connect(self.img_view.chec_my_mask) self.centre_par_widget.finished_b_centr.connect(self.img_view.unchec_b_centr) self.centre_par_widget.click_b_centr.connect(self.img_view.chec_b_centr) v_info_splitter = QSplitter() v_info_splitter.setOrientation(Qt.Vertical) v_info_splitter.addWidget(self.output_info_tabs) h_main_splitter.addWidget(v_info_splitter) main_box.addWidget(h_main_splitter) self.txt_bar = Text_w_Bar() main_box.addWidget(self.txt_bar) self.connect_all() self.custom_thread = CommandThread() self.custom_thread.finished.connect(self.update_after_finished) self.custom_thread.str_fail_signal.connect(self.after_failed) self.custom_thread.str_print_signal.connect(self.cli_out.add_txt) self.custom_thread.str_print_signal.connect(self.txt_bar.setText) self.custom_thread.busy_box_on.connect(self.pop_busy_box) self.custom_thread.busy_box_off.connect(self.close_busy_box) self.main_widget = QWidget() self.main_widget.setLayout(main_box) self.setCentralWidget(self.main_widget) self.setWindowTitle("CCP4 DUI - {}: {}".format(__version__, dui_files_path)) self.setWindowIcon(QIcon(self.stop_run_retry.dials_logo_path)) self.just_reindexed = False self.user_stoped = False self.reconnect_when_ready() self.my_pop = None if refresh_gui: self.refresh_my_gui()
except BaseException as e: # We don't want to catch bare exceptions but don't know # what this was supposed to catch. Log it. logger.debug("Caught unknown exception type %s: %s", type(e).__name__, e) logger.debug("no pickle file available") return ref_pkl, pre_pkl def get_next_from_here(self): return self.current_node.get_next_step() if __name__ == "__main__" and __package__ is None: tree_output = TreeShow() storage_path = sys_arg.directory try: with open(storage_path + "/dui_files/bkp.pickle", "rb") as bkp_in: idials_runner = pickle.load(bkp_in) # TODO sometimes the following error appears # Attribute not found # 'module' object has no attribute 'CommandNode' except Exception as e: print("str(e) = %s", str(e)) print("e.__doc__ = %s", e.__doc__) print("e.message = %s", e.message) idials_runner = Runner()
def __init__(self): super(MainWidget, self).__init__() self.storage_path = sys_arg.directory try: with open (self.storage_path + "/dui_files/bkp.pickle", "rb") as bkp_in: self.idials_runner = pickle.load(bkp_in) #TODO sometimes the following error appears #Attribute not found #'module' object has no attribute 'CommandNode' except Exception as e: print "str(e) =", str(e) print "e.__doc__ =", e.__doc__ print "e.message =", e.message self.idials_runner = Runner() try: import shutil shutil.rmtree(self.storage_path + "/dui_files") except: print "failed to do \"shutil.rmtree(\"/dui_files\")\"" os.mkdir(self.storage_path + "/dui_files") #This flag makes the behaviour switch (automatic / explicit) self.idials_runner.make_next = sys_arg.make_next self.cli_tree_output = TreeShow() self.cli_tree_output(self.idials_runner) self.cur_html = None self.cur_pick = None self.cur_json = None self.cur_log = None self.cur_cmd_name = "None" main_box = QVBoxLayout() h_left_splitter = QSplitter() h_left_splitter.setOrientation(Qt.Horizontal) self.tree_out = TreeNavWidget() ''' scroll_area_left = QScrollArea() scroll_area_left.setWidget(self.tree_out) h_left_splitter.addWidget(scroll_area_left) ''' h_left_splitter.addWidget(self.tree_out) self.centre_widget = CentreWidget() self.centre_widget.get_arg_obj(sys_arg) self.run_all = sys_arg.run_all h_left_splitter.addWidget(self.centre_widget) v_left_splitter = QSplitter() v_left_splitter.setOrientation(Qt.Vertical) v_left_splitter.addWidget(h_left_splitter) self.info_widget = InfoWidget() scrollArea = QScrollArea() scrollArea.setWidget(self.info_widget) v_left_splitter.addWidget(scrollArea) h_main_splitter = QSplitter() h_main_splitter.setOrientation(Qt.Horizontal) h_main_splitter.addWidget(v_left_splitter) self.cli_out = CliOutView() self.web_view = WebTab() self.img_view = MyImgWin() self.ext_view = OuterCaller() self.output_info_tabs = QTabWidget() self.output_info_tabs.addTab(self.img_view, "Image View") self.output_info_tabs.addTab(self.cli_out, "Log Text") self.output_info_tabs.addTab(self.web_view, "Report View") self.output_info_tabs.addTab(self.ext_view, "Reciprocal Lattice Viewer") self.view_tab_num = 0 self.output_info_tabs.currentChanged.connect(self.tab_changed) h_main_splitter.addWidget(self.output_info_tabs) main_box.addWidget(h_main_splitter) self.txt_bar = Text_w_Bar() main_box.addWidget(self.txt_bar) self.connect_all() self.custom_thread = CommandThread() self.custom_thread.finished.connect(self.update_after_finished) self.custom_thread.str_fail_signal.connect(self.after_failed) self.custom_thread.str_print_signal.connect(self.cli_out.add_txt) self.custom_thread.str_print_signal.connect(self.txt_bar.setText) self.main_widget = QWidget() self.main_widget.setLayout(main_box) self.setCentralWidget(self.main_widget) self.setWindowTitle('CCP4 DUI') self.setWindowIcon(QIcon(self.centre_widget.dials_logo_path)) self.just_reindexed = False self.user_stoped = False self.reconnect_when_ready()