diff --git a/scam.py b/scam.py index 5872172..6719d6d 100755 --- a/scam.py +++ b/scam.py @@ -9,14 +9,15 @@ clargs = parser.parse_args() SHOWN_SETTINGS = { "image_background": "Background", - "image_threshold": "image_threshold", + "threshold": "Threshold", "project_axis": "Projection axis", "roi_background": "ROI Background", "roi_signal": "ROI Signal" } ENFORCED_SETTINGS = [ - "image_background_enable" + "image_background_enable", + "image_threshold" ] @@ -111,6 +112,9 @@ class MainPanel(wx.Panel): self.entries.update(cfg) else: filtered_cfg = {k: v for k, v in cfg.items() if k in SHOWN_SETTINGS} + for k in SHOWN_SETTINGS: + if k not in filtered_cfg: + filtered_cfg[k] = None self.entries.update(filtered_cfg, SHOWN_SETTINGS) self._adjust_size() @@ -153,16 +157,32 @@ class MainPanel(wx.Panel): def check_incoming_cfg(cfg): bkg_enable = cfg.get("image_background_enable") if bkg_enable not in (None, "passive"): - printable_bkg_enable = repr(bkg_enable).replace("'", '"') + printable_bkg_enable = printable(bkg_enable) print(f"Warning: found: image_background_enable = {printable_bkg_enable}, this will be set to None or \"passive\" upon saving") + img_thresh = cfg.get("image_threshold") + if img_thresh is not None: + printable_img_thresh = printable(img_thresh) + print(f"Warning: found: image_threshold = {printable_img_thresh}, this will be set to None upon saving") + + thresh = cfg.get("threshold") + if thresh is None: + print(f"Warning: found: threshold = None, will overwrite with value of image_threshold ({printable_img_thresh})") + def check_outgoing_cfg(cfg): bkg = cfg["image_background"] cfg["image_background_enable"] = "passive" if bkg else None + + cfg["image_threshold"] = None + return cfg +def printable(val): + return repr(val).replace("'", '"') + +