made image_background_enable an enforced setting
This commit is contained in:
46
scam.py
46
scam.py
@ -9,13 +9,16 @@ clargs = parser.parse_args()
|
||||
|
||||
SHOWN_SETTINGS = {
|
||||
"image_background": "Background",
|
||||
"image_background_enable": "image_background_enable",
|
||||
"image_threshold": "image_threshold",
|
||||
"project_axis": "Projection axis",
|
||||
"roi_background": "ROI Background",
|
||||
"roi_signal": "ROI Signal"
|
||||
}
|
||||
|
||||
ENFORCED_SETTINGS = [
|
||||
"image_background_enable"
|
||||
]
|
||||
|
||||
|
||||
import wx
|
||||
|
||||
@ -94,7 +97,12 @@ class MainPanel(wx.Panel):
|
||||
cfg = pc.get_instance_config(instance)
|
||||
print(cfg)
|
||||
|
||||
self.orig_cfg = cfg
|
||||
self.camera = cfg["camera_name"]
|
||||
|
||||
if not clargs.show_all_settings:
|
||||
check_incoming_cfg(cfg)
|
||||
|
||||
self.eb_bkg.Enable()
|
||||
self.btn_print.Enable()
|
||||
self.btn_save.Enable()
|
||||
@ -114,24 +122,48 @@ class MainPanel(wx.Panel):
|
||||
parent.Fit()
|
||||
|
||||
|
||||
def on_print(self, event):
|
||||
new_cfg = self.entries.get()
|
||||
print(new_cfg)
|
||||
old_cfg = pc.get_instance_config(self.instance)
|
||||
def make_cfg(self):
|
||||
cfg = self.entries.get()
|
||||
|
||||
if not clargs.show_all_settings:
|
||||
old_cfg = {k: v for k, v in old_cfg.items() if k in SHOWN_SETTINGS}
|
||||
cfg = check_outgoing_cfg(cfg)
|
||||
|
||||
return cfg
|
||||
|
||||
|
||||
def on_print(self, event):
|
||||
new_cfg = self.make_cfg()
|
||||
|
||||
old_cfg = self.orig_cfg
|
||||
if not clargs.show_all_settings:
|
||||
old_cfg = {k: v for k, v in old_cfg.items() if k in list(SHOWN_SETTINGS) + ENFORCED_SETTINGS}
|
||||
|
||||
print("old config:", old_cfg)
|
||||
print("new config:", new_cfg)
|
||||
print("unchanged" if old_cfg == new_cfg else "changed")
|
||||
|
||||
|
||||
def on_save_cfg(self, event):
|
||||
new_cfg = self.entries.get()
|
||||
new_cfg = self.make_cfg()
|
||||
res = pc.set_instance_config(self.instance, new_cfg)
|
||||
print(res)
|
||||
|
||||
|
||||
|
||||
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("'", '"')
|
||||
print(f"Warning: found: image_background_enable = {printable_bkg_enable}, this will be set to None or \"passive\" upon saving")
|
||||
|
||||
|
||||
def check_outgoing_cfg(cfg):
|
||||
bkg = cfg["image_background"]
|
||||
cfg["image_background_enable"] = "passive" if bkg else None
|
||||
return cfg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
app = wx.App()
|
||||
|
Reference in New Issue
Block a user