From 65f4133b2c04c58e495bd6bd31860a59c62b01b5 Mon Sep 17 00:00:00 2001 From: Gabriel Selzer Date: Thu, 8 Sep 2022 11:37:33 -0500 Subject: [PATCH] Restrict settings order in popup Due to the way confuse maintains settings changes, we can get different settings orderings in the popup as a function of the previous edits made. By editing over the settings present in the DEFAULT source (src/napari-imagej/config-default.yaml), we get two nice effects: 1. Settings will always appear in the order listed in the default configuration file 2. Defined settings that are NOT in the default configuration file are not listed in this popup. This could happen if the user hacked their own configuration, for example. Unfortunately, this does not fix the way that settings changes are dumped into the user's settings. Thus the settings can still appear out of order in the user's file. More work needed on that one... --- src/napari_imagej/widgets/menu.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/napari_imagej/widgets/menu.py b/src/napari_imagej/widgets/menu.py index ca684cbb..f27bea94 100644 --- a/src/napari_imagej/widgets/menu.py +++ b/src/napari_imagej/widgets/menu.py @@ -305,16 +305,17 @@ def __init__(self, viewer: Viewer): def _update_settings(self): args = {} - for k, v in settings.items(): + default_source = next(s for s in settings.sources if s.default) + for k, v in default_source.items(): args[k] = {} - args[k]["value"] = v.get() + args[k]["value"] = settings[k].get() choices = request_values(title="napari-imagej Settings", values=args) if choices is not None: any_changed = False for k, v in choices.items(): if v != settings[k].get(): any_changed = True - settings[k].set(v) + settings[k] = v if any_changed: self.setting_change.emit()