Git Product home page Git Product logo

qtvoila's Introduction

QtVoila

PyPI version

A Qt for Python extension for Voila!

QtVoila a Qt for Python (Pyside2) 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 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:

qtvoila's People

Contributors

luiztauffer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.