Skip to main content

A framework for user-friendly widgets and tools in Jupyter Notebook.

Project description

NBTools

NBTools is a framework for creating user-friendly Jupyter notebooks that are assessible to both programming and non-programming users alike. The framework provides:

  • A widget and decorator which can transform any Python function into an interactive user interface.
  • A toolbox interface for encapsulating and adding new computational steps to a notebook.
  • Flexible theming and APIs to extend the NBTools functionality.
  • A WYSWYG editor for markdown cells (provided as part of the accompanying juptyter-wyswyg package).

NBTools was developed as part of the GenePattern Notebook environment. GenePattern Notebook also serves as an example of how NBTools can be extended and applied to a specific domain: in its case, bioinformatics.

Installation

NBTools is available through PIP and conda. Just run one of the following commands.

pip install nbtools

or

conda install -c genepattern nbtools

If using Jupyter Notebook version <= 5.2, you will need to execute to additional commands to install and enable the nbextension. This is not necessary in Jupyter 5.3+.

jupyter nbextension install --py nbtools

jupyter nbextension enable --py nbtools

Getting Started

Let's start by writing a simple Hello World function and turning it into an interactive widget inside a Jupyter notebook. Go ahead and install NBTools, launch Jupyter and open a new, blank notebook.

Next, let's write the function. The function below accepts a string and prints a brief hello message. By default, the message addresses the world. For good measure we will also add a docstring to document the function.

def say_hello(to_whom='World'):
    """Say hello to the world or whomever."""
    print('Hello ' + to_whom)

This is pretty basic Python and hopefully so far everything is familiar. Next we will turn this function into an interactive widget with just an import statement and one line of code. Update the code to what is shown below and execute the cell.

import nbtools

@nbtools.build_ui
def say_hello(to_whom='World'):
    """Say hello to the world or whomever."""
    print('Hello ' + to_whom)

You should now see a widget containing a web form. This form will prompt for the value of the to_whom parameter. The docstrong will also appear as a description near the top of the widget. Go ahead and change the to_whom value or just leave it as "World," then click the "Run" button. This will execute the function and print the results below the widget. Meanwhile, the form will also collapse, making more room on your screen.

With the push of a button, you've ran the say_hello function!

This is exciting, but it is far from the only feature of the NBTools framework. You can edit markdown cells using a WYSIWYG editor, customize how your function displays, chain together multiple related functions, make widgets from existing third-party methods, create a library of interactive tools (just click the Tools button on the toolbar and you will see say_hello has already added itself) and more! Just see the documentation links below.

Features

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbtools-19.8.tar.gz (59.7 kB view details)

Uploaded Source

Built Distribution

nbtools-19.8-py3-none-any.whl (119.7 kB view details)

Uploaded Python 3

File details

Details for the file nbtools-19.8.tar.gz.

File metadata

  • Download URL: nbtools-19.8.tar.gz
  • Upload date:
  • Size: 59.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for nbtools-19.8.tar.gz
Algorithm Hash digest
SHA256 ee390285132a1dd02bf255086229ac35c5b6d5448a64318f97377d05bae92ab9
MD5 14e7a509fb5035a3c949ea80e8359fcb
BLAKE2b-256 0bb20bc7a3cc952a18819006a619c7b3ddc5ffcd344b122d372023443b9fdfd9

See more details on using hashes here.

File details

Details for the file nbtools-19.8-py3-none-any.whl.

File metadata

  • Download URL: nbtools-19.8-py3-none-any.whl
  • Upload date:
  • Size: 119.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for nbtools-19.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6dddb2868ff2a0dae44f26b77a1ca42412256427561497341a6a87995ec5130c
MD5 75ec16785ecd3ce8d03b73de808b77bf
BLAKE2b-256 ddfee16387130bc745c2dd64d934a20efd4d760ba7148e628921ecb1d7f7e648

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page