Skip to content

Commit

Permalink
💄 🐛 Added disable method to set Nullable state if disabled in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ollyhensby committed Mar 22, 2023
1 parent c042c7a commit 14aeda0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ipyautoui/autowidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def __init__(self, widget_type, schema, *args, **kwargs):
super().__init__([self.bn, self.widget, self.show_none])
self._init_controls()
self.value = value
self._set_disabled()

def _init_trait(self):
# NOTE: see test for add_traits that demos usage -@jovyan at 7/18/2022, 12:11:39 PM
Expand Down Expand Up @@ -165,6 +166,11 @@ def _toggle_none(self, onchange):
self.show_none.layout.display = "None"
self.value = self.widget.value

def _set_disabled(self):
"""If disabled in schema, set to value defined."""
if "disabled" in self.schema:
self.disabled = self.schema["disabled"]


def nullable(fn, **kwargs):
"""extend a simple widget to allow None
Expand Down

0 comments on commit 14aeda0

Please sign in to comment.