Skip to content

Commit

Permalink
Merge pull request #140 from maxfordham/disabled-with-nullable-fix-2
Browse files Browse the repository at this point in the history
💄 🐛 Added disable method to set Nullable state if disabled in schema
  • Loading branch information
ollyhensby authored Mar 22, 2023
2 parents ab9fc3d + 14aeda0 commit 03b8980
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 03b8980

Please sign in to comment.