Exemplo n.º 1
0
    def _repr_html_(self):
        import openalea.core
        import base64
        from openalea.deploy.shared_data import shared_data
        from openalea.core.project.formatting.html import html_metainfo_summary, html_item_summary
        from openalea.core.formatting.util import obj_icon_path
        from IPython.display import Image

        stylesheet_path = shared_data(openalea.core, 'stylesheet.css')
        if stylesheet_path and stylesheet_path.isfile():
            with open(stylesheet_path) as f:
                stylesheet = f.read()
            html = '<style>%s</style>' % stylesheet
        else:
            html = ''

        icon = obj_icon_path(self, paths=[self.path])
        if icon:
            data = base64.b64encode(
                Image(filename=icon)._repr_png_()).decode('ascii')
            image = '<image width="64px" style="vertical-align:middle;" src="data:image/png;base64,%s">' % data
        else:
            image = ''

        args = dict(image=image, title=self.title)

        html += '<div class="summary"><p class="title">%(image)s%(title)s</p>' % args
        html += '\n<hr>'
        html += html_metainfo_summary(self)
        html += html_item_summary(self)
        html += '</div>'
        return html
Exemplo n.º 2
0
    def _repr_html_(self):
        import openalea.core
        import base64
        from openalea.deploy.shared_data import shared_data
        from openalea.core.project.formatting.html import html_metainfo_summary, html_item_summary
        from openalea.core.formatting.util import obj_icon_path
        from IPython.display import Image

        stylesheet_path = shared_data(openalea.core, 'stylesheet.css')
        if stylesheet_path and stylesheet_path.isfile():
            with open(stylesheet_path) as f:
                stylesheet = f.read()
            html = '<style>%s</style>' % stylesheet
        else:
            html = ''

        icon = obj_icon_path(self, paths=[self.path])
        if icon:
            data = base64.b64encode(Image(filename=icon)._repr_png_()).decode('ascii')
            image = '<image width="64px" style="vertical-align:middle;" src="data:image/png;base64,%s">' % data
        else:
            image = ''

        args = dict(image=image, title=self.title)

        html += '<div class="summary"><p class="title">%(image)s%(title)s</p>' % args
        html += '\n<hr>'
        html += html_metainfo_summary(self)
        html += html_item_summary(self)
        html += '</div>'
        return html
Exemplo n.º 3
0
def html_project_summary(project):
    args = dict(
        image=qicon_path(project, project.path, paths=[project.path], packages=[openalea.core, openalea.oalab],
                         default=DEFAULT_PROJECT_ICON),
        label=project.label,
        name=project.name)
    html = '<div class="summary"><p class="title"><img style="vertical-align:middle;" src="%(image)s" width="128" />' % args
    html += '%(label)s</p>' % args
    html += '\n<hr>'
    html += html_metainfo_summary(project)
    html += html_item_summary(project)
    html += '</div>'
    return html
Exemplo n.º 4
0
def html_project_summary(project):
    args = dict(image=qicon_path(project,
                                 project.path,
                                 paths=[project.path],
                                 packages=[openalea.core, openalea.oalab],
                                 default=DEFAULT_PROJECT_ICON),
                label=project.label,
                name=project.name)
    html = '<div class="summary"><p class="title"><img style="vertical-align:middle;" src="%(image)s" width="128" />' % args
    html += '%(label)s</p>' % args
    html += '\n<hr>'
    html += html_metainfo_summary(project)
    html += html_item_summary(project)
    html += '</div>'
    return html