Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.

brainprep.reporting.html_reporting.HTMLReport

class brainprep.reporting.html_reporting.HTMLReport(html, width=800, height=800)[source]

Bases: object

Render and manage HTML content for display in web pages or Jupyter notebooks.

This class encapsulates HTML content and provides utilities for rendering it inline (e.g., in Jupyter), resizing the display area, and exporting to an HTML file. It supports iframe embedding and integrates with notebook display protocols.

The different rendering are available as follows:

  • print the object to get the content of the web page.

  • from a Jupyter notebook, the plot will be displayed inline if this object is the output of a cell.

  • use save_as_html to save it as an html file.

  • use get_iframe to have it wrapped in an iframe.

Parameters:
htmlstr

The HTML content to be rendered.

widthint

Width of the display area in pixels. Default 800.

heightint

Height of the display area in pixels. Default 800.

Examples

>>> html = "<h1>Hello, world!</h1>"
>>> report = HTMLReport(html)
>>> print(report)
<h1>Hello, world!</h1>
>>> report.save_as_html("/tmp/output.html")
__init__(html, width=800, height=800)[source]
get_iframe(width, height)[source]

Get the document wrapped in an inline frame.

Parameters:
width: int | None

Width of the inline frame. Default None.

height: int | None

Height of the inline frame. Default None.

Returns:
wrapped: str

Raw HTML code for the inline frame.

Notes

Useful for inserting the document content in another HTML page, i.e. in a Jupyter notebook.

resize(width, height)[source]

Resize the document displayed.

Parameters:
width: int

New width of the document.

height: int

New height of the document.

Returns:
Self
save_as_html(file_name)[source]

Save the plot in an HTML file, that can later be opened in a browser.

Parameters:
file_name: str

Path to the HTML file used for saving.

Examples using brainprep.reporting.html_reporting.HTMLReport

HTML reporting

HTML reporting