Skip to main content

pyhandsontable

Build Status PyPI version shields.io PyPI license PyPI pyversions

View a list of JSON-serializable dictionaries or a 2-D array, in HandsOnTable, in Jupyter Notebook.

Nested JSON renderer is also supported and is default. Image and markdown renderers are possible, but has to be extended.

Installation

pip install pyhandsontable

Usage

In Jupyter Notebook,

>>> from pyhandsontable import PagedViewer
>>> viewer = PagedViewer(data=data_matrix, **kwargs)
>>> viewer
'A Handsontable is shown in Jupyter Notebook.'
>>> viewer.view(-1)
'The last page is shown.'
>>> viewer.previous()
'The previous page (i-1) is shown.'
>>> viewer.next()
'The next page (i+1) is shown.'

Data matrix can be either a list of lists (2-D array) or a list of dictionaries.

It is also possible to view all entries at once, but it could be bad, if there are too many rows.

>>> from pyhandsontable import view_table
>>> view_table(data_matrix, **kwargs)

Acceptable kwargs

  • height: height of the window (default: 500)
  • width: width of the window (default: 1000)
  • title: title of the HTML file
  • maxColWidth: maximum column width. (Default: 200)
  • renderers: the renderers to use in generating the columns (see below.)
  • autodelete: whether the temporary HTML file should be autodeleted. (Default: True)
  • filename: filename of the temporary HTML file (default: 'temp.handsontable.html')
  • config: add additional config as defined in https://docs.handsontable.com/pro/5.0.0/tutorial-introduction.html
    • This will override the default config (per key basis) which are:
{
    data: data,
    rowHeaders: true,
    colHeaders: true,
    columns: columns,
    manualColumnResize: true,
    manualRowResize: true,
    renderAllRows: true,
    modifyColWidth: (width, col)=>{
        if(width > maxColWidth) return maxColWidth;
    },
    afterRenderer: (td, row, column, prop, value, cellProperties)=>{
        td.innerHTML = '<div class="wrapper"><div class="wrapped">' + td.innerHTML + '</div></div>';
    }
}

renderers example, if your data is a 2-D array:

{
    1: 'html',
    2: 'html'
}

or if your data is list of dict:

{
    "front": 'html',
    "back": 'html'
}

Enabling Image, HTML and Markdown renderer

This can be done in Python side, by converting everything to HTML. Just use any markdown for Python library.

from markdown import markdown
import base64
image_html = f'<img src="{image_url}" width=100 />'
image_html2 = f'<img src="data:image/png;base64,{base64.b64encode(image_bytes).decode()}" />'
markdown_html = markdown(markdown_raw)

Any then,

PagedViewer(data=data_matrix, renderers={
    "image_field": "html",
    "html_field": "html",
    "markdown_field": "html"
})

Screenshots

1.png 0.png

Related projects

  • htmlviewer - similar in concept to this project, but does not use HandsOnTable.js
  • TinyDB-viewer - uses HandsOnTable.js and also allow editing in Jupyter Notebook.

License

This software includes handsontable.js, which is MIT-licensed.

Metadata

Release files for pyhandsontable 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyhandsontable 0.3
File Size Uploaded
pyhandsontable-0.3.tar.gz 214.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyhandsontable 0.3
File Interpreter ABI Platform
pyhandsontable-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 1.1 MB

Release files / pyhandsontable-0.3.tar.gz

Download URL pyhandsontable-0.3.tar.gz
Size 214.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b0cfd9e10b635f5dc922328d95c38002f875c580da6ffd4db09774d673cbb6a8
BLAKE2b-256 checksum
How to use checksums
b6db061db7ac8e5e003e60fca1e8c67330f6d79038ca83ba74407b60279fff07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.11.2 CPython/3.7.0 Darwin/17.7.0

Release files / pyhandsontable-0.3-py3-none-any.whl

Download URL pyhandsontable-0.3-py3-none-any.whl
Size 866.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18aff1a062e2383594ff0608f840d92b9a14ad6e2e2713cc347e9c13ba0d4326
BLAKE2b-256 checksum
How to use checksums
65bf4e53c455f7f6084f8e227dcf3f3cdeae2a1d33d994349f2267764a87c064
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.11.2 CPython/3.7.0 Darwin/17.7.0

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.2.14

2 release files

0.2.7

2 release files

0.2.5

2 release files

0.2.0

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page