Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix observatory widget #284

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autoui_widget_viewer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
" PhotometryApertures, \n",
" Exoplanet, \n",
" PhotometrySettings, \n",
" PhotometryOptions,\n",
" PhotometryOptionalSettings,\n",
" PassbandMap,\n",
" SourceLocationSettings,\n",
")\n",
Expand Down Expand Up @@ -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",
Expand Down
21 changes: 21 additions & 0 deletions stellarphot/settings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,28 @@ 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():
if hasattr(widget, "continuous_update"):
widget.continuous_update = False

return ui