diff --git a/src/hyperctui/autonomous_reconstruction/select_tof_regions.py b/src/hyperctui/autonomous_reconstruction/select_tof_regions.py index 96a3545..c9e4e46 100644 --- a/src/hyperctui/autonomous_reconstruction/select_tof_regions.py +++ b/src/hyperctui/autonomous_reconstruction/select_tof_regions.py @@ -54,6 +54,7 @@ def __init__(self, parent=None): self.load_time_spectra() self.calculate_lambda_axis() self.check_table_state() + self.check_state_ok_button() def initialization(self): o_init = InitializationSelectTofRegions(parent=self, grand_parent=self.parent) @@ -325,6 +326,7 @@ def top_roi_changed(self): def checkButton_clicked(self): self.table_changed() + self.check_state_ok_button() def replot_bragg_regions(self): """replot the Bragg regions""" @@ -373,6 +375,25 @@ def regions_manually_moved(self): o_table.unblock_signals() # self.update_evaluation_regions_dict() + def is_ok_button_ready(self): + tof_regions = self.parent.tof_regions + nbr_region_enabled = 0 + for _key in tof_regions.keys(): + if tof_regions[_key][EvaluationRegionKeys.state]: + nbr_region_enabled += 1 + + if nbr_region_enabled > 0: + return True + + return False + + def check_state_ok_button(self): + if self.is_ok_button_ready(): + self.ui.pushButton.setEnabled(True) + else: + self.ui.pushButton.setEnabled(False) + + def accept(self): self.ok_clicked = True self.save_table()