{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "from seeq import spy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "pycharm": {
     "is_executing": false,
     "name": "#%%\n"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# Log into the Seeq Server if you're not using Seeq Data Lab:\n",
    "spy.login(url='http://localhost:34216', credentials_file='../credentials.key', force=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# spy.widgets\n",
    "\n",
    "A set of ipython widgets designed specifically for working with Seeq.\n",
    "\n",
    "These widgets can be used on their own or incorporated into an ipywidgets UI."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "## SeeqItemSelect\n",
    "\n",
    "The Seeq Item Selector is a configurable item selector. Creating a basic item selector that allows searching for \n",
    "seeq items by name and type can be created with no arguments."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "is_executing": false,
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "item_selector1 = spy.widgets.SeeqItemSelect()\n",
    "display(item_selector1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "Once a search has been performed, an item may be selected in the results window and information on that item is \n",
    "available through the `selected_value` attribute. Perform a search in the above selector and select an item before \n",
    "running the next cell."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "is_executing": false,
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "item_selector1.selected_value"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "There are a number of options available which can be found in the widget's documentation. In this example, the widget\n",
    " will be shown with:\n",
    "  - search fields of name, type, a datasource dropdown and a selector to include archived items\n",
    "  - type options limited to 'Signal', 'Condition', and 'Scalar'\n",
    "  - a default type of 'Condition\n",
    "  - a collapsible help window\n",
    "  - a results window 15 rows long\n",
    "  - a maximum of 200 results displayed\n",
    "  - the ability to select multiple items"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "is_executing": false,
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "item_selector2 = spy.widgets.SeeqItemSelect(\n",
    "    show_fields=['Name', 'Type', 'Datasource Dropdown', 'Archived'],\n",
    "    type_options=['Signal', 'Condition', 'Scalar'],\n",
    "    item_type='Condition',\n",
    "    show_help=True,\n",
    "    results_box_rows=15,\n",
    "    max_displayed_results=200,\n",
    "    mulit_selct=True\n",
    ")\n",
    "display(item_selector2)"
   ]
  }
 ],
 "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.3"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
