{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import panel as pn\n",
    "\n",
    "pn.extension()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This example demonstrates how to control one set of widgets with another set of widgets, such as when the value of one widget changes the allowable values of another. Here the ``title_widget`` and ``value_widget`` control the title and ranges of the other set of widgets, respectively."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "title_widget = pn.widgets.TextInput(name='This controls labels', value='LABEL TEXT')\n",
    "value_widget = pn.widgets.IntSlider(name='This controls values', start=0, end=10, value=5)\n",
    "\n",
    "meta_widgets = pn.WidgetBox(\n",
    "    title_widget,\n",
    "    value_widget,\n",
    ")\n",
    "\n",
    "widgets = pn.WidgetBox(\n",
    "    pn.widgets.TextInput(),\n",
    "    pn.widgets.Spinner(),\n",
    "    pn.widgets.IntSlider(),\n",
    "    pn.widgets.RangeSlider(),\n",
    "    pn.widgets.FloatSlider(),\n",
    ")\n",
    "\n",
    "def update_titles(event):\n",
    "    for w in widgets:\n",
    "        w.name = '%s %s' % (w.__class__.__name__, event.new)\n",
    "\n",
    "title_widget.param.watch(update_titles, 'value')\n",
    "title_widget.param.trigger('value')\n",
    "\n",
    "def update_values(event):\n",
    "    for w in widgets:\n",
    "        if isinstance(w.value, (int, float)):\n",
    "            w.value = event.new\n",
    "            w.end = event.new\n",
    "\n",
    "value_widget.param.watch(update_values, 'value')\n",
    "\n",
    "pn.Row(meta_widgets, widgets).servable()"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
