{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ipyvuetify as v\n", "import traitlets\n", "from traitlets import Int, Unicode, List, Dict, Bool" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# URL text box\n", "\n", "https://vuetifyjs.com/en/components/text-fields" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "v.Col(cols=6, children=[\n", " v.TextField(outlined=True, class_='ma-2', label='URL', placeholder='https://')\n", "])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# home listing\n", "# https://www.rightmove.co.uk/property-for-sale/property-72921928.html\n", "\n", "# all listing data: property of Rightmove.co.uk" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "from download_listing import get_listing\n", "from pprint import pprint\n", "\n", "class URLTextField(v.VuetifyTemplate):\n", " url = Unicode('').tag(sync=True, allow_null=True)\n", " loading = Bool(False).tag(sync=True)\n", " template = Unicode('''\n", " \n", " ''').tag(sync=True)\n", " \n", " def vue_get_properties(self, data):\n", " self.loading = True\n", " pprint(get_listing(data))\n", " self.loading = False\n", "\n", "URLTextField()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Card\n", "https://vuetifyjs.com/en/components/cards" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from download_listing import get_listing\n", "\n", "class URLTextField(v.VuetifyTemplate):\n", " url = Unicode('').tag(sync=True, allow_null=True)\n", " loading = Bool(False).tag(sync=True)\n", " props = List(get_listing('')).tag(sync=True)\n", " show = Bool(False).tag(sync=True)\n", " price_string = Unicode('£1,000,000').tag(sync=True)\n", " template = Unicode('''\n", " \n", " ''').tag(sync=True)\n", " \n", " def vue_get_properties(self, data):\n", " self.disabled = True\n", " self.loading = True\n", " self.props = list(get_listing(data))\n", " self.price_string = f'£{self.props[0]:,.0f}'\n", " self.disabled = False\n", " self.loading = False\n", "\n", "u = URLTextField()\n", "u" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Sparkline\n", "https://vuetifyjs.com/en/components/sparklines" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "strange_walk = np.random.beta(2, 3, 10) * 100 * np.random.normal(size=10)\n", "strange_walk = pd.Series(strange_walk, name='Strange Walk').cumsum().round(2)\n", "\n", "strange_walk.plot()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "class SeriesSparkline(v.VuetifyTemplate):\n", " name = Unicode('').tag(sync=True)\n", " value = List([1,2,3]).tag(sync=True)\n", " template = Unicode(\"\"\"\n", " \n", " \"\"\").tag(sync=True)\n", " \n", " def __init__(self, *args, \n", " data=pd.Series(),\n", " **kwargs):\n", " super().__init__(*args, **kwargs)\n", " self.name = data.name\n", " self.value = data.tolist()\n", " \n", "s = SeriesSparkline(data=strange_walk)\n", "\n", "s" ] }, { "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": 4 }