ipyvue
ipyvue is a Python library that provides a Jupyter widget base for building interactive applications using Vue.js. It allows developers to create custom Jupyter widgets with Vue.js templates and data reactivity. The library is actively maintained with frequent minor releases addressing bug fixes and introducing new features, currently at version 1.12.0.
Warnings
- gotcha Prior to v1.11.2, a data value of `0` (integer zero) was incorrectly transformed into an empty object (`{}`) when passed from Python to Vue, leading to unexpected behavior in templates.
- gotcha Before v1.11.1, templates that were empty or had their `<template>` tags on a single line or omitted could cause rendering errors in some environments.
- gotcha In versions prior to v1.11.0, the `v_model` directive in Vue templates could not be set or updated after the initial render of the component. Changes to the Python-side data bound to `v_model` would not propagate to the frontend.
- gotcha Starting with v1.10.0, ipyvue began sending all serializable event data (e.g., key presses, mouse clicks) with events. If your code on older versions relied on a limited subset of event data, this change might expose more data than expected.
Install
-
pip install ipyvue
Imports
- VueTemplate
from ipyvue import VueTemplate
Quickstart
from ipyvue import VueTemplate
from IPython.display import display
class HelloWorld(VueTemplate):
template = """
<template>
<div>Hello, {{ name }}!</div>
<input v-model="name" placeholder="Enter your name">
</template>
"""
data = {
'name': 'World'
}
widget = HelloWorld()
display(widget)
# In a Jupyter notebook/Lab cell, 'widget' on the last line
# would implicitly display it without 'display()'.