{
  "verso": "1.1",
  "metadata": {
    "title": "A dial the rest of the notebook can read",
    "created": "2026-08-04T00:00:00+00:00",
    "defaultKernel": "python",
    "activeLayout": {
      "extensionId": "verso.layout.notebook",
      "layoutId": "notebook"
    }
  },
  "cells": [
    {
      "id": "00000015-0001-0001-0001-000000000001",
      "type": "markdown",
      "source": "# A dial the rest of the notebook can read\n\nA widget is a control drawn in the browser with a kernel behind it. This one is a\nPython class carrying about eighty lines of JavaScript, and once it exists a single\nline shares its value with every other language in the notebook. A C# cell then reads\nthat value as an ordinary variable, and writing the variable turns the dial.\n\nThis page is a recording of a run, so the dial redraws when you turn it and nobody is\nlistening. Download the notebook for the half that talks back."
    },
    {
      "id": "00000015-0001-0001-0001-000000000002",
      "type": "markdown",
      "source": "## The widget is a Python class\n\nThe trait is the whole interface. \u0060value\u0060 is an ordinary integer traitlet marked to\nsynchronise, and the JavaScript beside it reads and writes that one name. Nothing here\nknows about the notebook yet."
    },
    {
      "id": "00000015-0001-0001-0001-000000000003",
      "type": "code",
      "language": "python",
      "source": "import anywidget\nimport traitlets\n\n\nclass Dial(anywidget.AnyWidget):\n    \u0022\u0022\u0022A round control whose position is an ordinary traitlet.\u0022\u0022\u0022\n\n    value = traitlets.Int(40).tag(sync=True)\n\n    _esm = \u0022\u0022\u0022\nexport default {\n  render({ model, el }) {\n    const SIZE = 176, MID = SIZE / 2, R = 62;\n    const LENGTH = 2 * Math.PI * R, SWEEP = 0.75, SPAN = 270;\n    const NS = \u0022http://www.w3.org/2000/svg\u0022;\n\n    const svg = document.createElementNS(NS, \u0022svg\u0022);\n    svg.setAttribute(\u0022viewBox\u0022, \u00600 0 ${SIZE} ${SIZE}\u0060);\n    svg.setAttribute(\u0022width\u0022, SIZE);\n    svg.setAttribute(\u0022height\u0022, SIZE);\n    svg.setAttribute(\u0022role\u0022, \u0022slider\u0022);\n    svg.setAttribute(\u0022tabindex\u0022, \u00220\u0022);\n    svg.setAttribute(\u0022aria-label\u0022, \u0022Threshold\u0022);\n    svg.setAttribute(\u0022aria-valuemin\u0022, \u00220\u0022);\n    svg.setAttribute(\u0022aria-valuemax\u0022, \u0022100\u0022);\n    svg.style.cssText = \u0022display:block;margin:0 auto;touch-action:none;cursor:grab\u0022;\n\n    function arc(stroke) {\n      const ring = document.createElementNS(NS, \u0022circle\u0022);\n      ring.setAttribute(\u0022cx\u0022, MID);\n      ring.setAttribute(\u0022cy\u0022, MID);\n      ring.setAttribute(\u0022r\u0022, R);\n      ring.setAttribute(\u0022fill\u0022, \u0022none\u0022);\n      ring.setAttribute(\u0022stroke\u0022, stroke);\n      ring.setAttribute(\u0022stroke-width\u0022, \u002213\u0022);\n      ring.setAttribute(\u0022stroke-linecap\u0022, \u0022round\u0022);\n      ring.setAttribute(\u0022transform\u0022, \u0060rotate(135 ${MID} ${MID})\u0060);\n      svg.appendChild(ring);\n      return ring;\n    }\n\n    const track = arc(\u0022var(--verso-border-default, #d6d9df)\u0022);\n    track.setAttribute(\u0022stroke-dasharray\u0022, \u0060${LENGTH * SWEEP} ${LENGTH}\u0060);\n    const filled = arc(\u0022var(--verso-accent-primary, #4f7cff)\u0022);\n\n    const reading = document.createElementNS(NS, \u0022text\u0022);\n    reading.setAttribute(\u0022x\u0022, MID);\n    reading.setAttribute(\u0022y\u0022, MID \u002B 4);\n    reading.setAttribute(\u0022text-anchor\u0022, \u0022middle\u0022);\n    reading.setAttribute(\u0022fill\u0022, \u0022var(--verso-fg-default, #22252b)\u0022);\n    reading.style.cssText = \u0022font:600 36px system-ui,-apple-system,sans-serif\u0022;\n    svg.appendChild(reading);\n\n    const caption = document.createElementNS(NS, \u0022text\u0022);\n    caption.setAttribute(\u0022x\u0022, MID);\n    caption.setAttribute(\u0022y\u0022, MID \u002B 30);\n    caption.setAttribute(\u0022text-anchor\u0022, \u0022middle\u0022);\n    caption.setAttribute(\u0022fill\u0022, \u0022var(--verso-fg-muted, #71767f)\u0022);\n    caption.style.cssText = \u0022font:11px system-ui,sans-serif;letter-spacing:.14em\u0022;\n    caption.textContent = \u0022THRESHOLD\u0022;\n    svg.appendChild(caption);\n\n    function draw() {\n      const value = model.get(\u0022value\u0022);\n      filled.setAttribute(\u0022stroke-dasharray\u0022, \u0060${LENGTH * SWEEP * value / 100} ${LENGTH}\u0060);\n      reading.textContent = value;\n      svg.setAttribute(\u0022aria-valuenow\u0022, value);\n    }\n\n    function set(next) {\n      next = Math.round(Math.min(100, Math.max(0, next)));\n      if (next === model.get(\u0022value\u0022)) return;\n      model.set(\u0022value\u0022, next);\n      model.save_changes();\n    }\n\n    function fromPointer(event) {\n      const box = svg.getBoundingClientRect();\n      const x = event.clientX - box.left - box.width / 2;\n      const y = event.clientY - box.top - box.height / 2;\n      const degrees = Math.atan2(x, -y) * 180 / Math.PI;\n      set((Math.min(SPAN / 2, Math.max(-SPAN / 2, degrees)) \u002B SPAN / 2) / SPAN * 100);\n    }\n\n    svg.addEventListener(\u0022pointerdown\u0022, function (event) {\n      svg.setPointerCapture(event.pointerId);\n      svg.style.cursor = \u0022grabbing\u0022;\n      fromPointer(event);\n    });\n    svg.addEventListener(\u0022pointermove\u0022, function (event) {\n      if (svg.hasPointerCapture(event.pointerId)) fromPointer(event);\n    });\n    svg.addEventListener(\u0022pointerup\u0022, function () { svg.style.cursor = \u0022grab\u0022; });\n    svg.addEventListener(\u0022keydown\u0022, function (event) {\n      const step = { ArrowLeft: -1, ArrowDown: -1, ArrowRight: 1, ArrowUp: 1 }[event.key];\n      if (!step) return;\n      event.preventDefault();\n      set(model.get(\u0022value\u0022) \u002B step * (event.shiftKey ? 10 : 1));\n    });\n\n    model.on(\u0022change:value\u0022, draw);\n    draw();\n    el.appendChild(svg);\n  }\n};\n\u0022\u0022\u0022\n\n\ndial = Dial()\nturned = []\ndial.observe(lambda change: turned.append(change[\u0022new\u0022]), names=\u0022value\u0022)\n\nf\u0022A dial sitting at {dial.value}, with nothing watching it yet.\u0022",
      "outputs": [
        {
          "mimeType": "text/plain",
          "content": "\u0027A dial sitting at 40, with nothing watching it yet.\u0027"
        }
      ]
    },
    {
      "id": "00000015-0001-0001-0001-000000000004",
      "type": "markdown",
      "source": "## One line shares it\n\n\u0060#!bind\u0060 takes an expression naming the object, the trait to follow, and the name to\nshare it under. Nothing about the widget changes; the trait simply becomes a variable\nthe whole notebook can see."
    },
    {
      "id": "00000015-0001-0001-0001-000000000005",
      "type": "code",
      "language": "python",
      "source": "#!bind dial.value as threshold",
      "outputs": [
        {
          "mimeType": "text/plain",
          "content": "\u0027threshold\u0027 now follows dial.value. Any kernel can read it, and writing it moves the widget."
        }
      ]
    },
    {
      "id": "00000015-0001-0001-0001-000000000006",
      "type": "markdown",
      "source": "## C# reads it as a variable\n\nThere is no bridge to write and no message to handle. \u0060threshold\u0060 is in the shared\nvariable store, so C# reads it the way it reads anything else."
    },
    {
      "id": "00000015-0001-0001-0001-000000000007",
      "type": "code",
      "language": "csharp",
      "source": "var cutoff = Variables.Get\u003Clong\u003E(\u0022threshold\u0022);\n\nvar stations = new[]\n{\n    (Station: \u0022Ridgeway\u0022,    Reading: 71),\n    (Station: \u0022Calder Fell\u0022, Reading: 48),\n    (Station: \u0022Ostergaard\u0022,  Reading: 93),\n    (Station: \u0022Pine Hollow\u0022, Reading: 27),\n    (Station: \u0022Bitterroot\u0022,  Reading: 62),\n    (Station: \u0022Kestrel Bay\u0022, Reading: 84),\n};\n\nstations.Where(station =\u003E station.Reading \u003E= cutoff)\n        .Select(station =\u003E new { station.Station, station.Reading })",
      "outputs": [
        {
          "mimeType": "text/html",
          "content": "\u003Cstyle\u003E.verso-obj-tree{--obj-bg:var(--vscode-editor-background,var(--verso-cell-output-background,#fff));--obj-fg:var(--vscode-editor-foreground,var(--verso-cell-output-foreground,#1e1e1e));--obj-border:var(--vscode-editorWidget-border,var(--verso-border-default,#e0e0e0));--obj-header-bg:var(--vscode-editorWidget-background,var(--verso-cell-background,#f5f5f5));--obj-hover:var(--vscode-list-hoverBackground,var(--verso-cell-hover-background,#f0f0f0));--obj-muted:var(--vscode-descriptionForeground,var(--verso-editor-line-number,#858585));--obj-accent:var(--vscode-textLink-foreground,var(--verso-accent-primary,#0078d4));--obj-summary-bg:var(--vscode-sideBar-background,var(--verso-cell-background,#f5f5f5));font-family:var(--verso-code-output-font-family,monospace);font-size:13px;color:var(--obj-fg);}.verso-obj-tree details.verso-obj-node{border:1px solid var(--obj-border);border-radius:3px;margin:2px 0;}.verso-obj-tree details.verso-obj-node\u003Esummary.verso-obj-summary{padding:3px 8px;cursor:pointer;list-style:none;background:var(--obj-summary-bg);display:flex;align-items:center;gap:4px;user-select:none;}.verso-obj-tree details.verso-obj-node\u003Esummary.verso-obj-summary::-webkit-details-marker{display:none;}.verso-obj-tree details.verso-obj-node\u003Esummary.verso-obj-summary::before{content:\u0027\\25B6\u0027;font-size:9px;color:var(--obj-muted);transition:transform 0.1s;}.verso-obj-tree details.verso-obj-node[open]\u003Esummary.verso-obj-summary::before{transform:rotate(90deg);}.verso-obj-tree summary.verso-obj-summary:hover{background:var(--obj-hover);}.verso-obj-tree .verso-obj-type{font-weight:600;color:var(--obj-accent);}.verso-obj-tree .verso-obj-count{color:var(--obj-muted);font-size:11px;}.verso-obj-tree table.verso-obj-table{border-collapse:collapse;width:100%;background:var(--obj-bg);color:var(--obj-fg);}.verso-obj-tree table.verso-obj-table th.verso-obj-th{text-align:left;padding:4px 10px;border-bottom:2px solid var(--obj-border);background:var(--obj-header-bg);font-weight:600;white-space:nowrap;}.verso-obj-tree table.verso-obj-table td.verso-obj-member{padding:3px 10px;border-bottom:1px solid var(--obj-border);color:var(--obj-muted);white-space:nowrap;vertical-align:top;font-size:12px;}.verso-obj-tree table.verso-obj-table td.verso-obj-value{padding:3px 10px;border-bottom:1px solid var(--obj-border);vertical-align:top;}.verso-obj-tree table.verso-obj-table tbody tr:hover{background:var(--obj-hover);}.verso-obj-tree .verso-obj-null{color:var(--obj-muted);font-style:italic;}.verso-obj-tree .verso-obj-cycle{color:var(--obj-muted);font-style:italic;}.verso-obj-tree .verso-obj-empty{color:var(--obj-muted);font-style:italic;}.verso-obj-tree .verso-obj-footer{padding:4px 10px;color:var(--obj-muted);font-size:11px;border-top:1px solid var(--obj-border);}\u003C/style\u003E\u003Cdiv class=\u0022verso-obj-tree\u0022\u003E\u003Cdetails class=\u0022verso-obj-node\u0022 open\u003E\u003Csummary class=\u0022verso-obj-summary\u0022\u003E\u003Cspan class=\u0022verso-obj-type\u0022\u003EWhereSelectArrayIterator\u0026lt;ValueTuple\u0026lt;String, Int32\u0026gt;, \u0026lt;\u0026gt;f__AnonymousType0#2\u0026lt;String, Int32\u0026gt;\u0026gt;\u003C/span\u003E\u003Cspan class=\u0022verso-obj-count\u0022\u003E (5 items)\u003C/span\u003E\u003C/summary\u003E\u003Ctable class=\u0022verso-obj-table\u0022\u003E\u003Cthead\u003E\u003Ctr\u003E\u003Cth class=\u0022verso-obj-th\u0022\u003EStation\u003C/th\u003E\u003Cth class=\u0022verso-obj-th\u0022\u003EReading\u003C/th\u003E\u003C/tr\u003E\u003C/thead\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003ERidgeway\u003C/td\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003E71\u003C/td\u003E\u003C/tr\u003E\u003Ctr\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003ECalder Fell\u003C/td\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003E48\u003C/td\u003E\u003C/tr\u003E\u003Ctr\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003EOstergaard\u003C/td\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003E93\u003C/td\u003E\u003C/tr\u003E\u003Ctr\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003EBitterroot\u003C/td\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003E62\u003C/td\u003E\u003C/tr\u003E\u003Ctr\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003EKestrel Bay\u003C/td\u003E\u003Ctd class=\u0022verso-obj-value\u0022\u003E84\u003C/td\u003E\u003C/tr\u003E\u003C/tbody\u003E\u003C/table\u003E\u003C/details\u003E\u003C/div\u003E"
        }
      ]
    },
    {
      "id": "00000015-0001-0001-0001-000000000008",
      "type": "markdown",
      "source": "## And writes it back\n\nThe same variable works in the other direction. Setting it from C# moves the dial and\nruns the \u0060observe\u0060 callback the Python cell registered, which is the part that makes\nthis a control rather than a reading."
    },
    {
      "id": "00000015-0001-0001-0001-000000000009",
      "type": "code",
      "language": "csharp",
      "source": "Variables.Set(\u0022threshold\u0022, 62L);\n\n\u0022The dial is at 62 now, and Python heard about it.\u0022",
      "outputs": [
        {
          "mimeType": "text/plain",
          "content": "The dial is at 62 now, and Python heard about it."
        }
      ]
    },
    {
      "id": "00000015-0001-0001-0001-000000000010",
      "type": "markdown",
      "source": "## Here it is\n\nThe dial below was drawn after that C# cell ran, which is why it reads 62 rather than\nthe 40 it was built with. \u0060turned\u0060 is the record the \u0060observe\u0060 callback kept, and it\nholds one entry: a value settles after a single trip in whichever direction it started,\nso nothing bounces between the two sides."
    },
    {
      "id": "00000015-0001-0001-0001-000000000011",
      "type": "code",
      "language": "python",
      "source": "print(\u0022dial.value:\u0022, dial.value)\nprint(\u0022every value the trait was set to:\u0022, turned)\n\ndial",
      "outputs": [
        {
          "mimeType": "text/plain",
          "content": "dial.value: 62\nevery value the trait was set to: [62]\n",
          "channel": "stdout"
        },
        {
          "mimeType": "text/x-verso-widget",
          "content": "\u003C!DOCTYPE html\u003E\n\u003Chtml lang=\u0022en\u0022\u003E\n\u003Chead\u003E\n\u003Cmeta charset=\u0022utf-8\u0022\u003E\n\u003Ctitle\u003EWidget\u003C/title\u003E\n\u003Cstyle\u003E\nhtml, body { margin: 0; padding: 0; background: transparent; }\n\u003C/style\u003E\n\u003C/head\u003E\n\u003Cbody\u003E\n\n\n\u003C!-- Load require.js. Delete this if your page already loads require.js --\u003E\n\u003Cscript src=\u0022https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js\u0022 integrity=\u0022sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb\u002Bm0JlOmKPjt6XZ9JJkA=\u0022 crossorigin=\u0022anonymous\u0022\u003E\u003C/script\u003E\n\u003Cscript src=\u0022https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@^1.0.1/dist/embed-amd.js\u0022 crossorigin=\u0022anonymous\u0022\u003E\u003C/script\u003E\n\n\u003Cscript type=\u0022application/vnd.jupyter.widget-state\u002Bjson\u0022\u003E\n{\n  \u0022version_major\u0022: 2,\n  \u0022version_minor\u0022: 0,\n  \u0022state\u0022: {\n    \u002234bd646df43f4ebeb8423a2f6ae0851e\u0022: {\n      \u0022model_name\u0022: \u0022LayoutModel\u0022,\n      \u0022model_module\u0022: \u0022@jupyter-widgets/base\u0022,\n      \u0022model_module_version\u0022: \u00222.0.0\u0022,\n      \u0022state\u0022: {\n        \u0022_model_module\u0022: \u0022@jupyter-widgets/base\u0022,\n        \u0022_model_module_version\u0022: \u00222.0.0\u0022,\n        \u0022_model_name\u0022: \u0022LayoutModel\u0022,\n        \u0022_view_module\u0022: \u0022@jupyter-widgets/base\u0022,\n        \u0022_view_module_version\u0022: \u00222.0.0\u0022,\n        \u0022_view_name\u0022: \u0022LayoutView\u0022\n      }\n    },\n    \u0022f71e62b7d67e46d7af90ade4f844db3e\u0022: {\n      \u0022model_name\u0022: \u0022AnyModel\u0022,\n      \u0022model_module\u0022: \u0022anywidget\u0022,\n      \u0022model_module_version\u0022: \u0022~0.11.*\u0022,\n      \u0022state\u0022: {\n        \u0022_anywidget_id\u0022: \u0022__main__.Dial\u0022,\n        \u0022_dom_classes\u0022: [],\n        \u0022_esm\u0022: \u0022\\nexport default {\\n  render({ model, el }) {\\n    const SIZE = 176, MID = SIZE / 2, R = 62;\\n    const LENGTH = 2 * Math.PI * R, SWEEP = 0.75, SPAN = 270;\\n    const NS = \\\u0022http://www.w3.org/2000/svg\\\u0022;\\n\\n    const svg = document.createElementNS(NS, \\\u0022svg\\\u0022);\\n    svg.setAttribute(\\\u0022viewBox\\\u0022, \u00600 0 ${SIZE} ${SIZE}\u0060);\\n    svg.setAttribute(\\\u0022width\\\u0022, SIZE);\\n    svg.setAttribute(\\\u0022height\\\u0022, SIZE);\\n    svg.setAttribute(\\\u0022role\\\u0022, \\\u0022slider\\\u0022);\\n    svg.setAttribute(\\\u0022tabindex\\\u0022, \\\u00220\\\u0022);\\n    svg.setAttribute(\\\u0022aria-label\\\u0022, \\\u0022Threshold\\\u0022);\\n    svg.setAttribute(\\\u0022aria-valuemin\\\u0022, \\\u00220\\\u0022);\\n    svg.setAttribute(\\\u0022aria-valuemax\\\u0022, \\\u0022100\\\u0022);\\n    svg.style.cssText = \\\u0022display:block;margin:0 auto;touch-action:none;cursor:grab\\\u0022;\\n\\n    function arc(stroke) {\\n      const ring = document.createElementNS(NS, \\\u0022circle\\\u0022);\\n      ring.setAttribute(\\\u0022cx\\\u0022, MID);\\n      ring.setAttribute(\\\u0022cy\\\u0022, MID);\\n      ring.setAttribute(\\\u0022r\\\u0022, R);\\n      ring.setAttribute(\\\u0022fill\\\u0022, \\\u0022none\\\u0022);\\n      ring.setAttribute(\\\u0022stroke\\\u0022, stroke);\\n      ring.setAttribute(\\\u0022stroke-width\\\u0022, \\\u002213\\\u0022);\\n      ring.setAttribute(\\\u0022stroke-linecap\\\u0022, \\\u0022round\\\u0022);\\n      ring.setAttribute(\\\u0022transform\\\u0022, \u0060rotate(135 ${MID} ${MID})\u0060);\\n      svg.appendChild(ring);\\n      return ring;\\n    }\\n\\n    const track = arc(\\\u0022var(--verso-border-default, #d6d9df)\\\u0022);\\n    track.setAttribute(\\\u0022stroke-dasharray\\\u0022, \u0060${LENGTH * SWEEP} ${LENGTH}\u0060);\\n    const filled = arc(\\\u0022var(--verso-accent-primary, #4f7cff)\\\u0022);\\n\\n    const reading = document.createElementNS(NS, \\\u0022text\\\u0022);\\n    reading.setAttribute(\\\u0022x\\\u0022, MID);\\n    reading.setAttribute(\\\u0022y\\\u0022, MID \u002B 4);\\n    reading.setAttribute(\\\u0022text-anchor\\\u0022, \\\u0022middle\\\u0022);\\n    reading.setAttribute(\\\u0022fill\\\u0022, \\\u0022var(--verso-fg-default, #22252b)\\\u0022);\\n    reading.style.cssText = \\\u0022font:600 36px system-ui,-apple-system,sans-serif\\\u0022;\\n    svg.appendChild(reading);\\n\\n    const caption = document.createElementNS(NS, \\\u0022text\\\u0022);\\n    caption.setAttribute(\\\u0022x\\\u0022, MID);\\n    caption.setAttribute(\\\u0022y\\\u0022, MID \u002B 30);\\n    caption.setAttribute(\\\u0022text-anchor\\\u0022, \\\u0022middle\\\u0022);\\n    caption.setAttribute(\\\u0022fill\\\u0022, \\\u0022var(--verso-fg-muted, #71767f)\\\u0022);\\n    caption.style.cssText = \\\u0022font:11px system-ui,sans-serif;letter-spacing:.14em\\\u0022;\\n    caption.textContent = \\\u0022THRESHOLD\\\u0022;\\n    svg.appendChild(caption);\\n\\n    function draw() {\\n      const value = model.get(\\\u0022value\\\u0022);\\n      filled.setAttribute(\\\u0022stroke-dasharray\\\u0022, \u0060${LENGTH * SWEEP * value / 100} ${LENGTH}\u0060);\\n      reading.textContent = value;\\n      svg.setAttribute(\\\u0022aria-valuenow\\\u0022, value);\\n    }\\n\\n    function set(next) {\\n      next = Math.round(Math.min(100, Math.max(0, next)));\\n      if (next === model.get(\\\u0022value\\\u0022)) return;\\n      model.set(\\\u0022value\\\u0022, next);\\n      model.save_changes();\\n    }\\n\\n    function fromPointer(event) {\\n      const box = svg.getBoundingClientRect();\\n      const x = event.clientX - box.left - box.width / 2;\\n      const y = event.clientY - box.top - box.height / 2;\\n      const degrees = Math.atan2(x, -y) * 180 / Math.PI;\\n      set((Math.min(SPAN / 2, Math.max(-SPAN / 2, degrees)) \u002B SPAN / 2) / SPAN * 100);\\n    }\\n\\n    svg.addEventListener(\\\u0022pointerdown\\\u0022, function (event) {\\n      svg.setPointerCapture(event.pointerId);\\n      svg.style.cursor = \\\u0022grabbing\\\u0022;\\n      fromPointer(event);\\n    });\\n    svg.addEventListener(\\\u0022pointermove\\\u0022, function (event) {\\n      if (svg.hasPointerCapture(event.pointerId)) fromPointer(event);\\n    });\\n    svg.addEventListener(\\\u0022pointerup\\\u0022, function () { svg.style.cursor = \\\u0022grab\\\u0022; });\\n    svg.addEventListener(\\\u0022keydown\\\u0022, function (event) {\\n      const step = { ArrowLeft: -1, ArrowDown: -1, ArrowRight: 1, ArrowUp: 1 }[event.key];\\n      if (!step) return;\\n      event.preventDefault();\\n      set(model.get(\\\u0022value\\\u0022) \u002B step * (event.shiftKey ? 10 : 1));\\n    });\\n\\n    model.on(\\\u0022change:value\\\u0022, draw);\\n    draw();\\n    el.appendChild(svg);\\n  }\\n};\\n\u0022,\n        \u0022_model_module\u0022: \u0022anywidget\u0022,\n        \u0022_model_module_version\u0022: \u0022~0.11.*\u0022,\n        \u0022_model_name\u0022: \u0022AnyModel\u0022,\n        \u0022_view_module\u0022: \u0022anywidget\u0022,\n        \u0022_view_module_version\u0022: \u0022~0.11.*\u0022,\n        \u0022_view_name\u0022: \u0022AnyView\u0022,\n        \u0022layout\u0022: \u0022IPY_MODEL_34bd646df43f4ebeb8423a2f6ae0851e\u0022,\n        \u0022value\u0022: 62\n      }\n    }\n  }\n}\n\u003C/script\u003E\n\u003Cscript type=\u0022application/vnd.jupyter.widget-view\u002Bjson\u0022\u003E\n{\u0022version_major\u0022: 2, \u0022version_minor\u0022: 0, \u0022model_id\u0022: \u0022f71e62b7d67e46d7af90ade4f844db3e\u0022}\n\u003C/script\u003E\n\n\u003C/body\u003E\n\u003C/html\u003E\n"
        }
      ]
    },
    {
      "id": "00000015-0001-0001-0001-000000000012",
      "type": "code",
      "language": "python",
      "source": "#!bind --list",
      "outputs": [
        {
          "mimeType": "text/plain",
          "content": "Widget traits shared as variables:\n  threshold  \u003C-  dial.value"
        }
      ]
    },
    {
      "id": "00000015-0001-0001-0001-000000000013",
      "type": "markdown",
      "source": "## Make it yours\n\nChange \u0060value = traitlets.Int(40)\u0060 to \u0060traitlets.Float\u0060 and the dial reports decimals,\nbecause the trait is the only thing that decides what the value is. Add a second trait\nand bind that too. Or leave the dial alone and bind a trait of something you already\nhave: what \u0060#!bind\u0060 asks of an object is whether it has a trait by that name and whether\nit will call back when the trait changes, so any \u0060traitlets.HasTraits\u0060 object works.\n\nA trait holding another widget is refused, which covers \u0060layout\u0060 and \u0060style\u0060, and so is\na value too large to keep re-sending on every turn of the dial. \u0060#!bind --remove\nthreshold\u0060 stops the two following each other and leaves the variable holding the value\nit last had."
    }
  ]
}