added dict of known types; create correct entries for those

This commit is contained in:
gac-maloja
2023-10-07 20:32:06 +02:00
parent 29b7648cae
commit ebc4f82b39

23
scam.py
View File

@ -25,6 +25,16 @@ ENFORCED_SETTINGS = [
"function"
]
KNOWN_TYPES = {
"threshold": 0.,
"project_axis": 0,
"roi_background": [0]*4,
"roi_signal": [0]*4,
"roi_radial": [0]*4,
"radial_x0": 0,
"radial_y0": 0
}
SCRIPT_NAME = "spectrometer.py"
TITLE = "SCam" if not clargs.show_all_settings else "SCam Expert Mode"
@ -146,6 +156,13 @@ class MainPanel(wx.Panel):
cfg = pipeline.get()
print("current config:", cfg)
# use contents of KNOWN_TYPES to pre-fill cfg
#TODO use setdefault instead?
cfg_o = cfg
cfg_x = KNOWN_TYPES.copy()
cfg_x.update(cfg)
cfg = cfg_x
self.camera = camera = cfg["camera_name"]
self.orig_cfg = cfg
@ -160,6 +177,12 @@ class MainPanel(wx.Panel):
self.entries.update(cfg, name_mapping)
# disable and clear lines added only from KNOWN_TYPES
for i in self.entries.children.values():
if i.name not in cfg_o:
i.disable()
i.clear()
# ensure background name is always set unless there is no background at all
bkg_setting = self.entries["image_background"]
if not bkg_setting.get_state():