# -*- coding: utf-8 -*- # pip install import numpy as np import os import sys import time import traceback import functools paths = ["../../src"] paths.append("../../../guitastro_device_ascomcam/src") paths.append("../../../guitastro_device_dfm/src") for path in paths: if path not in sys.path: sys.path.insert(0,path) import guitastro from guitastro_device_ascomcam import Device_Ascomcam from guitastro_device_dfm import Device_DFM import tkinter as tk from tkinter import ttk import tkinter.font as tkFont import tkinter.messagebox as messageBox import os, sys import time import pickle import yaml import math import numpy as np import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk) # ##################################################################### # ##################################################################### # ##################################################################### # Class Devicepad # ##################################################################### # ##################################################################### # This class provides a pad # ##################################################################### class Devicepad(): """ Pad to drive a device. """ def __init__(self, device): self._device = device self.tkroot = None self._command_history = [] self._command_history.append('self._main') self._command_history_index = 0 # === GUI self.pad_cbk_compute_things_repeated_stop = True self.after_id = None self.pad_gui_create() # gui will block the code here # ========================================== # ========================================== # === pad method repeated regularly to fill infos # ========================================== # ========================================== def pad_cbk_compute_things_repeated(self): """ Compute in one time all the informations to refresh in the pad """ try: # self.pad_var_motion_axis_polar.set(texte) pass except: msg = "{}".format(sys.exc_info()) print(msg) if self.pad_cbk_compute_things_repeated_stop == False: self.after_id = self.tkroot.after(100,self.pad_cbk_compute_things_repeated) # ========================================== # ========================================== # === pad Ra,Dec GOTO # ========================================== # ========================================== # ========================================== # ========================================== # === pad Calibrations Console # ========================================== # ========================================== def pad_cbk_console(self, event): command =self.pad_var_console.get() res = "" try: exec(f"""locals()['temp'] = {command}""") res = locals()['temp'] #exec(f"""globals()['temp'] = {command}""") #res = globals()['temp'] #self.log.print("res={}".format(res)) except Exception as err: res = err #self.log.print("type(res)={}".format(type(res))) #self.log.print("(2) res={}".format(res)) self.text_console.insert(tk.END,command+"\n","command") self.text_console.yview_moveto(1.0) res = "# "+str(res)+"\n" self.text_console.insert(tk.END,res,"result") self.text_console.yview_moveto(1.0) self._command_history.append(command) self._command_history_index = len(self._command_history) command =self.pad_var_console.set("") def pad_cbk_command_prev(self, event): k = self._command_history_index k -= 1 if k>=0: self._command_history_index = k command = self._command_history[k] self.pad_var_console.set(command) self.entry_console.icursor(tk.END) def pad_cbk_command_next(self, event): n = len(self._command_history) k = self._command_history_index k += 1 if k=0: texte += "toward west (increase HA)" else: texte += "toward east (decrease HA)" self.log.print(texte) supertext += texte + "\n" dec = float(ima1.getkwd("DEC")) crval2 = float(ima1.getkwd("CRVAL2")) ddec = crval2 - dec ddec_arcmin = ddec*60.0 texte = f"Mount must be offset by {abs(ddec_arcmin):.1f} arcmin " if ddec_arcmin<0: texte += "toward north (decrease Dec)" else: texte += "towoard south (increase Dec)" self.log.print(texte) supertext += texte self.text_calibwcs_res.insert(tk.END,supertext+"\n","blue") texte = f"Centre RA,Dec = {guitastro.Angle(crval1).sexagesimal('H:0.2')} {guitastro.Angle(crval2).sexagesimal('d:+090.1')}" self.log.print(texte) self.text_calibwcs_res.insert(tk.END,texte+"\n","black") x, y = ima1.radec2xy(ra, dec) texte = f"Target ra,dec = {ra:.5f}, {dec:.5f}\n" texte = f"Target x,y = {x:.2f}, {y:.2f}\n" print(texte) if self._visumethod == "guitastro_visu": if self._wcstag != None: self._visu1.clear_marks(self._wcstag) self._wcstag = self._visu1.add_mark("circle",x, y, 7, color='#00FF00') # --- supertext = "" cdelt1 = ima1.getkwd("CDELT1") cdelt2 = ima1.getkwd("CDELT2") naxis1 = ima1.getkwd("NAXIS1") naxis2 = ima1.getkwd("NAXIS2") sampling_base = cdelt1*3600 sampling_pole = cdelt2*3600 fov_base_arcmin = abs(sampling_base*naxis1/60.0) fov_pole_arcmin = abs(sampling_pole*naxis2/60.0) texte = f"Spatial sampling = {abs(sampling_base):.2f} arcsec/pix" supertext += texte + "\n" texte = f"Field of view = {fov_base_arcmin:.2f} x {fov_pole_arcmin:.2f} arcmin" supertext += texte self.text_calibwcs_res.insert(tk.END,supertext+"\n","blue") self.text_calibwcs_res.yview_moveto(1.0) # --- date = guitastro.Date(ima1.getkwd("DATE-OBS")) jd = date.jd() params = {} params["EQUINOX"] = "J2000" ha_target = 0 dec_target = 90 ra_equinox, dec_equinox = self._main.radec_app2cat(jd, ha_target, dec_target, params) x, y = ima1.radec2xy(0, 90) texte = f"Pole x,y = {x:.2f}, {y:.2f}\n" self.text_calibwcs_res.insert(tk.END,texte+"\n","black") try: if self._visumethod == "matplotlib": self.ax1.scatter([x], [y], c = 'yellow', marker = 'o', s=200) # update the plot plt.tight_layout() self.tkroot.update() self.fig1.canvas.draw() else: self._visu1.add_mark("circle",x, y, 5, 'yellow') except: pass else: supertext_intro = "WCS calibration failed\n" self.text_calibwcs_res.insert(tk.END,supertext_intro+"\n","red") self.text_calibwcs_res.yview_moveto(1.0) return valid def pad_cbk_camtemperature(self): cam_infos = self._main.camera_cam.properties() texte = "" CCDTemperature= cam_infos["CCDTemperature"] texte += f"{CCDTemperature:.1f} degC" CanSetCCDTemperature = cam_infos["CanSetCCDTemperature"] CanGetCoolerPower = cam_infos["CanGetCoolerPower"] if CanSetCCDTemperature==True: SetCCDTemperature = cam_infos["SetCCDTemperature"] CoolerOn = cam_infos["CoolerOn"] texte += f" / {SetCCDTemperature:.1f} degC" if CoolerOn==True: texte += " (cooler on)" else: texte += " (cooler off)" else: SetCCDTemperature = None CoolerOn = None if CanGetCoolerPower==True: CoolerPower = cam_infos["CoolerPower"] texte += f" power {CoolerPower:.0f} percent" else: CoolerPower = None self.pad_var_camtemp.set(texte) def pad_cbk_cammodelregu(self): self._cammodel(1) def pad_cbk_cammodelflip(self): self._cammodel(-1) def pad_cbk_cammodel_compute_images(self): if self._visumethod == "matplotlib": self._main.camera_wcs_modpoi("images",(self.tkroot, self.fig1, self.ax1)) else: self._main.camera_wcs_modpoi("images", self._visu1) def pad_cbk_cammodel_compute_pointings(self): if self._visumethod == "matplotlib": self._main.camera_wcs_modpoi("pointings",(self.tkroot, self.fig1, self.ax1)) else: self._main.camera_wcs_modpoi("pointings", self._visu1) def _cammodel(self, side): exp = self.pad_var_camera_exp.get() binning = self.pad_var_camera_bin.get() camdark = self.pad_var_camdark.get() camusedark = self.pad_var_camusedark.get() if camusedark == 1 and camdark != "": fitsdark = camdark else: fitsdark = None if self._visumethod == "matplotlib": self._main.camera_acq_modpoi(exp, binning, side, fitsdark, (self.tkroot, self.fig1, self.ax1)) else: self._main.camera_acq_modpoi(exp, binning, side, fitsdark, self._visu1) def pad_cbk_button_pushed(self, key): print(f"Select command {key=}") device = self._device res = device.commandstring(key) self.pad_var_component[component_name].set(res) # ========================================== # ========================================== # === pad GUI # ========================================== # ========================================== def pad_cbk_quit(self): # --- We can destroy the windows of the gui """ self.pad_cbk_compute_things_repeated_stop = True self.tkroot.after_idle(self.pad_cbk_compute_things_repeated) if self.after_id != None: self.tkroot.after_cancel(self.after_id) """ self.tkroot.quit() self.tkroot.destroy() print("Pad Quit terminated") def pad_gui_create(self): device = self._device self.tkroot = tk.Tk() screen_width = self.tkroot.winfo_screenwidth() screen_height = self.tkroot.winfo_screenheight() max_height = 700 if screen_height>max_height: screen_height = max_height self.tkroot.geometry(str(screen_width)+"x"+str(screen_height)+"+0+0") self.tkroot.title("Device pad for "+ device.param['NAME']) self.tkroot.protocol('WM_DELETE_WINDOW', self.pad_cbk_quit) # Check components msg = "" for component_name in device.component_names: component = device.component(component_name) name = component.name p = component.prop() a = p['actions'] msg += f"\n--- Component {name} actions: {a}\n" for keya in a: if keya in p.keys(): o = p[keya] for keyo, val in o.items(): if isinstance(val, dict): so = val for keyso, val in so.items(): msg += f" * Operation {keya} {keyo} {keyso} = {val}\n" else: msg += f" * Operation {keya} {keyo} = {val}\n" #print(f"{msg=}") fontStyle_1 = tkFont.Font(family="Arial", size=14, weight="bold") fontStyle_2 = tkFont.Font(family="Arial", size=12, weight="bold") fontStyle_3 = tkFont.Font(family="Arial", size=10, weight="bold") fontStyle_c3 = tkFont.Font(family="courier", size=10, weight="bold") # ===================================================== # === All the tabs are in a X scrollable frame # ===================================================== superframe = ttk.Frame(self.tkroot) supercanvas = tk.Canvas(superframe) superscrollbar = ttk.Scrollbar(superframe, orient="horizontal", command=supercanvas.xview) superscrollable_frame = ttk.Frame(supercanvas) superscrollable_frame.bind("", lambda e: supercanvas.configure(scrollregion=supercanvas.bbox("all"))) supercanvas.create_window((0, 0), window=superscrollable_frame, anchor="nw") supercanvas.configure(xscrollcommand=superscrollbar.set) # ===================================================== # ===================================================== # (100) Frame Pilot # ===================================================== # ===================================================== frame_pilot = tk.Frame(superscrollable_frame) notebook = ttk.Notebook(frame_pilot) tabs = {} kcomps = [] for kcomp in range(101, 101+len(device.component_names), 1): kcomps.append(kcomp) # ===================================================== # Tab 1xx # ===================================================== frame = {} button = {} label = {} entry = {} self.pad_var_component = {} for kcomp, component_name in zip(kcomps, device.component_names): tabs[kcomp] = ttk.Frame(notebook) component = device.component(component_name) # --- frame[kcomp] = tk.Frame(tabs[kcomp]) # --- name = component.name p = component.prop() a = p['actions'] for keya in a: if keya in p.keys(): o = p[keya] for keyo, val in o.items(): if isinstance(val, dict): so = val for keyso, val in so.items(): msg = f"{val}" key = f"{keya}_{keyo}_{keyso}" cmd = f"{component_name} {keya} {keyo} {keyso}" lab_comp_key = str(kcomp) + "_" + key frame_tmp = tk.Frame(frame[kcomp]) button[lab_comp_key] = tk.Button(frame_tmp, text = key, command=functools.partial(self.pad_cbk_button_pushed, cmd), font=fontStyle_3) button[lab_comp_key].pack(side = tk.LEFT) label[lab_comp_key] = tk.Label(frame_tmp, text = msg, font=fontStyle_3) label[lab_comp_key].pack(side = tk.LEFT) frame_tmp.pack(side = tk.TOP, anchor = tk.W) else: msg = f"{val}" key = f"{keya}_{keyo}" cmd = f"{component_name} {keya} {keyo}" lab_comp_key = str(kcomp) + "_" + key frame_tmp = tk.Frame(frame[kcomp]) button[lab_comp_key] = tk.Button(frame_tmp, text = key, command=functools.partial(self.pad_cbk_button_pushed, cmd), font=fontStyle_3) button[lab_comp_key].pack(side = tk.LEFT) label[lab_comp_key] = tk.Label(frame_tmp, text = msg, font=fontStyle_3) label[lab_comp_key].pack(side = tk.LEFT) frame_tmp.pack(side = tk.TOP, anchor = tk.W) self.pad_var_component[component_name] = tk.StringVar() self.pad_var_component[component_name].set("") lab_comp_key = component_name frame_tmp = tk.Frame(frame[kcomp]) label[lab_comp_key] = tk.Label(frame_tmp, text = "Result", font=fontStyle_3) label[lab_comp_key].pack(side = tk.LEFT) entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_component[component_name], font=fontStyle_3) entry[lab_comp_key].pack(side = tk.LEFT) frame_tmp.pack(side = tk.TOP, anchor = tk.W) if component.category == 'SensorDetector': # --- val = component.command("GET", "exptime") lab_comp_key = str(kcomp) + "_exptime" self.pad_var_exptime = tk.DoubleVar() self.pad_var_exptime.set(1.2) frame_tmp = tk.Frame(frame[kcomp]) label[lab_comp_key] = tk.Label(frame_tmp, text = "Exptime", font=fontStyle_3) label[lab_comp_key].pack(side = tk.LEFT) entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_exptime, font=fontStyle_3) entry[lab_comp_key].pack(side = tk.LEFT) frame_tmp.pack(side = tk.TOP, anchor = tk.W) # --- val = component.command("GET", "binning") lab_comp_key = str(kcomp) + "_binning" self.pad_var_binning = tk.StringVar() self.pad_var_binning.set([1, 1]) frame_tmp = tk.Frame(frame[kcomp]) label[lab_comp_key] = tk.Label(frame_tmp, text = "Binning", font=fontStyle_3) label[lab_comp_key].pack(side = tk.LEFT) entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_binning, font=fontStyle_3) entry[lab_comp_key].pack(side = tk.LEFT) frame_tmp.pack(side = tk.TOP, anchor = tk.W) if component.category == 'MountPointing': # --- val = component.command("GET", "target") lab_comp_key = str(kcomp) + "_target" self.pad_var_target = tk.StringVar() self.pad_var_target.set("RADEC 6h 30d") frame_tmp = tk.Frame(frame[kcomp]) label[lab_comp_key] = tk.Label(frame_tmp, text = "Target", font=fontStyle_3) label[lab_comp_key].pack(side = tk.LEFT) entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_target, font=fontStyle_3) entry[lab_comp_key].pack(side = tk.LEFT) frame_tmp.pack(side = tk.TOP, anchor = tk.W) if component.category == 'DetectorFocuser': # --- val = component.command("GET", "target") lab_comp_key = str(kcomp) + "_target" self.pad_var_detectorfocuser_target = tk.DoubleVar() self.pad_var_detectorfocuser_target.set("1000") frame_tmp = tk.Frame(frame[kcomp]) label[lab_comp_key] = tk.Label(frame_tmp, text = "Target", font=fontStyle_3) label[lab_comp_key].pack(side = tk.LEFT) entry[lab_comp_key] = tk.Entry(frame_tmp, textvariable = self.pad_var_detectorfocuser_target, font=fontStyle_3) entry[lab_comp_key].pack(side = tk.LEFT) frame_tmp.pack(side = tk.TOP, anchor = tk.W) frame[kcomp].pack(side = tk.TOP, pady=5) # ===================================================== # Pack frame pilot # ===================================================== for kcomp, component_name in zip(kcomps, device.component_names): component = device.component(component_name) notebook.add(tabs[kcomp], text=component_name) notebook.pack(fill = tk.BOTH) frame_pilot.pack(fill = tk.Y, side = tk.LEFT, anchor=tk.NW) # ===================================================== # ===================================================== # (200) Frame camera # ===================================================== # ===================================================== if False: frame_camera = tk.Frame(superscrollable_frame, width = 500) notebook = ttk.Notebook(frame_camera) tab201 = ttk.Frame(notebook) # ===================================================== # Tab 201 == Load and save FITS images # ===================================================== # === Title frame_tabload_title = tk.Frame(tab201) label_tabload_title = tk.Label(frame_tabload_title, text="Load / save FITS images", font=fontStyle_1) label_tabload_title.pack(side = tk.TOP) frame_tabload_title.pack(side = tk.TOP, pady=5) frame_camload = tk.Frame(tab201) button_camload = tk.Button(frame_camload, text="Load", command=self.pad_cbk_camload, font=fontStyle_3) button_camload.pack(side = tk.LEFT, padx=5) button_camheader = tk.Button(frame_camload, text="Header", command=self.pad_cbk_camheader, font=fontStyle_3) button_camheader.pack(side = tk.LEFT, padx=5) button_camsave = tk.Button(frame_camload, text="Save", command=self.pad_cbk_camsave, font=fontStyle_3) button_camsave.pack(side = tk.LEFT, padx=5) frame_camload.pack(side = tk.TOP, pady=5) tab201.pack() # ===================================================== # Pack notebook camera # ===================================================== notebook.add(tab201, text="Load/Save") notebook.pack(fill = tk.BOTH) # ===================================================== # Pack frame visu # ===================================================== # === Frame of camera visu frame_camvisu = tk.Frame(frame_camera) # --- if True: self._visu1 = guitastro.Visu(frame_camvisu) else: self.tkrootvisu = tk.Toplevel(self.tkroot) screen_width = self.tkrootvisu.winfo_screenwidth() screen_height = self.tkrootvisu.winfo_screenheight() cam_infos = self._main.camera_cam.properties() nbcellx = cam_infos["CameraXSize"] nbcelly = cam_infos["CameraYSize"] framex = 30 framey = 100 ratiox = (screen_width-framex) / nbcellx ratioy = (screen_height-framey) / nbcelly ratiomini = ratioy if ratiox < ratiomini: ratiomini = ratiox if ratiox > 1 and ratioy > 1: width = nbcellx + framex height = nbcelly + framey else: width = nbcellx*ratiox + framex height = nbcelly*ratioy + framey height = int(height) width = int(width) self.tkrootvisu.geometry(str(width)+"x"+str(height)+"+600+200") self.tkrootvisu.title("Visu tool for Mount pad") self.tkrootvisu.protocol('WM_DELETE_WINDOW', self.pad_cbk_quit) self._visu1 = guitastro.Visu(self.tkrootvisu) # --- frame_camvisu.pack(side=tk.BOTTOM, pady=0, expand=tk.YES, fill=tk.BOTH) frame_camera.pack(side=tk.LEFT, anchor=tk.NW, expand=tk.YES, fill=tk.BOTH) frame_camera.pack_propagate(0) # ===================================================== # ===================================================== # (300) Frame processing # ===================================================== # ===================================================== frame_processing = tk.Frame(superscrollable_frame) # self.tkroot notebook = ttk.Notebook(frame_processing) tab301 = ttk.Frame(notebook) tab302 = ttk.Frame(notebook) tab303 = ttk.Frame(notebook) tab304 = ttk.Frame(notebook) # ===================================================== # Tab 301 == Processing Header FITS # ===================================================== # === Title frame_fitsheader_title = tk.Frame(tab301) label_fitsheader_title = tk.Label(frame_fitsheader_title, text="FITS Header", font=fontStyle_1) label_fitsheader_title.pack(side = tk.TOP) frame_fitsheader_title.pack(side = tk.TOP, pady=5) frame_fitsheader_go = tk.Frame(tab301) button_camwcs = tk.Button(frame_fitsheader_go, text="Display FITS header", command=self.pad_cbk_dispheader, font=fontStyle_3) button_camwcs.pack(side = tk.LEFT, padx=5) frame_fitsheader_go.pack(side = tk.TOP, pady=5) frame_fitsheader_disp = tk.Frame(tab301) self.text_fitsheader_res = tk.Text(frame_fitsheader_disp, height=32, wrap="word", font=fontStyle_c3) self.text_fitsheader_res.pack(side = tk.TOP, padx=5, pady=1) self.text_fitsheader_res.tag_config('red', foreground="red") self.text_fitsheader_res.tag_config('blue', foreground="blue") self.text_fitsheader_res.tag_config('black', foreground="black") self.text_fitsheader_res.tag_config('green', foreground="green") frame_fitsheader_disp.pack(side = tk.TOP, pady=5) tab301.pack() # ===================================================== # Tab 302 == Processing WCS calibration # ===================================================== # === Title frame_calibwcs_title = tk.Frame(tab302) label_calibwcs_title = tk.Label(frame_calibwcs_title, text="WCS calibration", font=fontStyle_1) label_calibwcs_title.pack(side = tk.TOP) frame_calibwcs_title.pack(side = tk.TOP, pady=5) frame_calibwcs_go = tk.Frame(tab302) button_camwcs = tk.Button(frame_calibwcs_go, text="Solve WCS", command=self.pad_cbk_camwcs, font=fontStyle_3) button_camwcs.pack(side = tk.LEFT, padx=5) frame_calibwcs_go.pack(side = tk.TOP, pady=5) frame_calibwcs_disp = tk.Frame(tab302) self.text_calibwcs_res = tk.Text(frame_calibwcs_disp, height=32, wrap="word", font=fontStyle_3) self.text_calibwcs_res.pack(side = tk.TOP, padx=5, pady=1) self.text_calibwcs_res.tag_config('red', foreground="red") self.text_calibwcs_res.tag_config('blue', foreground="blue") self.text_calibwcs_res.tag_config('black', foreground="black") self.text_calibwcs_res.tag_config('green', foreground="green") frame_calibwcs_disp.pack(side = tk.TOP, pady=5) tab302.pack() # ===================================================== # Tab 303 == Processing Python console # ===================================================== # === Title frame_pyconsole_title = tk.Frame(tab303) label_pyconsole_title = tk.Label(frame_pyconsole_title, text="Python console", font=fontStyle_1) label_pyconsole_title.pack(side = tk.TOP) frame_pyconsole_title.pack(side = tk.TOP, pady=5) # === Frames of console frame_console = tk.Frame(tab303) self.pad_var_console = tk.StringVar() self.text_console = tk.Text(frame_console, height=35, wrap="word", font=fontStyle_3) self.text_console.pack(side = tk.TOP, padx=5, pady=1) self.text_console.tag_config('command', foreground="red") self.text_console.tag_config('result', foreground="blue") self.entry_console = tk.Entry(frame_console, textvariable=self.pad_var_console, font=fontStyle_3) self.entry_console.pack(side = tk.TOP, padx=5, pady=1, fill="both") self.entry_console.bind("", self.pad_cbk_console) self.entry_console.bind("", self.pad_cbk_command_prev) self.entry_console.bind("", self.pad_cbk_command_next) frame_console.pack(side = tk.BOTTOM, pady=5) tab302.pack() # ===================================================== # Tab 304 == Processing Pointing model # ===================================================== # === Title frame_modpoi_title = tk.Frame(tab304) label_modpoi_title = tk.Label(frame_modpoi_title, text="Pointing model computations", font=fontStyle_1) label_modpoi_title.pack(side = tk.TOP) frame_modpoi_title.pack(side = tk.TOP, pady=5) # === Frame of acq modpoi buttons frame_pmcpt = tk.Frame(tab304) label_pmcpt_title = tk.Label(frame_pmcpt, text="Compute pointing model", font=fontStyle_2) label_pmcpt_title.pack(side = tk.LEFT) button_pmcpt1 = tk.Button(frame_pmcpt, text="from FITS images", command=self.pad_cbk_cammodel_compute_images, font=fontStyle_3) button_pmcpt1.pack(side = tk.LEFT, padx=5) button_pmcpt2 = tk.Button(frame_pmcpt, text="from pointing file", command=self.pad_cbk_cammodel_compute_pointings, font=fontStyle_3) button_pmcpt2.pack(side = tk.LEFT, padx=5) frame_pmcpt.pack(side = tk.TOP, pady=5) tab304.pack() # ===================================================== # Pack frame processing # ===================================================== notebook.add(tab301, text="Header") notebook.add(tab302, text="WCS") notebook.add(tab303, text="Python") notebook.add(tab304, text="Compute model") notebook.pack(fill = tk.Y) frame_processing.pack(side=tk.LEFT, anchor="nw") # ===================================================== # ===================================================== # Event loop # ===================================================== # ===================================================== superframe.pack(fill=tk.BOTH, expand=True) supercanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True) superscrollbar.pack(side=tk.BOTTOM, fill=tk.X) self.tkroot.attributes("-topmost", True) self.tkroot.update() self.tkroot.attributes("-topmost", False) #self.pad_cbk_compute_things_repeated_stop = False #self.pad_cbk_compute_things_repeated() self.tkroot.mainloop() print("Pad mainloop terminated") if __name__ == "__main__": ima = guitastro.Ima() path_products = ima.copy_data2products() site = "GPS 2 E 43 137" # ------------------------ if False: name = "Camera" device = "ASCOM.ASICamera2.Camera" model = "ZWO" serial_number = "12345" description = "Test" dev = Device_Ascomcam("ASCOMCAM", transport="USB", name=name, description=description, model=model, serial_number=serial_number, device=device, site=site) else: dev = Device_DFM("ZADKO", transport="TCP", name="Test mount Zadko", serial_number="#0000") # ------------------------ real = False dev.open(real) # ------------------------ for component_name in dev.component_names: component = dev.component(component_name) if component.category == 'SensorDetector': cam = component # ------------------------ cam.ima.fcontext_create("pad_device", "Pad for Guitastro devices") cam.ima.fcontext = "pad_device" cam.ima.extension = ".fit" rootdir0 = cam.ima.rootdir cam.ima.rootdir = os.path.join(rootdir0, "pad_device") os.makedirs(cam.ima.rootdir, exist_ok=True) print(f"{cam.__repr__()}") # ------------------------ if real == False: import shutil fname_in = os.path.join(cam.ima.rootdir, "..", "..", "data", "m57.fit") fname_out = os.path.join(cam.ima.rootdir, "m57.fit") shutil.copy(fname_in, fname_out) # --- try to catch the Ctrl+C interrupt try: # --- We launch the pad print("Create the pad. Tk Event loop activated.") pad = Devicepad(dev) print("Pad deleted. Tk Event loop stopped") except (KeyboardInterrupt, SystemExit): pass except: raise