Commit 3dd254a4 authored by David Davó's avatar David Davó

getField IntValue working

parent 71d98d91
# IPython widget messaging specification version 2 # IPython widget messaging specification version 2
The model implemented is the Model State v8, for ipywidgets 7.4., @jupyter-widgets/base 1.1., and @jupyter-widgets/controls 1.4.*.
> Largely based on: https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/messages.md > Largely based on: https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/messages.md
> The messaging specification as detailed is riddled with assumptions the IHaskell widget > The messaging specification as detailed is riddled with assumptions the IHaskell widget
...@@ -29,7 +31,7 @@ The initial state must *at least* have the following fields in the `data.state` ...@@ -29,7 +31,7 @@ The initial state must *at least* have the following fields in the `data.state`
- `_view_module_version` - `_view_module_version`
- `_view_name` - `_view_name`
You can see more info on the model state of widgets [here](https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/jupyterwidgetmodels.latest.md). You can see more info on the model state of widgets [here](https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/jupyterwidgetmodels.v8.md).
> Warning!: By default there are two widgets modules: `@jupyter-widgets/controls` and `@jupyter-widgets/base`. > Warning!: By default there are two widgets modules: `@jupyter-widgets/controls` and `@jupyter-widgets/base`.
......
...@@ -281,5 +281,5 @@ nestedObjectLookup :: Value -> [Text] -> Maybe Value ...@@ -281,5 +281,5 @@ nestedObjectLookup :: Value -> [Text] -> Maybe Value
nestedObjectLookup val [] = Just val nestedObjectLookup val [] = Just val
nestedObjectLookup val (x:xs) = nestedObjectLookup val (x:xs) =
case val of case val of
Object o -> maybe Nothing (`nestedObjectLookup` xs) $ HM.lookup x o Object o -> (`nestedObjectLookup` xs) =<< HM.lookup x o
_ -> Nothing _ -> Nothing
...@@ -58,7 +58,7 @@ mkIntSlider = do ...@@ -58,7 +58,7 @@ mkIntSlider = do
instance IHaskellWidget IntSlider where instance IHaskellWidget IntSlider where
getCommUUID = uuid getCommUUID = uuid
comm widget val _ = comm widget val _ =
case nestedObjectLookup val ["sync_data", "value"] of case nestedObjectLookup val ["state", "value"] of
Just (Number value) -> do Just (Number value) -> do
void $ setField' widget IntValue (Sci.coefficient value) void $ setField' widget IntValue (Sci.coefficient value)
triggerChange widget triggerChange widget
......
...@@ -652,10 +652,10 @@ reflect = fromSing ...@@ -652,10 +652,10 @@ reflect = fromSing
-- | A record representing a Widget class from IPython from the controls modules -- | A record representing a Widget class from IPython from the controls modules
defaultControlWidget :: FieldType 'S.ViewName -> FieldType 'S.ModelName -> Rec Attr WidgetClass defaultControlWidget :: FieldType 'S.ViewName -> FieldType 'S.ModelName -> Rec Attr WidgetClass
defaultControlWidget viewName modelName = (ViewModule =:: "@jupyter-widgets/controls") defaultControlWidget viewName modelName = (ViewModule =:: "@jupyter-widgets/controls")
:& (ViewModuleVersion =:: "2.0.0") :& (ViewModuleVersion =:: "1.4.0")
:& (ViewName =:: viewName) :& (ViewName =:: viewName)
:& (ModelModule =:: "@jupyter-widgets/controls") :& (ModelModule =:: "@jupyter-widgets/controls")
:& (ModelModuleVersion =:: "2.0.0") :& (ModelModuleVersion =:: "1.4.0")
:& (ModelName =:: modelName) :& (ModelName =:: modelName)
:& (MsgThrottle =:+ 3) :& (MsgThrottle =:+ 3)
:& (DisplayHandler =:: return ()) :& (DisplayHandler =:: return ())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment