html.py 720 B

123456789101112131415161718192021222324252627282930
  1. import justpy as jp
  2. from .element import Element
  3. class Html(Element):
  4. def __init__(self, content: str = '', design='', classes: str = ''):
  5. """Html Element
  6. Renders arbitrary html onto the page. `Tailwind <https://tailwindcss.com/>`_ can be used for styling.
  7. :param content: the html code to be displayed
  8. """
  9. view = jp.QDiv()
  10. super().__init__(view, design=design, classes=classes)
  11. self.content = content
  12. @property
  13. def content(self):
  14. return self.content.inner_html
  15. @content.setter
  16. def content(self, content: any):
  17. self.set_content(content)
  18. def set_content(self, content: str):
  19. self.view.inner_html = content