Skip to content

Commit b871c12

Browse files
committed
Minor wording fixes for custom widget
1 parent c342d06 commit b871c12

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

docs/source/examples/Widget Custom.ipynb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"\n",
3131
"To create a custom widget, you need to define the widget both in the browser and in the Python kernel.\n",
3232
"\n",
33-
"This tutorial shows how to build a simple email widget using the TypeScript widget cookiecutter"
33+
"This tutorial shows how to build a simple email widget using the TypeScript widget cookiecutter: https://github.com/jupyter-widgets/widget-ts-cookiecutter"
3434
]
3535
},
3636
{
@@ -50,7 +50,7 @@
5050
"Next create a conda environment that includes:\n",
5151
"\n",
5252
"1. the latest release of JupyterLab or the classic notebook\n",
53-
"2. [cookiecutter](https://github.com/cookiecutter/cookiecutter), the tool you will use to bootstrap the custom widget\n",
53+
"2. [cookiecutter](https://github.com/cookiecutter/cookiecutter): the tool you will use to bootstrap the custom widget\n",
5454
"3. [NodeJS](https://nodejs.org): the JavaScript runtime you'll use to\n",
5555
" compile the web assets (e.g., TypeScript, CSS) for the custom widget\n",
5656
"\n",
@@ -85,7 +85,7 @@
8585
"cookiecutter https://github.com/jupyter-widgets/widget-ts-cookiecutter\n",
8686
"```\n",
8787
"\n",
88-
"When prompted, enter the desired values like the following for all of the cookiecutter prompts:\n",
88+
"When prompted, enter the desired values as follows:\n",
8989
"\n",
9090
"```bash\n",
9191
"author_name []: Your Name\n",
@@ -98,14 +98,14 @@
9898
"project_short_description [A Custom Jupyter Widget Library]: An Custom Email Widget\n",
9999
"```\n",
100100
"\n",
101-
"Change to the directory the cookiecutter created and list the files.\n",
101+
"Change to the directory the cookiecutter created and list the files:\n",
102102
"\n",
103103
"```bash\n",
104104
"cd ipyemail\n",
105105
"ls\n",
106106
"```\n",
107107
"\n",
108-
"You should see a list like the following.\n",
108+
"You should see a list like the following:\n",
109109
"\n",
110110
"```bash\n",
111111
"appveyor.yml css examples ipyemail.json MANIFEST.in pytest.ini readthedocs.yml setup.cfg src tsconfig.json\n",
@@ -127,7 +127,7 @@
127127
"If you are using JupyterLab:\n",
128128
"\n",
129129
"```bash\n",
130-
"# install the widget manager to display Widgets in the JupyterLab interface\n",
130+
"# install the widget manager to display the widgets in JupyterLab\n",
131131
"jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build\n",
132132
"\n",
133133
"# install the local extension\n",
@@ -161,7 +161,7 @@
161161
"\n",
162162
"![hello-world](./images/custom-widget-hello.png)\n",
163163
"\n",
164-
"The next step will walk you through how to modify the existing code to transform the widget into an email widget."
164+
"The next steps will walk you through how to modify the existing code to transform the widget into an email widget."
165165
]
166166
},
167167
{
@@ -225,8 +225,9 @@
225225
"\n",
226226
"Instead, you must tell it yourself by defining specially named trait attributes, `_view_name`, `_view_module`, and `_view_module_version` (as seen below) and optionally `_model_name` and `_model_module`.\n",
227227
"\n",
228+
"First let's rename `ipyemail/example.py` to `ipyemail/widget.py`.\n",
228229
"\n",
229-
"In `ipyemail/example.py`, replace the example code with the following:\n",
230+
"In `ipyemail/widget.py`, replace the example code with the following:\n",
230231
"\n",
231232
"```python\n",
232233
"from ipywidgets import DOMWidget, ValueWidget, register\n",
@@ -254,13 +255,13 @@
254255
"In `ipyemail/__init__.py`, change the import from:\n",
255256
"\n",
256257
"```python\n",
257-
"from .example import ExampleWidget\n",
258+
"from .widget import ExampleWidget\n",
258259
"```\n",
259260
"\n",
260261
"To:\n",
261262
"\n",
262263
"```python\n",
263-
"from .example import Email\n",
264+
"from .widget import Email\n",
264265
"```"
265266
]
266267
},
@@ -433,15 +434,15 @@
433434
"\n",
434435
"A handle to the widget's default DOM element can be acquired via `this.el`. The `el` property is the DOM element associated with the view.\n",
435436
"\n",
436-
"In `src/widget.ts`, define the `email_input` attribute:\n",
437+
"In `src/widget.ts`, define the `_emailInput` attribute:\n",
437438
"\n",
438439
"```typescript\n",
439440
"export class EmailView extends DOMWidgetView {\n",
440441
" private _emailInput: HTMLInputElement;\n",
441442
"}\n",
442443
"```\n",
443444
"\n",
444-
"Then, add the following logic for the `render`:\n",
445+
"Then, add the following logic for the `render` method:\n",
445446
"\n",
446447
"```typescript\n",
447448
"render: function() { \n",
@@ -503,8 +504,8 @@
503504
"We want to be able to avoid user to write an invalid email address, so we need a validator using traitlets.\n",
504505
"\n",
505506
"```python\n",
506-
"from traitlets import Unicode, Bool, validate, TraitError\n",
507507
"from ipywidgets import DOMWidget, ValueWidget, register\n",
508+
"from traitlets import Unicode, Bool, validate, TraitError\n",
508509
"\n",
509510
"from ._frontend import module_name, module_version\n",
510511
"\n",

0 commit comments

Comments
 (0)