made function (i.e., script name) enforced; clear entries on error
This commit is contained in:
13
scam.py
13
scam.py
@ -18,9 +18,12 @@ SHOWN_SETTINGS = {
|
||||
|
||||
ENFORCED_SETTINGS = [
|
||||
"image_background_enable",
|
||||
"image_threshold"
|
||||
"image_threshold",
|
||||
"function"
|
||||
]
|
||||
|
||||
SCRIPT_NAME = "spectrometer.py"
|
||||
|
||||
|
||||
|
||||
import itertools
|
||||
@ -97,6 +100,8 @@ class MainPanel(wx.Panel):
|
||||
|
||||
|
||||
def on_select(self, event):
|
||||
self.entries.clear()
|
||||
|
||||
self.instance = instance = self.cb_pls.GetValue()
|
||||
cfg = pc.get_instance_config(instance)
|
||||
print(cfg)
|
||||
@ -167,12 +172,18 @@ def check_incoming_cfg(cfg):
|
||||
if thresh is None:
|
||||
print(f"Warning: found: threshold = None, will overwrite with value of image_threshold ({printable_img_thresh})")
|
||||
|
||||
script = cfg.get("function")
|
||||
if script != SCRIPT_NAME:
|
||||
printable_script = printable(script)
|
||||
print(f"Warning: found: function = {printable_script}, this will be set to \"{SCRIPT_NAME}\" upon saving")
|
||||
|
||||
|
||||
def check_outgoing_cfg(cfg):
|
||||
bkg = cfg["image_background"]
|
||||
cfg["image_background_enable"] = "passive" if bkg else None
|
||||
|
||||
cfg["image_threshold"] = None
|
||||
cfg["function"] = SCRIPT_NAME
|
||||
|
||||
return cfg
|
||||
|
||||
|
@ -15,7 +15,6 @@ class SettingsList(wx.GridSizer):
|
||||
if names is None:
|
||||
names = {}
|
||||
|
||||
self.clear()
|
||||
for k, v in sorted(cfg.items()):
|
||||
n = names.get(k, k)
|
||||
self.add(k, n, v)
|
||||
|
Reference in New Issue
Block a user