From ebc4f82b398cc73cd9926a0328fcb64dc7977b38 Mon Sep 17 00:00:00 2001 From: gac-maloja Date: Sat, 7 Oct 2023 20:32:06 +0200 Subject: [PATCH] added dict of known types; create correct entries for those --- scam.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scam.py b/scam.py index 4eecc0e..657b8c7 100755 --- a/scam.py +++ b/scam.py @@ -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():