Skip to content

Commit

Permalink
Create and use a custom BoundedIntText
Browse files Browse the repository at this point in the history
This is used for the aperture settings fields to ensure a lower bound in
the UI.
  • Loading branch information
mwcraig committed Aug 10, 2023
1 parent 54898cb commit cd28d0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions stellarphot/settings/autowidgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Some classes for ipyautoui that really belong there, not here

import ipywidgets as w
from ipyautoui.autowidgets import create_widget_caller


class CustomBoundedIntTex(w.BoundedIntText):
def __init__(self, schema):
self.schema = schema
self.caller = create_widget_caller(schema)
super().__init__(**self.caller)
8 changes: 4 additions & 4 deletions stellarphot/settings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

from pydantic import BaseModel, Field

from .autowidgets import CustomBoundedIntTex

class ApertureUnit(Enum):
PIXEL = un.pix
ARCSEC = un.arcsec


class ApertureSettings(BaseModel):
radius : float
inner_annulus : float
outer_annulus : float
unit : ApertureUnit = Field(default=ApertureUnit.PIXEL, enum=[au.value for au in ApertureUnit])
radius : conint(ge=1) = Field(autoui=CustomBoundedIntTex)
inner_annulus : conint(ge=1) = Field(autoui=CustomBoundedIntTex)
outer_annulus : conint(ge=1) = Field(autoui=CustomBoundedIntTex)

class Config:
use_enum_values = True
Expand Down

0 comments on commit cd28d0c

Please sign in to comment.