Exemplo n.º 1
0
    def __init__(self, master=None):
        super().__init__(master=master)
        self.title("Star List")

        self.defGeometry = STAR_WIN_DEF_GEOM
        self.geometry(str(self.defGeometry))
        self.resizable(False, False)
        self.configure(bg=FR_BG)
        self.protocol("WM_DELETE_WINDOW", self.close)

        # Star list
        self.listFrame = tk.Frame(self, bg=FR_BG)
        self.listFrame.grid()

        self.starLabel = mtk.make_Label(self.listFrame,
                                        text="Star",
                                        column=1,
                                        pady=2,
                                        sticky=tk.EW)
        self.posesLabel = mtk.make_Label(self.listFrame,
                                         text="Poses",
                                         column=2,
                                         pady=2,
                                         sticky=tk.EW)
        self.flatLabel = mtk.make_Label(self.listFrame,
                                        text="Flat",
                                        column=3,
                                        pady=2,
                                        sticky=tk.EW)
        self.neonLabel = mtk.make_Label(self.listFrame,
                                        text="Neon",
                                        column=4,
                                        pady=2,
                                        sticky=tk.EW)
        self.darkLabel = mtk.make_Label(self.listFrame,
                                        text="Dark T",
                                        column=5,
                                        pady=2,
                                        sticky=tk.EW)
        self.standardLabel = mtk.make_Label(self.listFrame,
                                            text="Standard",
                                            column=6,
                                            pady=2,
                                            sticky=tk.EW)

        self.starEntries = []
        self.posesEntries = []
        self.flatEntries = []
        self.neonEntries = []
        self.darkEntries = []
        self.standardEntries = []
        self.removeButtons = []

        # Ref frame
        self.refFrame = tk.Frame(self, bg=FR_BG)
        self.refFrame.grid()

        self.refLabel = mtk.make_Label(self.refFrame,
                                       text="REF: ",
                                       padx=2,
                                       state=tk.DISABLED)
        self.refEntry = mtk.make_Entry(self.refFrame,
                                       column=1,
                                       padx=2,
                                       sticky=tk.EW,
                                       state=tk.DISABLED)
        self.refPoseLabel = mtk.make_Label(self.refFrame,
                                           text="REF pose: ",
                                           column=2,
                                           padx=2,
                                           state=tk.DISABLED)
        self.refPoseEntry = mtk.make_Entry(self.refFrame,
                                           width=5,
                                           column=3,
                                           padx=2,
                                           sticky=tk.EW,
                                           state=tk.DISABLED)

        # Start button
        self.startButton = mtk.make_Button(self,
                                           self.start_session,
                                           text="Start Session",
                                           row=2,
                                           pady=2)

        return
Exemplo n.º 2
0
    def add_master(self, master_type):
        print("ADD MASTER (" + master_type + ")")

        bias_flag = (master_type == BIAS)
        err_flag = False

        if bias_flag:
            print("Checking inserted bias poses value...")
            poses_entry = self.biasPosesEntry

        else:
            print("Checking inserted dark poses and time values...")
            poses_entry = self.darkPosesEntry

            time_entry = self.darkTimeEntry
            master_time = rm_spaces(time_entry.get())
            print("Checking master time...")
            if not str_is_positive_int(master_time):
                print("Error: invalid master time value!")
                err_flag = True
            else:
                master_time = int(master_time)
                if not (self.masterListWindow is None):
                    for i in range(0, self.masterListDim):
                        if self.masterListWindow.typeEntries[i].get() == BIAS:
                            continue

                        i_time = int(
                            self.masterListWindow.timeEntries[i].get())
                        if master_time == i_time:
                            print(
                                "Error: master dark with such pose time already exists!"
                            )
                            err_flag = True
                            break

        master_poses = rm_spaces(poses_entry.get())
        print("Checking master poses...")
        if not str_is_positive_int(master_poses):
            print("Error: invalid master poses value!")
            err_flag = True
        else:
            master_poses = int(master_poses)

        if err_flag:
            mtk.entry_err_blink(poses_entry)
            if master_type == DARK:
                mtk.entry_err_blink(time_entry)
            return

        mtk.clear_Entry(poses_entry)
        if bias_flag:
            self.biasButton.configure(state=tk.DISABLED)
            self.biasPosesLabel.configure(state=tk.DISABLED)
            self.biasPosesEntry.configure(state=tk.DISABLED)
        else:
            mtk.clear_Entry(time_entry)

        self.masterListDim += 1
        self.masterFlag = True

        if self.masterListWindow is None:
            # Open dark list window
            print("Opening master list window...")
            self.masterListWindow = MasterListWindow()

        list_dim = self.masterListDim
        list_frame = self.masterListWindow.listFrame

        print("Adding the master to the list...")
        new_remove_button = mtk.make_Button(
            list_frame,
            text="-",
            row=list_dim,
            pady=1,
            command=lambda to_remove=list_dim: self.remove_master(to_remove))
        self.masterListWindow.removeButtons.append(new_remove_button)

        new_type_entry = mtk.make_Entry(list_frame,
                                        text=master_type,
                                        row=list_dim,
                                        column=1,
                                        padx=2,
                                        width=6,
                                        sticky=tk.EW,
                                        state="readonly")
        self.masterListWindow.typeEntries.append(new_type_entry)

        new_poses_entry = mtk.make_Entry(list_frame,
                                         text=master_poses,
                                         row=list_dim,
                                         column=2,
                                         padx=2,
                                         width=6,
                                         sticky=tk.EW,
                                         state="readonly")
        self.masterListWindow.posesEntries.append(new_poses_entry)

        new_time_entry = mtk.make_Entry(list_frame,
                                        row=list_dim,
                                        column=3,
                                        padx=2,
                                        width=6,
                                        sticky=tk.EW)
        if bias_flag:
            new_time_entry.configure(state=tk.DISABLED)
        else:
            new_time_entry.insert(0, master_time)
            new_time_entry.configure(state="readonly")
        self.masterListWindow.timeEntries.append(new_time_entry)

        # Resize master list window
        self.masterListWindow = resized_window(self.masterListWindow, list_dim,
                                               MASTERL_EN_HG)

        print("New master added successfully")
        return
