示例#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
示例#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
示例#3
0
文件: html.py 项目: gbaty/openalea
def html_project_summary(project):
    icon = obj_icon_path(project, paths=[project.path])
    if icon_path:
        image = '<img style="vertical-align:middle;" src="file://%s" width="128" />' % icon
    else:
        image = ""
    args = dict(image=image, label=project.label, name=project.name)
    html = '<div class="summary">%(image)s<p class="title">%(label)s</p>' % args
    html += "\n<hr>"
    html += html_metainfo_summary(project)
    html += html_item_summary(project)
    html += "</div>"
    return html
示例#4
0
def html_project_summary(project):
    icon = obj_icon_path(project, paths=[project.path])
    if icon_path:
        image = '<img style="vertical-align:middle;" src="file://%s" width="128" />' % icon
    else:
        image = ''
    args = dict(image=image, label=project.label, name=project.name)
    html = '<div class="summary">%(image)s<p class="title">%(label)s</p>' % args
    html += '\n<hr>'
    html += html_metainfo_summary(project)
    html += html_item_summary(project)
    html += '</div>'
    return html