A Qt for Python extension for Voila
Project description
QtVoila
A Qt for Python extension for Voila!
QtVoila a Qt for Python (PySide6) widget that controls and renders a Voila application. It's a convenient way of embedding the awesomeness of Voila in your Qt applications.
The idea of the widget and implementation details are described in this blog post.
Installation
$ pip install qtvoila
Usage
QtVoila should be imported and used as a PySide6 widget, anywhere inside your GUI application. Although it can be initialized with default parameters, you are able to define the parent (the PySide6 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 PySide6 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qtvoila-2.1.0.tar.gz.
File metadata
- Download URL: qtvoila-2.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
715ac33548ec70c5885696419d075827dbc51e4f68fa9eb381e5c4dd169b830d
|
|
| MD5 |
d57e4eece89d4c2e5da9ce420beee8fa
|
|
| BLAKE2b-256 |
2ba25dc550d321cdca941635013fcedd65c5613d051fec144b4687c7190d9678
|
File details
Details for the file qtvoila-2.1.0-py3-none-any.whl.
File metadata
- Download URL: qtvoila-2.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c6183fe13d14e8c1c3cd60f0d2ee3f370644dbceaa91d66bc4e6b01293ebf31
|
|
| MD5 |
b5e45464d9567c188aa85b9d06aab088
|
|
| BLAKE2b-256 |
cac030e4e7556bf15ad464210d2f8368e37d7bc903a84f51f90f578037a19e98
|