html.py 704 B

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