Exemplo n.º 3
0
    def __init__(self):
        super().__init__()
        self.title("IRAF Liste")

        self.defGeometry = MAIN_WIN_DEF_GEOM
        self.geometry(str(self.defGeometry))
        self.resizable(False, False)
        self.configure(bg=FR_BG)

        # Settings frame
        self.settingFrame = tk.Frame(self, bg=FR_BG)
        self.settingFrame.pack()

        # Workspace settings
        self.wsButton = mtk.make_Button(self.settingFrame,
                                        self.select_ws_path,
                                        text="Choose WS dir",
                                        pady=5)
        self.wsLabel = mtk.make_Label(self.settingFrame,
                                      text="Workspace:",
                                      column=1)
        self.wsEntry = mtk.make_Entry(self.settingFrame,
                                      column=2,
                                      state="readonly")
        self.wsPath = ""

        # Add star interface
        self.starButton = mtk.make_Button(self.settingFrame,
                                          self.add_star,
                                          text="Add star",
                                          row=1,
                                          state=tk.DISABLED)
        self.starLabel = mtk.make_Label(self.settingFrame,
                                        text="New star:",
                                        row=1,
                                        column=1,
                                        state=tk.DISABLED)
        self.starEntry = mtk.make_Entry(self.settingFrame,
                                        row=1,
                                        column=2,
                                        state=tk.DISABLED)

        # Star list
        self.starList = []
        self.starListDim = 0
        self.starListWindow = None

        # Reference star interface
        self.refButton = mtk.make_Button(self.settingFrame,
                                         self.select_ref,
                                         text="Choose reference",
                                         row=2,
                                         state=tk.DISABLED)
        self.refLabel = mtk.make_Label(self.settingFrame,
                                       text="New REF:",
                                       row=2,
                                       column=1,
                                       state=tk.DISABLED)
        self.refEntry = mtk.make_Entry(self.settingFrame,
                                       row=2,
                                       column=2,
                                       state=tk.DISABLED)

        self.curRefLabel = mtk.make_Label(self.settingFrame,
                                          text="Selected REF:",
                                          row=3,
                                          column=1,
                                          state=tk.DISABLED)
        self.curRefEntry = mtk.make_Entry(self.settingFrame,
                                          row=3,
                                          column=2,
                                          state=tk.DISABLED)

        self.refName = None
        self.refPose = None

        # Spectrograph selection interface
        self.specLabel = mtk.make_Label(self.settingFrame,
                                        text="Spectrograph:",
                                        row=4,
                                        column=1,
                                        state=tk.DISABLED)

        self.specVal = tk.StringVar(self)
        spec_name_list = (specInfo.name for specInfo in SPEC_INFO)
        self.specOptions = mtk.make_OptionMenu(self.settingFrame,
                                               self.specVal,
                                               spec_name_list,
                                               defaultval=SPEC_INFO[0].name,
                                               row=4,
                                               column=2,
                                               state=tk.DISABLED)

        self.addSpecButton = mtk.make_Button(
            self.settingFrame,
            command=lambda mode=ADD: self.set_spec(mode),
            text="Add New SPEC",
            row=5,
            padx=2,
            state=tk.DISABLED)
        self.modSpecButton = mtk.make_Button(
            self.settingFrame,
            command=lambda mode=MOD: self.set_spec(mode),
            text="Modify SPEC",
            column=1,
            row=5,
            padx=2,
            state=tk.DISABLED)
        self.delSpecButton = mtk.make_Button(self.settingFrame,
                                             self.del_spec,
                                             text="Delete SPEC",
                                             column=2,
                                             row=5,
                                             padx=2,
                                             state=tk.DISABLED)

        self.specWindow = None

        # Synthesis Button
        self.synButton = mtk.make_Button(self,
                                         self.gen_syn,
                                         text="Generate Synthesis",
                                         state=tk.DISABLED,
                                         grid_flag=False,
                                         fill="x",
                                         padx=5)
        self.synWindow = None
        self.sepSynMaster = mtk.make_Separator(self)

        # Master frame
        self.masterFrame = tk.Frame(self, bg=FR_BG)
        self.masterFrame.pack()

        # Master dark interface
        self.darkButton = mtk.make_Button(
            self.masterFrame,
            command=lambda spec_type=DARK: self.add_master(spec_type),
            text="Add Master Dark",
            state=tk.DISABLED)
        self.darkPosesLabel = mtk.make_Label(self.masterFrame,
                                             text="Dark poses:",
                                             column=1,
                                             state=tk.DISABLED)
        self.darkPosesEntry = mtk.make_Entry(self.masterFrame,
                                             column=2,
                                             state=tk.DISABLED)
        self.darkTimeLabel = mtk.make_Label(self.masterFrame,
                                            text="Dark time:",
                                            row=1,
                                            column=1,
                                            state=tk.DISABLED)
        self.darkTimeEntry = mtk.make_Entry(self.masterFrame,
                                            row=1,
                                            column=2,
                                            state=tk.DISABLED)

        # Master list
        self.masterListDim = 0
        self.masterListWindow = None
        self.masterFlag = False

        # Master bias interface
        self.biasButton = mtk.make_Button(
            self.masterFrame,
            command=lambda spec_type=BIAS: self.add_master(spec_type),
            text="Insert Master Bias",
            row=2,
            state=tk.DISABLED)
        self.biasPosesLabel = mtk.make_Label(self.masterFrame,
                                             text="Bias poses:",
                                             row=2,
                                             column=1,
                                             state=tk.DISABLED)
        self.biasPosesEntry = mtk.make_Entry(self.masterFrame,
                                             row=2,
                                             column=2,
                                             state=tk.DISABLED)

        # Bottom frame
        self.bottomFrame = tk.Frame(self, bg=FR_BG)
        self.bottomFrame.pack(side=tk.BOTTOM, fill=tk.X)
        self.restartFrame = tk.Frame(self.bottomFrame, bg=FR_BG)
        self.restartFrame.pack(side=tk.LEFT, expand=True, fill=tk.X)
        self.closeFrame = tk.Frame(self.bottomFrame, bg=FR_BG)
        self.closeFrame.pack(side=tk.RIGHT, expand=True, fill=tk.X)

        # Restart button
        self.restartButton = mtk.make_Button(self.restartFrame,
                                             self.restart,
                                             text="Restart",
                                             pady=5,
                                             grid_flag=False,
                                             fill=tk.X,
                                             expand=True)

        # Close button
        self.closeButton = mtk.make_Button(self.closeFrame,
                                           self.destroy,
                                           text="Close",
                                           pady=5,
                                           grid_flag=False,
                                           fill=tk.X,
                                           expand=True)

        return
