{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.twosigma.beakerx.widget.IntSlider\n", "\n", "w = new IntSlider()\n", "w.value = 60\n", "w" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w.value" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w.value =76" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w.description = \"desc1\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w.disabled = false" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w.max = 200\n", "w.min = 50" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w.orientation = \"horizontal\"\n", "//w.orientation = \"vertical\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w.step = 20" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w.visible = true\n", "//w.visible = false" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.twosigma.beakerx.widget.IntProgress\n", "bar = new IntProgress()\n", "bar.value = 10\n", "bar" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bar.value" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bar.value =110" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bar.max = 300\n", "bar.min = 50" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bar.step = 20" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bar.orientation = \"horizontal\"\n", "//bar.orientation = \"vertical\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Output usage" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.twosigma.beakerx.widget.Output\n", "out = new Output()\n", "OutputManager.setOutput(new Output())\n", "out" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for (i = 0; i <10; i++) {\n", " println(\"Hello \"+ i)\n", "}\n", "\"result loop\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out.appendStdout(\"Hello 2\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out.appendStderr(\"Error 1\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "System.err.println(\"Error 2\");" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out.clearOutput()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "println(\"Hello 3\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.twosigma.beakerx.widget.IntSlider\n", "out.display(new IntSlider())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "OutputManager.setOutput(null)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "println(\"Hello 6\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Only stdout" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.twosigma.beakerx.widget.Output\n", "OutputManager.setStandardOutput(new Output())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "println(\"Hello only stdout\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "System.err.println(\"Error for onlyOut\");" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "OutputManager.clear()\n", "OutputManager.setStandardOutput(null)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Only stderr" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.twosigma.beakerx.widget.Output\n", "OutputManager.setStandardError(new Output())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "println(\"Hello only stderr\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "System.err.println(\"Error for onlyErr\");" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "OutputManager.setStandardError(null)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Rich material can also be directed to the output area" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import com.twosigma.beakerx.widget.Output\n", "out2 = new Output()\n", "OutputManager.setOutput(out2)\n", "out2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "println(\"before\")\n", "out2.display(YoutubeVideo(\"gSVvxOchT8Y\"))\n", "println(\"inside\")\n", "out2.display(SVG(\"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/car.svg\"))\n", "println(\"after\")\n", "\"done\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out2.display(YoutubeVideo(\"gSVvxOchT8Y\"))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out2.clearOutput()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "OutputManager.setOutput(null)" ] } ], "metadata": { "kernelspec": { "display_name": "Groovy", "language": "groovy", "name": "groovy" }, "language_info": { "codemirror_mode": "groovy", "file_extension": ".groovy", "mimetype": "", "name": "Groovy", "nbconverter_exporter": "", "version": "2.4.3" } }, "nbformat": 4, "nbformat_minor": 2 }