From a5282afb893abfd891336abe1e57ad7e865dc40b Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Mon, 11 Mar 2024 13:20:01 -0500 Subject: [PATCH 1/3] Fix unusable widgets by disabling coninuous_update --- stellarphot/settings/views.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/stellarphot/settings/views.py b/stellarphot/settings/views.py index dd67d629..ffa4f6e1 100644 --- a/stellarphot/settings/views.py +++ b/stellarphot/settings/views.py @@ -15,7 +15,30 @@ def ui_generator(model): The model to generate the user interface for. """ ui = AutoUi(model) + + # validation is really messy looking right now, so suppress display of + # the validation errors. A green check or red x will still be displayed. ui.show_validation = False + + # By default nullable are not shown at all but it seems much easier for + # the user to understand if they are shown but disabled. ui.show_null = True + + # Set the description to the first sentence of the docstring. The default is + # to use the entire docstring, which is often too long. ui.description = _extract_short_description(model.__doc__) + + # Validation is checked every time a value is changed, and the contents of each + # field are written to the widget if validation passes. In at least one case, + # the "Observatory" model, this is not helpful because the format of lat/lon is + # not necessarily what the user entered. Furthermore, you can't edit the value + # in the widget because it is overwritten every time validation passes. So, for + # now, we will disable this feature by turning continuous update off for most + # fields. + for widget in ui.di_widgets.values(): + try: + widget.continuous_update = False + except AttributeError: + pass + return ui From aacc60b241624ecca296c7a9a3e0b7be68a6f6c1 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Mon, 11 Mar 2024 13:20:32 -0500 Subject: [PATCH 2/3] Update widget viewer notebook for new class name --- autoui_widget_viewer.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoui_widget_viewer.ipynb b/autoui_widget_viewer.ipynb index 8c9f4234..e86e6a15 100644 --- a/autoui_widget_viewer.ipynb +++ b/autoui_widget_viewer.ipynb @@ -39,7 +39,7 @@ " PhotometryApertures, \n", " Exoplanet, \n", " PhotometrySettings, \n", - " PhotometryOptions,\n", + " PhotometryOptionalSettings,\n", " PassbandMap,\n", " SourceLocationSettings,\n", ")\n", @@ -75,7 +75,7 @@ "metadata": {}, "outputs": [], "source": [ - "classes = [Camera, Observatory, PassbandMap, PhotometryApertures, SourceLocationSettings, PhotometryOptions, LoggingSettings]\n", + "classes = [Camera, Observatory, PassbandMap, PhotometryApertures, SourceLocationSettings, PhotometryOptionalSettings, LoggingSettings]\n", "\n", "uis = [ui_generator(c) for c in classes]\n", "\n", From f57ac2fcd30b2e837e4e4768627f442b4bec3020 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Mon, 11 Mar 2024 14:09:20 -0500 Subject: [PATCH 3/3] Change logic when setting continuous_update --- stellarphot/settings/views.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stellarphot/settings/views.py b/stellarphot/settings/views.py index ffa4f6e1..3d0b36b8 100644 --- a/stellarphot/settings/views.py +++ b/stellarphot/settings/views.py @@ -36,9 +36,7 @@ def ui_generator(model): # now, we will disable this feature by turning continuous update off for most # fields. for widget in ui.di_widgets.values(): - try: + if hasattr(widget, "continuous_update"): widget.continuous_update = False - except AttributeError: - pass return ui