Module pandas_profiling.report.presentation.flavours.widget.image
Expand source code
from ipywidgets import widgets
from pandas_profiling.report.presentation.core.image import Image
class WidgetImage(Image):
def render(self):
image = self.content["image"]
if self.content["image_format"] == "svg":
image.replace("svg ", 'svg class="img-responsive center-img"')
else:
image = '<img src="{image}" alt="{alt}" />'.format(
image=image, alt=self.content["alt"]
)
widget = widgets.HTML(image)
if "caption" in self.content and self.content["caption"] is not None:
caption = widgets.HTML(
'<p style="color: #999"><em>{caption}</em></p>'.format(
caption=self.content["caption"]
)
)
return widgets.VBox([widget, caption])
else:
return widget
Classes
class WidgetImage (image, image_format, alt, caption=None, **kwargs)
-
Helper class that provides a standard way to create an ABC using inheritance.
Expand source code
class WidgetImage(Image): def render(self): image = self.content["image"] if self.content["image_format"] == "svg": image.replace("svg ", 'svg class="img-responsive center-img"') else: image = '<img src="{image}" alt="{alt}" />'.format( image=image, alt=self.content["alt"] ) widget = widgets.HTML(image) if "caption" in self.content and self.content["caption"] is not None: caption = widgets.HTML( '<p style="color: #999"><em>{caption}</em></p>'.format( caption=self.content["caption"] ) ) return widgets.VBox([widget, caption]) else: return widget
Ancestors
- Image
- ItemRenderer
- Renderable
- abc.ABC
Methods
def render(self)
-
Expand source code
def render(self): image = self.content["image"] if self.content["image_format"] == "svg": image.replace("svg ", 'svg class="img-responsive center-img"') else: image = '<img src="{image}" alt="{alt}" />'.format( image=image, alt=self.content["alt"] ) widget = widgets.HTML(image) if "caption" in self.content and self.content["caption"] is not None: caption = widgets.HTML( '<p style="color: #999"><em>{caption}</em></p>'.format( caption=self.content["caption"] ) ) return widgets.VBox([widget, caption]) else: return widget