Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
783bcb94
Commit
783bcb94
authored
Oct 06, 2015
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:gibiansky/IHaskell
parents
89ba1ded
0a3a8995
Changes
20
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
336 additions
and
2193 deletions
+336
-2193
ihaskell-plot.cabal
ihaskell-display/ihaskell-plot/ihaskell-plot.cabal
+1
-0
Bool Widgets.ipynb
...kell-display/ihaskell-widgets/Examples/Bool Widgets.ipynb
+28
-58
Box Widgets.ipynb
ihaskell-display/ihaskell-widgets/Examples/Box Widgets.ipynb
+118
-259
Image Widget.ipynb
...kell-display/ihaskell-widgets/Examples/Image Widget.ipynb
+6
-0
Introduction to Widgets.ipynb
...y/ihaskell-widgets/Examples/Introduction to Widgets.ipynb
+32
-768
Numeric Widgets.ipynb
...l-display/ihaskell-widgets/Examples/Numeric Widgets.ipynb
+19
-39
Output Widget.ipynb
...ell-display/ihaskell-widgets/Examples/Output Widget.ipynb
+9
-760
Plotting UI.ipynb
ihaskell-display/ihaskell-widgets/Examples/Plotting UI.ipynb
+33
-109
Selection Widgets.ipynb
...display/ihaskell-widgets/Examples/Selection Widgets.ipynb
+14
-105
String Widgets.ipynb
...ll-display/ihaskell-widgets/Examples/String Widgets.ipynb
+22
-40
MsgSpec.md
ihaskell-display/ihaskell-widgets/MsgSpec.md
+9
-18
ihaskell-widgets.cabal
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
+1
-1
Widgets.hs
...-display/ihaskell-widgets/src/IHaskell/Display/Widgets.hs
+3
-4
Valid.hs
...askell-widgets/src/IHaskell/Display/Widgets/Bool/Valid.hs
+4
-4
PlaceProxy.hs
...ll-widgets/src/IHaskell/Display/Widgets/Box/PlaceProxy.hs
+4
-5
Proxy.hs
...haskell-widgets/src/IHaskell/Display/Widgets/Box/Proxy.hs
+3
-3
Common.hs
...y/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
+3
-3
Singletons.hs
...askell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
+1
-1
Types.hs
...ay/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
+15
-14
IPython.hs
src/IHaskell/IPython.hs
+11
-2
No files found.
ihaskell-display/ihaskell-plot/ihaskell-plot.cabal
View file @
783bcb94
...
...
@@ -61,6 +61,7 @@ library
build-depends: base >=4.6 && <4.9,
plot,
bytestring,
hmatrix >= 0.10 && <0.17,
ihaskell >= 0.6.2
-- Directories containing source files.
...
...
ihaskell-display/ihaskell-widgets/Examples/Bool Widgets.ipynb
View file @
783bcb94
...
...
@@ -22,13 +22,14 @@
},
{
"cell_type": "code",
"execution_count":
1
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"{-# LANGUAGE FlexibleContexts #-}\n",
"import IHaskell.Display.Widgets\n",
"import Data.Text (pack, unpack)\n",
"import Text.Printf (printf)"
...
...
@@ -43,18 +44,20 @@
},
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"-- C
onstructors
\n",
"-- C
heck box
\n",
"chk <- mkCheckBox\n",
"\n",
"-- Toggle button\n",
"tgb <- mkToggleButton\n",
"\n",
"--
For demonstration
\n",
"
o <- mkHTML
Widget"
"--
Valid widget: Displaying booleans conveniently
\n",
"
vld <- mkValid
Widget"
]
},
{
...
...
@@ -66,16 +69,16 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"-- Display\n",
"-- Display
the widgets
\n",
"chk\n",
"tgb\n",
"
o
"
"
vld
"
]
},
{
...
...
@@ -87,38 +90,23 @@
},
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"setField chk Description \"Bool 1: \"\n",
"setField tgb Description \"Bool 2\"\n",
"\n",
"-- Helper function\n",
"refresh b =\n",
" let stat = if b then \"green\" else \"red\"\n",
" fmt = \"<div style=\\\"background:%s;color:#ffffff\\\"><b>%s</b></div>\"\n",
" in setField o StringValue $ pack $ printf fmt stat (show b)\n",
"\n",
" -- Cosmetic changes\n",
"setField o Description \"Bool 1 && Bool 2\"\n",
"setField o Padding 10\n",
"setField vld Description \"Bool 1 && Bool 2\"\n",
"\n",
" -- And (&&) the two values, and send output to html widget\n",
"setHandler w = setField w ChangeHandler $ do\n",
" b1 <- getField chk BoolValue\n",
" b2 <- getField tgb BoolValue\n",
"
refresh
(b1 && b2)\n",
"
setField vld BoolValue
(b1 && b2)\n",
"\n",
"setHandler chk\n",
"setHandler tgb"
...
...
@@ -142,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -163,19 +151,11 @@
},
{
"cell_type": "code",
"execution_count":
6
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"sign <- mkCheckBox\n",
"bits <- replicateM 7 mkToggleButton\n",
...
...
@@ -195,19 +175,11 @@
},
{
"cell_type": "code",
"execution_count":
7
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"box <- mkFlexBox\n",
"out <- mkHTMLWidget\n",
...
...
@@ -248,19 +220,11 @@
},
{
"cell_type": "code",
"execution_count":
8
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import Control.Arrow (first, second)\n",
"\n",
...
...
@@ -295,6 +259,12 @@
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.2"
}
},
"nbformat": 4,
...
...
ihaskell-display/ihaskell-widgets/Examples/Box Widgets.ipynb
View file @
783bcb94
This diff is collapsed.
Click to expand it.
ihaskell-display/ihaskell-widgets/Examples/Image Widget.ipynb
View file @
783bcb94
...
...
@@ -104,6 +104,12 @@
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.2"
}
},
"nbformat": 4,
...
...
ihaskell-display/ihaskell-widgets/Examples/Introduction to Widgets.ipynb
View file @
783bcb94
This diff is collapsed.
Click to expand it.
ihaskell-display/ihaskell-widgets/Examples/Numeric Widgets.ipynb
View file @
783bcb94
...
...
@@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count":
1
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -46,9 +46,9 @@
},
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
null
,
"metadata": {
"collapsed":
tru
e
"collapsed":
fals
e
},
"outputs": [],
"source": [
...
...
@@ -58,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -77,19 +77,11 @@
},
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"setField bit MaxInt 20\n",
"setField bit MinInt 10\n",
...
...
@@ -119,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -131,7 +123,7 @@
},
{
"cell_type": "code",
"execution_count":
6
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -143,21 +135,11 @@
},
{
"cell_type": "code",
"execution_count":
7
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(25,75)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"getField irs IntPairValue"
]
...
...
@@ -178,7 +160,7 @@
},
{
"cell_type": "code",
"execution_count":
8
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -190,19 +172,11 @@
},
{
"cell_type": "code",
"execution_count":
9
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"setField inp IntValue 42"
]
...
...
@@ -213,6 +187,12 @@
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.2"
}
},
"nbformat": 4,
...
...
ihaskell-display/ihaskell-widgets/Examples/Output Widget.ipynb
View file @
783bcb94
This diff is collapsed.
Click to expand it.
ihaskell-display/ihaskell-widgets/Examples/Plotting UI.ipynb
View file @
783bcb94
...
...
@@ -13,13 +13,14 @@
},
{
"cell_type": "code",
"execution_count":
1
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"{-# LANGUAGE OverloadedStrings #-}\n",
"{-# LANGUAGE FlexibleContexts #-}\n",
"import IHaskell.Display.Widgets"
]
},
...
...
@@ -32,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -83,19 +84,11 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import Data.IORef\n",
"import Graphics.Rendering.Chart.Easy hiding (tan)\n",
...
...
@@ -164,19 +157,11 @@
},
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"divBox <- mkFlexBox\n",
"setField divBox Orientation HorizontalOrientation\n",
...
...
@@ -204,20 +189,12 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
null
,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"slBox <- mkFlexBox\n",
"\n",
...
...
@@ -244,19 +221,11 @@
},
{
"cell_type": "code",
"execution_count":
6
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"-- The four FlexBox widgets.\n",
"import Control.Monad (replicateM, forM_)\n",
...
...
@@ -302,19 +271,11 @@
},
{
"cell_type": "code",
"execution_count":
7
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"-- A FlexBox with ToggleButtons\n",
"buttonBox <- mkFlexBox\n",
...
...
@@ -339,19 +300,11 @@
},
{
"cell_type": "code",
"execution_count":
8
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import Control.Arrow (first, second)\n",
"\n",
...
...
@@ -384,19 +337,11 @@
},
{
"cell_type": "code",
"execution_count":
9
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"setField tlBox Children $ map ChildWidget $ boxes ++ [buttonBox] ++ rangeBoxes"
]
...
...
@@ -410,19 +355,11 @@
},
{
"cell_type": "code",
"execution_count":
10
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"setField tlBox Titles [\"Plot title\", \"X-Label\", \"Y-Label\", \"Grid\", \"X-range\", \"Y-range\"]"
]
...
...
@@ -436,19 +373,11 @@
},
{
"cell_type": "code",
"execution_count":
11
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"let syncVal widget value fieldGetter = readIORef plotState >>= setField widget value . fieldGetter\n",
" in do\n",
...
...
@@ -478,7 +407,7 @@
},
{
"cell_type": "code",
"execution_count":
12
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -500,22 +429,11 @@
},
{
"cell_type": "code",
"execution_count":
13
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"-- Spurious update to display empty plot instead of empty image initially\n",
"update return\n",
...
...
@@ -532,7 +450,7 @@
},
{
"cell_type": "code",
"execution_count":
14
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -543,7 +461,7 @@
},
{
"cell_type": "code",
"execution_count":
15
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -554,7 +472,7 @@
},
{
"cell_type": "code",
"execution_count":
16
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -569,6 +487,12 @@
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.2"
}
},
"nbformat": 4,
...
...
ihaskell-display/ihaskell-widgets/Examples/Selection Widgets.ipynb
View file @
783bcb94
...
...
@@ -22,7 +22,7 @@
},
{
"cell_type": "code",
"execution_count":
1
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -34,7 +34,7 @@
},
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -49,19 +49,11 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"setField msel Description \"Functions to show (One or more)\"\n",
"setField msel Options (OptionLabels [\"sin\", \"cos\"])\n",
...
...
@@ -79,20 +71,12 @@
},
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
null
,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import Graphics.Rendering.Chart.Easy hiding (tan)\n",
"import Graphics.Rendering.Chart.Backend.Cairo\n",
...
...
@@ -140,92 +124,11 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"-- Display the widgets\n",
"msel\n",
...
...
@@ -246,6 +149,12 @@
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.2"
}
},
"nbformat": 4,
...
...
ihaskell-display/ihaskell-widgets/Examples/String Widgets.ipynb
View file @
783bcb94
...
...
@@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count":
1
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -33,7 +33,7 @@
},
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -69,7 +69,7 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -82,7 +82,7 @@
},
{
"cell_type": "code",
"execution_count":
4
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -94,7 +94,7 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -116,7 +116,7 @@
},
{
"cell_type": "code",
"execution_count":
6
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -142,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count":
7
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
...
...
@@ -154,20 +154,12 @@
},
{
"cell_type": "code",
"execution_count":
8
,
"execution_count":
null
,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"-- Some padding\n",
"setField text Padding 5"
...
...
@@ -182,19 +174,11 @@
},
{
"cell_type": "code",
"execution_count":
9
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"setField text Placeholder \"Enter your text here...\"\n",
"setField area Placeholder \"Parsed output will appear here...\""
...
...
@@ -216,7 +200,7 @@
},
{
"cell_type": "code",
"execution_count":
10
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -239,7 +223,7 @@
},
{
"cell_type": "code",
"execution_count":
11
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -300,19 +284,11 @@
},
{
"cell_type": "code",
"execution_count":
12
,
"execution_count":
null
,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"setField text ChangeHandler $ do\n",
" input <- unpack <$> getField text StringValue\n",
...
...
@@ -338,7 +314,7 @@
},
{
"cell_type": "code",
"execution_count":
13
,
"execution_count":
null
,
"metadata": {
"collapsed": true
},
...
...
@@ -354,6 +330,12 @@
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.2"
}
},
"nbformat": 4,
...
...
ihaskell-display/ihaskell-widgets/MsgSpec.md
View file @
783bcb94
...
...
@@ -8,26 +8,17 @@
## Creating widgets
Let's say the user types in some code, and the only effect of that code is the creation of a widget.
The kernel will open a comm for the widget, and store a reference to that comm
inside it. Then, to
notify the frontend about the creation of a widget, an initial state update is sent on the widget's
comm
.
The kernel will open a comm for the widget, and store a reference to that comm
. The comm_open message
also holds the initial state of the widget in it, which is used by the frontend to create a model for
the widget
.
> The comm should be opened with a `target_name` of `"ipython.widget"`.
The initial state update message looks like this:
```
json
{
"method"
:
"update"
,
"state"
:
{
"<some/all widget properties>"
}
}
```
Any
*numeric*
property initialized with the empty string is provided the default value by the
frontend. Some numbers need to be sent as actual numbers (when non-null), whereas
some (especially
those used by sliders)
need to be sent as strings.
frontend. Some numbers need to be sent as actual numbers (when non-null), whereas
the ones representing
lengths in CSS units
need to be sent as strings.
The initial state
update
must
*at least*
have the following fields:
The initial state must
*at least*
have the following fields:
-
`msg_throttle`
(default 3): To prevent the kernel from flooding with messages, the messages from
the widget to the kernel are throttled. If
`msg_throttle`
messages were sent, and all are still
...
...
@@ -43,8 +34,8 @@ The initial state update must *at least* have the following fields:
-
Rest of the properties as required initially.
This state
update is also used with fragments of the overall state to sync changes between the
frontend and
the kernel.
This state
is also used with fragments of the overall state to sync changes between the frontend and
the kernel.
## Displaying widgets
...
...
@@ -111,7 +102,7 @@ If this were not so, the frontend would not be able to determine under which cel
input widget, when an
`input_request`
is received.
Now, widgets cannot send
`execute_request`
messages. They can only send
`comm_data`
messages, which
means that it's not possible to fetch input
through widget event
s.
means that it's not possible to fetch input
inside widget event handler
s.
---
...
...
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
View file @
783bcb94
...
...
@@ -104,7 +104,7 @@ library
, nats -any
, vinyl >= 0.5
, vector -any
, singletons >= 0.9.0
, singletons >= 0.9.0
&& <2.0.0.0
, scientific -any
, unix -any
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets.hs
View file @
783bcb94
...
...
@@ -41,7 +41,6 @@ import IHaskell.Display.Widgets.String.Text as X
import
IHaskell.Display.Widgets.String.TextArea
as
X
import
IHaskell.Display.Widgets.Common
as
X
import
IHaskell.Display.Widgets.Types
as
X
(
setField
,
getField
,
properties
,
triggerDisplay
,
triggerChange
,
triggerClick
,
triggerSelection
,
triggerSubmit
,
ChildWidget
(
..
))
import
IHaskell.Display.Widgets.Types
as
X
(
setField
,
getField
,
properties
,
triggerDisplay
,
triggerChange
,
triggerClick
,
triggerSelection
,
triggerSubmit
,
ChildWidget
(
..
))
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Bool/Valid.hs
View file @
783bcb94
...
...
@@ -4,8 +4,8 @@
{-# LANGUAGE TypeSynonymInstances #-}
module
IHaskell.Display.Widgets.Bool.Valid
(
-- * The Valid Widget
ValidWidget
,
-- * The Valid Widget
ValidWidget
,
-- * Constructor
mkValidWidget
)
where
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/PlaceProxy.hs
View file @
783bcb94
...
...
@@ -3,10 +3,9 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
module
IHaskell.Display.Widgets.Box.PlaceProxy
(
-- * The PlaceProxy widget
PlaceProxy
,
-- * The PlaceProxy widget
PlaceProxy
,
-- * Constructor
mkPlaceProxy
)
where
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Box/Proxy.hs
View file @
783bcb94
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
View file @
783bcb94
...
...
@@ -97,11 +97,11 @@ pattern Selector = S.SSelector
closeWidget
::
IHaskellWidget
w
=>
w
->
IO
()
closeWidget
w
=
widgetSendClose
w
emptyObject
newtype
StrInt
=
StrI
nt
Integer
newtype
PixCount
=
PixCou
nt
Integer
deriving
(
Num
,
Ord
,
Eq
,
Enum
)
instance
ToJSON
StrI
nt
where
toJSON
(
StrInt
x
)
=
toJSON
.
pack
$
show
x
instance
ToJSON
PixCou
nt
where
toJSON
(
PixCount
x
)
=
toJSON
.
pack
$
show
x
++
"px"
-- | Pre-defined border styles
data
BorderStyleValue
=
NoBorder
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
View file @
783bcb94
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
View file @
783bcb94
...
...
@@ -48,8 +48,8 @@ module IHaskell.Display.Widgets.Types where
--
-- The IPython widgets expect state updates of the form {"property": value}, where an empty string
-- for numeric values is ignored by the frontend and the default value is used instead. Some numbers
-- need to be sent as numbers (represented by @Integer@), whereas some
need to be sent as Strings
--
(@StrI
nt@).
-- need to be sent as numbers (represented by @Integer@), whereas some
(css lengths) need to be sent
--
as Strings (@PixCou
nt@).
--
-- Child widgets are expected to be sent as strings of the form "IPY_MODEL_<uuid>", where @<uuid>@
-- represents the uuid of the widget's comm.
...
...
@@ -58,7 +58,7 @@ module IHaskell.Display.Widgets.Types where
-- look at the supplied MsgSpec.md.
--
-- Widgets are not able to do console input, the reason for that can be found in the messaging
-- specification
-- specification
.
import
Control.Monad
(
unless
,
join
,
when
,
void
,
mapM_
)
import
Control.Applicative
((
<$>
))
import
qualified
Control.Exception
as
Ex
...
...
@@ -140,19 +140,19 @@ type family FieldType (f :: Field) :: * where
FieldType
S
.
Visible
=
Bool
FieldType
S
.
CSS
=
[(
Text
,
Text
,
Text
)]
FieldType
S
.
DOMClasses
=
[
Text
]
FieldType
S
.
Width
=
StrI
nt
FieldType
S
.
Height
=
StrI
nt
FieldType
S
.
Padding
=
StrI
nt
FieldType
S
.
Margin
=
StrI
nt
FieldType
S
.
Width
=
PixCou
nt
FieldType
S
.
Height
=
PixCou
nt
FieldType
S
.
Padding
=
PixCou
nt
FieldType
S
.
Margin
=
PixCou
nt
FieldType
S
.
Color
=
Text
FieldType
S
.
BackgroundColor
=
Text
FieldType
S
.
BorderColor
=
Text
FieldType
S
.
BorderWidth
=
StrI
nt
FieldType
S
.
BorderRadius
=
StrI
nt
FieldType
S
.
BorderWidth
=
PixCou
nt
FieldType
S
.
BorderRadius
=
PixCou
nt
FieldType
S
.
BorderStyle
=
BorderStyleValue
FieldType
S
.
FontStyle
=
FontStyleValue
FieldType
S
.
FontWeight
=
FontWeightValue
FieldType
S
.
FontSize
=
StrI
nt
FieldType
S
.
FontSize
=
PixCou
nt
FieldType
S
.
FontFamily
=
Text
FieldType
S
.
Description
=
Text
FieldType
S
.
ClickHandler
=
IO
()
...
...
@@ -220,7 +220,7 @@ class CustomBounded a where
upperBound
::
a
-- Set according to what IPython widgets use
instance
CustomBounded
StrI
nt
where
instance
CustomBounded
PixCou
nt
where
upperBound
=
10
^
16
-
1
lowerBound
=
-
(
10
^
16
-
1
)
...
...
@@ -312,7 +312,8 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
'[
S
.
Orientation
,
S
.
ShowRange
,
S
.
ReadOut
,
S
.
SliderColor
]
WidgetFields
BoxType
=
BoxClass
WidgetFields
ProxyType
=
WidgetClass
:++
'[
S
.
Child
]
WidgetFields
PlaceProxyType
=
WidgetFields
ProxyType
:++
'[
S
.
Selector
]
WidgetFields
PlaceProxyType
=
WidgetFields
ProxyType
:++
'[
S
.
Selector
]
WidgetFields
FlexBoxType
=
BoxClass
:++
'[
S
.
Orientation
,
S
.
Flex
,
S
.
Pack
,
S
.
Align
]
WidgetFields
AccordionType
=
SelectionContainerClass
...
...
src/IHaskell/IPython.hs
View file @
783bcb94
...
...
@@ -72,6 +72,13 @@ ipythonCommand = do
Nothing
->
"ipython"
Just
_
->
"jupyter"
locateIPython
::
SH
.
Sh
SH
.
FilePath
locateIPython
=
do
mbinary
<-
SH
.
which
"ipython"
case
mbinary
of
Nothing
->
SH
.
errorExit
"The IPython binary could not be located"
Just
ipython
->
return
ipython
-- | Run the IPython command with any arguments. The kernel is set to IHaskell.
ipython
::
Bool
-- ^ Whether to suppress output.
->
[
Text
]
-- ^ IPython command line arguments.
...
...
@@ -201,15 +208,17 @@ installKernelspec replace opts = void $ do
src
<-
liftIO
$
Paths
.
getDataFileName
$
"html/"
++
file
SH
.
cp
(
SH
.
fromText
$
T
.
pack
src
)
(
tmp
SH
.</>
kernelName
SH
.</>
file
)
Just
ipython
<-
SH
.
which
"ipython"
ipython
<-
locateIPython
let
replaceFlag
=
[
"--replace"
|
replace
]
installPrefixFlag
=
maybe
[
"--user"
]
(
\
prefix
->
[
"--prefix"
,
T
.
pack
prefix
])
(
kernelSpecInstallPrefix
opts
)
cmd
=
concat
[[
"kernelspec"
,
"install"
],
installPrefixFlag
,
[
SH
.
toTextIgnore
kernelDir
],
replaceFlag
]
SH
.
silently
$
SH
.
run
ipython
cmd
kernelSpecCreated
::
SH
.
Sh
Bool
kernelSpecCreated
=
do
Just
ipython
<-
SH
.
which
"ipython"
ipython
<-
locateIPython
out
<-
SH
.
silently
$
SH
.
run
ipython
[
"kernelspec"
,
"list"
]
let
kernelspecs
=
map
T
.
strip
$
T
.
lines
out
return
$
T
.
pack
kernelName
`
elem
`
kernelspecs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment