Source code for GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameDBInteractions.FrameReload
"""
FrameReload module: maintenance buttons for the DB and Data Interactions tab.
Provides two on-demand actions:
- Reload Targets: re-scan the targets folder and refresh the Target dropdown in
every panel.
- Reload Opacities: re-scan the petitRADTRANS opacity folders and rebuild the
molecule/isotope/opacity dropdowns in the retrieval Parameters panel and the
Forward Model panel.
Both delegate to InputPanel so the cascade/rebuild logic lives in a single place.
"""
from tkinter import messagebox
from GUIBRUSHR.GUI.LAYOUT.MyPanel import MyPanel
from GUIBRUSHR.GUI.WIDGET.MyButton import MyButton
[docs]
class FrameReload(MyPanel):
"""Panel hosting the Reload Targets / Reload Opacities buttons."""
[docs]
def __init__(self, parent, color, row, column, path_default, frame_input, window, **kwargs):
"""
Initialize the reload panel.
Args:
parent: Parent widget.
color: Color scheme for the panel.
row: Row position in the parent layout.
column: Column position in the parent layout.
path_default: Default path for file operations.
frame_input: The InputPanel container (exposes reload_all_targets /
reload_all_opacities).
window: Main window reference.
**kwargs: Additional keyword arguments for the parent class.
"""
super().__init__(parent, color, row, column, **kwargs)
self.frame_input = frame_input
self.path_default = path_default
self.window = window
self.color = color
self.button_reload_targets = MyButton(
self, 0, 0, "Reload Targets",
bg="#1e4fda", color_panel=color, command=self.reload_targets,
fg="white"
)
self.button_reload_opacities = MyButton(
self, 0, 1, "Reload Opacities",
bg="#1e4fda", color_panel=color, command=self.reload_opacities,
fg="white"
)
[docs]
def reload_targets(self):
"""Refresh the Target dropdown in all panels from disk."""
try:
self.frame_input.reload_all_targets()
messagebox.showinfo("Reload Targets", "Target dropdowns reloaded")
except Exception as e:
print(e)
messagebox.showerror("Reload Targets", "Reload failed")
[docs]
def reload_opacities(self):
"""Rebuild the molecule/opacity dropdowns in all panels from disk."""
try:
self.frame_input.reload_all_opacities()
messagebox.showinfo("Reload Opacities", "Opacity dropdowns reloaded")
except Exception as e:
print(e)
messagebox.showerror("Reload Opacities", "Reload failed")