Skip to content

Instantly share code, notes, and snippets.

@bollwyvl
Created October 25, 2014 23:30
Show Gist options
  • Save bollwyvl/7c1d9606bc31272c825a to your computer and use it in GitHub Desktop.
Save bollwyvl/7c1d9606bc31272c825a to your computer and use it in GitHub Desktop.
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