{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Hello Jupyter Notebook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Installing jupyter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "My system has Python 3.7.4 installed under Windows 10.  I followed the directions for [Installing Jupyter Notebook](https://test-jupyter.readthedocs.io/en/latest/install.html) via command line:\n",
    "\n",
    "* *pip install jupyter*\n",
    "\n",
    "Then running via command line:\n",
    "\n",
    "* *jupyter notebook*\n",
    "\n",
    "Jupyter Notebook then lauched successfully.  Next:  [Running the Notebook](https://test-jupyter.readthedocs.io/en/latest/running.html#running)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Running the notebook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I created this *HelloJupyterNotebook* page and then loaded the *x3d* package into Pythonas follows."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Loading x3d package"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x3d package loaded, have fun with X3D Graphics!\n"
     ]
    }
   ],
   "source": [
    "import x3d"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Since the x3d.py package is experimental, successful loading is confirmed by the message above."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Creating an X3D model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following model fragment demonstrates an X3D model running in jupyter notebook.  Note that each of the X3D nodes and statements are namespaced with the prefix *x3d.*  Also note that field names are not prefixed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "import x3d\n",
    "\n",
    "newModel = x3d.X3D(\n",
    "    head=x3d.head(children=[\n",
    "        x3d.component(name='Core',level=2),\n",
    "        x3d.unit(),\n",
    "        x3d.meta(name='title',content='HelloJupyterNotebook.py')]),\n",
    "    Scene=x3d.Scene(children=[\n",
    "        x3d.WorldInfo(),\n",
    "        x3d.Group()]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Showing an error"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here is an intentional error forcing a Python TypeError, thus showing that the notebook is active."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'X3D' and 'int'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-13-eaf770075e07>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnewModel\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'X3D' and 'int'"
     ]
    }
   ],
   "source": [
    "newModel + 2;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "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.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