Exemplo n.º 4
0
    def add_star(self):
        print("ADD STAR")

        # Check star name
        print("Checking inserted name...")
        star_name = rm_spaces(self.starEntry.get())
        mtk.clear_Entry(self.starEntry)
        if not star_name:
            print("Error: insert a star name!")
            mtk.entry_err_blink(self.starEntry)
            return
        elif self.starListWindow is None:
            # Open star list window
            print("Opening star list window...")
            self.starListWindow = StarListWindow()
            self.refButton.configure(state=tk.NORMAL)
            self.refLabel.configure(state=tk.NORMAL)
            self.refEntry.configure(state=tk.NORMAL)
        else:
            for i in range(0, self.starListDim):
                i_star = self.starListWindow.starEntries[i].get()
                if star_name == i_star:
                    print("Error: star is already in the list!")
                    mtk.entry_err_blink(self.starEntry)
                    return
        mtk.clear_Entry(self.starEntry)

        self.starListDim += 1
        list_dim = self.starListDim
        list_frame = self.starListWindow.listFrame

        # Add new record on the star list window
        print("Adding a new record on the star list window...")
        new_remove_button = mtk.make_Button(
            list_frame,
            text="-",
            row=list_dim,
            pady=1,
            command=lambda to_remove=list_dim: self.remove_star(to_remove))
        self.starListWindow.removeButtons.append(new_remove_button)

        new_star_entry = mtk.make_Entry(list_frame,
                                        text=star_name,
                                        row=list_dim,
                                        column=1,
                                        padx=2,
                                        width=20,
                                        sticky=tk.EW,
                                        state="readonly")
        self.starListWindow.starEntries.append(new_star_entry)

        new_pose_entry = mtk.make_Entry(list_frame,
                                        row=list_dim,
                                        column=2,
                                        width=6,
                                        sticky=tk.EW)
        self.starListWindow.posesEntries.append(new_pose_entry)

        new_flat_entry = mtk.make_Entry(list_frame,
                                        text=5,
                                        row=list_dim,
                                        column=3,
                                        width=6,
                                        sticky=tk.EW)
        self.starListWindow.flatEntries.append(new_flat_entry)

        new_neon_entry = mtk.make_Entry(list_frame,
                                        text=3,
                                        row=list_dim,
                                        column=4,
                                        width=6,
                                        sticky=tk.EW)
        self.starListWindow.neonEntries.append(new_neon_entry)

        new_dark_entry = mtk.make_Entry(list_frame,
                                        row=list_dim,
                                        column=5,
                                        width=6,
                                        sticky=tk.EW)
        self.starListWindow.darkEntries.append(new_dark_entry)

        new_standard_entry = mtk.make_Entry(list_frame,
                                            row=list_dim,
                                            column=6,
                                            width=10,
                                            sticky=tk.EW)
        if is_standard(star_name):
            new_standard_entry.configure(state=tk.DISABLED)
        self.starListWindow.standardEntries.append(new_standard_entry)

        # Resize star list window
        self.starListWindow = resized_window(self.starListWindow,
                                             self.starListDim, STARL_EN_HG)

        print("New star added successfully")
        return
