Skip to main content

A Qt for Python extension for Voila

Project description

QtVoila

A Qt for Python extension for Voila!

PyPI version

Introduction

This is a Qt for Python (Pyside2) widget encapsulating a Voila application. It's a convenient way of embedding the awesomeness of Voila in your Qt applications.

Installation

$ pip install qtvoila

Usage

QtVoila should be imported and used as a PySide2 widget, anywhere inside your GUI application. Although it can be initialized with default parameters, you are able to define the parent (the PySide2 application), the temporary directory where any created notebooks will be temporarily stored, the path to an existing external notebook and the boolean option to either strip code sources on Voila rendering or not:

from qtvoila import QtVoila

voila_widget = QtVoila(
    parent=None,
    temp_dir=None,
    external_notebook=None,
    strip_sources=True
)

If creating a notebook programmatically, new cells can be added with the method add_notebook_cell(). This method accepts three arguments: code_imports is a dictionary of modules to be imported, code is the string containing the cell's code or markdown text and cell_type defines if the cell is of type code or markdown. Examples:

# Mardown cell
mtext = "#This is my title\n"
mtext += "Here goes some text. Check out this graphic:"
voila_widget.add_notebook_cell(code=mtext, cell_type='markdown')

# Code cell
imports = {
  'matplotlib': ['pyplot'],
  'numpy': [],
}
code = "%matplotlib inline\n"
code += "pyplot.plot(numpy.random.rand(10))"
voila_widget.add_notebook_cell(code_imports=imports, code=code, cell_type='code')

To run the Voila process and render the result on widget:

voila_widget.run_voila()

To clear widget and stop the background Voila process:

voila_widget.close_renderer()

Examples

Here you can find some examples on how to use QtVoila in your PySide2 application. For example, creating notebooks from user's input and rendering them:

To have your GUI importing existing notebooks and rendering them:

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

qtvoila-1.0.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

qtvoila-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file qtvoila-1.0.0.tar.gz.

File metadata

  • Download URL: qtvoila-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for qtvoila-1.0.0.tar.gz
Algorithm Hash digest
SHA256 87091f5f8523c28a88447f8c9964b1779f30dfe313ff9af052aa4beb04e57a11
MD5 2150c4b6b6dabbf3aeca7931a924f00d
BLAKE2b-256 63e36bf6ec7e5fd15ed93d9289f39deffbf65d993973876e65efa529220d0ea1

See more details on using hashes here.

File details

Details for the file qtvoila-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: qtvoila-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for qtvoila-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3dab9b40e1d8cb2380b5e1bbbd828531fa1730c7b49e73cd2bd4cdb71aa20120
MD5 37260b64a5a2e39039102d0925ce03a0
BLAKE2b-256 1f6cd4261d194bc607e162d3194e41d5a1e86930b292eda79cf03e82f3b4c4aa

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