Source code for frontend.widgets

'''
Created on 2021-01-04

@author: wf
'''

[docs]class Widget(object): ''' a HTML widget ''' def __init(self): pass def __str__(self): html=self.render() return html
[docs]class Image(Widget): ''' a HTML Image ''' def __init__(self,url,alt=None,width=None,height=None): ''' constructor Args: url(str): the link alt(str): alternative image representation (if any) ''' self.url=url if alt is not None: self.alt=alt else: self.alt=url self.width=width self.height=height
[docs] def render(self): ''' render me Returns: str: html code for Image ''' width=" width='%d'" % self.width if self.width is not None else "" height=" height='%d'" % self.height if self.height is not None else "" html="<img src='%s' alt='%s'%s%s/>" % (self.url,self.alt,width,height) return html