Exemplo n.º 5
0
    def __init__(self, master=None, mode=MOD, spec_info=None):
        super().__init__(master=master)
        # Mode flags
        self._mode = mode
        if self._mode == MOD:
            self.title("Modify Spectrograph")
            self._specIndex = get_spec_index(spec_info.name)
        elif self._mode == DEL:
            self.title("Delete Spectrograph")
            self._specIndex = get_spec_index(spec_info.name)
        elif self._mode == ADD:
            self.title("Add Spectrograph")
            # Empty spectrograph data entries
            spec_info = SpecInfo("", "", "", "", "")
        else:
            print("Error: invalid mode!")
            self.destroy()
            return

        self.defGeometry = SPEC_WIN_DEF_GEOM
        self.geometry(str(self.defGeometry))
        self.resizable(False, False)
        self.configure(bg=FR_BG)
        self.protocol("WM_DELETE_WINDOW", self.close)

        # Spectrograph data frame
        self.specFrame = tk.Frame(self, bg=FR_BG)
        self.specFrame.pack()

        self.nameLabel = mtk.make_Label(self.specFrame,
                                        text="name:",
                                        sticky=tk.W)
        self.nameEntry = mtk.make_Entry(self.specFrame,
                                        text=spec_info.name,
                                        column=1)
        self.minHLabel = mtk.make_Label(self.specFrame,
                                        text="min_h_pixel:",
                                        row=1,
                                        sticky=tk.W)
        self.minHEntry = mtk.make_Entry(self.specFrame,
                                        text=spec_info.min_h_pixel,
                                        row=1,
                                        column=1)
        self.maxHLabel = mtk.make_Label(self.specFrame,
                                        text="max_h_pixel:",
                                        row=2,
                                        sticky=tk.W)
        self.maxHEntry = mtk.make_Entry(self.specFrame,
                                        text=spec_info.max_h_pixel,
                                        row=2,
                                        column=1)
        self.imageHLabel = mtk.make_Label(self.specFrame,
                                          text="h_image:",
                                          row=3,
                                          sticky=tk.W)
        self.imageHEntry = mtk.make_Entry(self.specFrame,
                                          text=spec_info.h_image,
                                          row=3,
                                          column=1)
        self.rowLabel = mtk.make_Label(self.specFrame,
                                       text="l_row:",
                                       row=4,
                                       sticky=tk.W)
        self.rowEntry = mtk.make_Entry(self.specFrame,
                                       text=spec_info.l_row,
                                       row=4,
                                       column=1)

        if self._mode == MOD:
            self.insertButton = mtk.make_Button(self,
                                                self.mod_spec,
                                                text="Modify Spectrograph",
                                                grid_flag=False,
                                                fill="x",
                                                padx=5)
        elif self._mode == ADD:
            self.insertButton = mtk.make_Button(self,
                                                self.add_spec,
                                                text="Add Spectrograph",
                                                grid_flag=False,
                                                fill="x",
                                                padx=5)
        else:
            self.del_spec()

        return