# -*- coding: utf-8 -*- from enum import Enum class Media(Enum): TEXT = 1 IMAGE = 2 VIDEO = 3 AUDIO = 4 class HtmlVisualization(object): def __init__( self, allow_annotation=False, slice_size=1000, align='center', width_scale='60%', title='Visualization', ): self.content_list = [] self.rows_meta = [] self.allow_annotation = allow_annotation self.slice_size = slice_size self.align = align self.width_scale = width_scale self.title = title self.html_start = '' self.html_head = f'{title}' self.html_style = ''' '''.replace('{width_scale}', self.width_scale).replace('{align}', self.align) self.html_body = '{BODY}\n' self.html_end = '' self.html_script = ''' ''' self.label_button = ( '
' + "" + '
') def format_col(self, content='', label='', type=Media.TEXT, content_height=400, content_width=600): if type == Media.TEXT: ret_str = '"{content}"\n' sec_ret_str = f'{label}\n' return [ret_str, sec_ret_str] elif type == Media.IMAGE: ret_str = f'{label}\n' return [ret_str, sec_ret_str] elif type == Media.VIDEO: ret_str = '\n' sec_ret_str = f'{label}\n' return [ret_str, sec_ret_str] elif type == Media.AUDIO: ret_str = f'