Created
October 25, 2014 23:30
-
-
Save bollwyvl/7c1d9606bc31272c825a to your computer and use it in GitHub Desktop.
A simple Bootstrap About widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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