Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple Bootstrap About widget
from IPython.html import widgets
from IPython.utils import traitlets
from jinja2 import Template
class About(widgets.HTML):
template = Template("""
<i id="about-{{ model_id }}"
class="text-info fa fa-info-circle widget-about"
title="{{ title|escape }}"
data-content="{{ content|escape }}"></i>
<script>
$('#about-{{ model_id }}').popover();
</script>
""")
title = traitlets.Unicode(sync=True)
content = traitlets.Unicode(sync=True)
html = traitlets.Bool(sync=True)
def __init__(self, *args, **kwargs):
super(About, self).__init__(*args, **kwargs)
def _title_changed(self, old, new):
self.value = self.template.render(**self._trait_values)
About(title="foo", content=""""It's lovely," I said""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment