Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's unclear if wrapping everything in VDOM() worked even before this
- Loading branch information
Showing
1 changed file
with
149 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,156 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"from vdom import VDOM, h1, div, p, b, createComponent\n", | ||
"# marquee is deprecated officially by browsers\n", | ||
"# we're going to create and use it anyway\n", | ||
"marquee = createComponent('marquee')" | ||
], | ||
"outputs": [], | ||
"execution_count": 2, | ||
"metadata": { | ||
"collapsed": false, | ||
"outputHidden": false, | ||
"inputHidden": false | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"from collections import Counter\n", | ||
"\nwinners = Counter()" | ||
], | ||
"outputs": [], | ||
"execution_count": 3, | ||
"metadata": { | ||
"collapsed": false, | ||
"outputHidden": false, | ||
"inputHidden": false | ||
} | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"collapsed": false, | ||
"inputHidden": false, | ||
"outputHidden": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from vdom import VDOM, h1, div, p, b, createComponent\n", | ||
"# marquee is deprecated officially by browsers\n", | ||
"# we're going to create and use it anyway\n", | ||
"marquee = createComponent('marquee')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": { | ||
"collapsed": false, | ||
"inputHidden": false, | ||
"outputHidden": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from collections import Counter\n", | ||
"\nwinners = Counter()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": { | ||
"collapsed": false, | ||
"inputHidden": false, | ||
"outputHidden": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"import secrets\n", | ||
"import time\n", | ||
"\n", | ||
"winner = \"\"\n", | ||
"\n", | ||
"# Each player should pick an emoji that you put into this array\n", | ||
"choices = [\"🥑\", \"🐱\", \"😻\"]\n", | ||
"\n", | ||
"game = display(VDOM(h1('GAMETIME')), display_id=\"game\")\n", | ||
"\n", | ||
"for ii in range(40):\n", | ||
" winner = secrets.choice(choices)\n", | ||
" game.display(\n", | ||
" VDOM(\n", | ||
" marquee(winner, style={ \"fontSize\" : '3em' })\n", | ||
" ),\n", | ||
" update=True\n", | ||
" )\n", | ||
" time.sleep(0.1)\n", | ||
"\n", | ||
"winners[winner] += 1\n", | ||
" \n", | ||
"game.display(VDOM(\n", | ||
" div(\n", | ||
" [\n", | ||
" h1('WINNER ' + winner, style={ \"fontSize\" : '3em' }),\n", | ||
" list(map(lambda i: p(i + ': ' + str(winners[i])), winners))\n", | ||
" ]\n", | ||
" )\n", | ||
"), update=True)" | ||
], | ||
"outputs": [ | ||
"data": { | ||
"application/vdom.v1+json": { | ||
"attributes": {}, | ||
"children": [ | ||
{ | ||
"attributes": { | ||
"style": { | ||
"fontSize": "3em" | ||
} | ||
}, | ||
"children": [ | ||
"WINNER 🥑" | ||
], | ||
"tagName": "h1" | ||
}, | ||
{ | ||
"attributes": {}, | ||
"children": [ | ||
"🥑: 2" | ||
], | ||
"tagName": "p" | ||
}, | ||
{ | ||
"output_type": "display_data", | ||
"data": { | ||
"application/vdom.v1+json": { | ||
"tagName": "div", | ||
"attributes": {}, | ||
"children": [ | ||
{ | ||
"tagName": "h1", | ||
"attributes": { | ||
"style": { | ||
"fontSize": "3em" | ||
} | ||
}, | ||
"children": "WINNER 🐱" | ||
}, | ||
[ | ||
{ | ||
"tagName": "p", | ||
"attributes": {}, | ||
"children": "😻: 1" | ||
}, | ||
{ | ||
"tagName": "p", | ||
"attributes": {}, | ||
"children": "🐱: 1" | ||
} | ||
] | ||
] | ||
}, | ||
"text/plain": [ | ||
"<vdom.core.VDOM at 0x110a86080>" | ||
] | ||
}, | ||
"metadata": {} | ||
"attributes": {}, | ||
"children": [ | ||
"🐱: 2" | ||
], | ||
"tagName": "p" | ||
}, | ||
{ | ||
"attributes": {}, | ||
"children": [ | ||
"😻: 1" | ||
], | ||
"tagName": "p" | ||
} | ||
], | ||
"execution_count": 5, | ||
"metadata": { | ||
"collapsed": false, | ||
"outputHidden": false, | ||
"inputHidden": false | ||
} | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"name": "python3", | ||
"language": "python", | ||
"display_name": "Python 3" | ||
}, | ||
"kernel_info": { | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"name": "python", | ||
"version": "3.6.4", | ||
"mimetype": "text/x-python", | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
], | ||
"tagName": "div" | ||
}, | ||
"pygments_lexer": "ipython3", | ||
"nbconvert_exporter": "python", | ||
"file_extension": ".py" | ||
}, | ||
"nteract": { | ||
"version": "0.7.1" | ||
"text/plain": [ | ||
"<div />" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"import secrets\n", | ||
"import time\n", | ||
"\n", | ||
"winner = \"\"\n", | ||
"\n", | ||
"# Each player should pick an emoji that you put into this array\n", | ||
"choices = [\"🥑\", \"🐱\", \"😻\"]\n", | ||
"\n", | ||
"game = display(h1('GAMETIME'), display_id=\"game\")\n", | ||
"\n", | ||
"for ii in range(40):\n", | ||
" winner = str(secrets.choice(choices))\n", | ||
" game.display(marquee(winner, style={ \"fontSize\" : '3em' }), update=True)\n", | ||
" time.sleep(0.1)\n", | ||
"\n", | ||
"winners[winner] += 1\n", | ||
" \n", | ||
"game.display(\n", | ||
" div(\n", | ||
" h1('WINNER ' + winner, style={ \"fontSize\" : '3em' }),\n", | ||
" *list(map(lambda i: p(i + ': ' + str(winners[i])), winners))\n", | ||
" ), \n", | ||
" update=True\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false, | ||
"inputHidden": false, | ||
"outputHidden": false | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernel_info": { | ||
"name": "python3" | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.3" | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} | ||
"nteract": { | ||
"version": "nteract-on-jupyter@1.6.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |